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

Android http client sets the Content Type header on all requests verbs, causing some servers to time out when expecting a request body

    Details

    • Story Points:
      2
    • Sprint:
      2016 Sprint 10 SDK

      Description

      This is a bug found when attempting to connect to a backend running Hunchentoot (Clisp web server), and the CLisp web framework Lucerne.
      Most other application servers I have experience with wouldn't mind, but this server expects to parse a request body when the Content Type is set. The Android http client, contrary to the iOS one, sets the content type not only on Post/Put/Patch as per the documentation, but actually on all http verbs.
      The issue can be easily fixed by changing :

      if (parts.size() > 0 && needMultipart) {
      						boundary = HttpUrlConnectionUtils.generateBoundary();
      						client.setRequestProperty("Content-Type", "multipart/form-data; boundary=" + boundary);
      					} else {
      						client.setRequestProperty("Content-Type","application/x-www-form-urlencoded");
      					}
      

      to

      if (parts.size() > 0 && needMultipart) {
      						boundary = HttpUrlConnectionUtils.generateBoundary();
      						client.setRequestProperty("Content-Type", "multipart/form-data; boundary=" + boundary);
      					} else if (isPostOrPutOrPatch){
      						client.setRequestProperty("Content-Type","application/x-www-form-urlencoded");
      					}
      

      on itanium_mobile/android/modules/network/src/java/ti/modules/titanium/network/TiHTTPClient.java

      I could send a pull request if you want.
      Cheers
      Richard

        Attachments

          Activity

            People

            • Assignee:
              msamah Ashraf Abu (Inactive)
              Reporter:
              rlustemberg Richard Lustemberg
            • Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Backbone Issue Sync

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

                  Git Source Code