[OSM-dev] Structured error messages from API

Ævar Arnfjörð Bjarmason avarab at gmail.com
Thu Dec 10 17:09:24 GMT 2009

On Thu, Dec 10, 2009 at 17:01, Peter Körner <osm-lists at mazdermind.de> wrote:
>> You mean showing upload progress in JOSM as opposed to the current
>> cylon impression? That could be implemented by counting the number of
>> bytes of the osmChange request that have been successfully sent over
>> the wire. That's how upload progress bars are usually implemented.
>> Obviously the upload could fail but that's another issue.
> That looks somehow more intelligent than streaming the progress from the
> server back to the client.

It is:) When I upload a file with Google Chrome it always shows the
progress of the upload. This isn't done with some ad-hoc streaming XML
from the server, the client is just counting how many bytes it has
sent over the wire and how large a percentage that is of the total.

I looked at the relevant code in JOSM once but I couldn't find a way
to do it (but I'm not familiar with Java). In Perl with
HTTP::Request::Common you can do e.g.:

    $HTTP::Request::Common::DYNAMIC_FILE_UPLOAD = 1
    my $req = HTTP::Request::Common->new( ... );
    $req->content( sub {
        my $chunk = &$gen();
        my $length = length $chunk;

        warn "I'm now uploading a chunk of length $length, of a total
of $total bytes";

        return $chunk;
     } );
     my $result = LWP::UserAgent->request( $req );

(See this code for a practical example of this that I wrote:

I presume Java has some library to do this as well but I couldn't find it.

More information about the dev mailing list