Uploaded image for project: 'Titanium SDK/CLI'
  1. Titanium SDK/CLI
  2. TIMOB-19817

Android: HTTPClient multipart header error

    Details

    • Story Points:
      1
    • Sprint:
      2015 Sprint 22 SDK

      Description

      The following code (upload a blob to the server), creates malformed http header:

      var xhr = Titanium.Network.createHTTPClient();
      xhr.onload = function() {...};
      xhr.open('POST',serverUrl');
      xhr.send({file:aBlob,name:'something'});
      

      This creates the request:

      POST /api/1/upload/ HTTP/1.1
      Accept-Encoding: identity
      X-Titanium-Id: 12345678-2222-4444-8888-111111111111
      Content-Type: multipart/form-data; boundary=j7D5qBH3i-pbXOzjDHVJNdQRhPBvF-Q0PUmVjZe
      ...
      Content-Length: 56789
       
      --j7D5qBH3i-pbXOzjDHVJNdQRhPBvF-Q0PUmVjZe
      Content-Disposition: form-data; name="file""; filename="tixhr1851009574.png"
      Content-Type: image/png
      Content-Transfer-Encoding: binary
      ...
      

      Note the double quotes for the name part:
      Content-Disposition: form-data; name="file""; filename="tixhr1851009574.png"

      I've traced the bug to TiHTTPClient.java at addFilePart(String name, ContentBody contentBody). The extra " comes when appending the filename argument.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                msamah Ashraf Abu (Inactive)
                Reporter:
                buddyguards grebulon
                Reviewer:
                Hieu Pham
              • Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Backbone Issue Sync

                  • Titanium SDK/CLI <> Titanium Mobile
                    Synced with:
                    TIMOB-20570
                    Sync status:
                    ERROR
                    Last received:
                    Last sent:

                    Git Source Code