Opened 5 years ago

Closed 5 years ago

#3513 closed defect (worksforme)

GPX upload through API fails with content-type and encodings

Reported by: rcgroot@… Owned by: tom@…
Priority: major Milestone: OSM 0.6
Component: api Version:
Keywords: gpx upload Cc:

Description

I'm uploading GPX files to the dev server using Apache httpclient-4.1.jar and am receiving unclear errors and HTTP-500 status.

Executing the same upload with a perl script succeeds. Tracing the procedure with Wireshark shows only a major difference in the added Content-Type and Content-Transfer-Encoding in the Mime entities.

Attached the network traces to api06.dev.openstreetmap.org using Java and Perl.

Thank for lookin into this.
Rene

Working on Android Open GPS Tracker, Direct upload to OpenStreetMap
http://code.google.com/p/open-gpstracker/issues/detail?id=194
Lines 469-538 http://code.google.com/p/open-gpstracker/source/browse/trunk/OpenGPSTracker/trunk/application/src/nl/sogeti/android/gpstracker/actions/ShareTrack.java?r=816

Attachments (2)

java_stream.txt (10.0 KB) - added by rcgroot@… 5 years ago.
Network sniff of Java code uploading and failing
perl_stream.txt (9.4 KB) - added by rcgroot@… 5 years ago.
Network sniff of Perl code uploading and succeeding

Download all attachments as: .zip

Change History (5)

Changed 5 years ago by rcgroot@…

Network sniff of Java code uploading and failing

Changed 5 years ago by rcgroot@…

Network sniff of Perl code uploading and succeeding

comment:1 Changed 5 years ago by TomH

This appears to be an issue with rack - it treats any field in a multipart/form-data submission which has a content-type as a file which confuses the upload code which only expects the actual GPX data to be a file.

It looks like it is fixed in rack 1.2.1 but rails 2 still uses 1.1.0 so we're probably stuck with this until we can manage to go to rails 3.

comment:2 Changed 5 years ago by rcgroot@…

Okay, thanks for clearing that up. I'll adjust the upload on the client side.

comment:3 Changed 5 years ago by rcgroot@…

  • Resolution set to worksforme
  • Status changed from new to closed

http-client offers a quick fix client-side:
A constructor parameter allows httpclient changes the behavior as desired.

new MultipartEntity?(HttpMultipartMode?.BROWSER_COMPATIBLE);
http://hc.apache.org/httpcomponents-client-ga/httpmime/apidocs/org/apache/http/entity/mime/MultipartEntity.html

Note: See TracTickets for help on using tickets.