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

HTTPClient: nested JSON object corrupts payload

    Details

    • Type: Bug
    • Status: Open
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None

      Description

      the changes in
      https://jira.appcelerator.org/browse/TIMOB-18902 (fix for SDK 4.1.1.GA)
      corrupts the data. The example below displays how the nested object 'syncParameters' corrupts the data sent to the server.

      var xhr = Ti.Network.createHTTPClient({
          timeout: 20000
      });
       
      xhr.open('POST', "http://httpbin.org/post");
       
      xhr.onload = function() {
      };
       
      xhr.onerror = function(err) {
      };
       
      var data = {
          "challenge": 578,
          "syncSource": "weather",
          "foo" : "bar",
          "syncParameters": {
              "zoo" : "lander",
              "sequel" : 2
        }
      };
       
      xhr.send(data);
      

      server logs the following data:

      {
        "args": {},
        "data": "{\"zoo\":\"lander\",\"sequel\":2}",
        "files": {},
        "form": {},
        "headers": {
          "Accept": "*/*",
          "Accept-Encoding": "gzip, deflate",
          "Accept-Language": "en-us",
          "Content-Length": "27",
          "Content-Type": "application/json;charset=utf-8",
          "Host": "httpbin.org",
          "User-Agent": "Appcelerator Titanium/4.1.1 (iPhone Simulator/8.4; iPhone OS; en_US;)",
          "X-Requested-With": "XMLHttpRequest",
          "X-Titanium-Id": "bb09dc9f-daba-443a-b382-XXXXXXXX"
        },
        "json": {
          "sequel": 2,
          "zoo": "lander"
        },
        "origin": "XXXXXX",
        "url": "http://httpbin.org/post"
      }
      

      The transfer is ok if the nested object is left out - again, server logs the following data:

      {
        "args": {},
        "data": "",
        "files": {},
        "form": {
          "challenge": "578",
          "foo": "bar",
          "syncSource": "weather"
        },
        "headers": {
          "Accept": "*/*",
          "Accept-Encoding": "gzip, deflate",
          "Accept-Language": "en-us",
          "Content-Length": "40",
          "Content-Type": "application/x-www-form-urlencoded; charset=utf-8",
          "Host": "httpbin.org",
          "User-Agent": "Appcelerator Titanium/4.1.1 (iPhone Simulator/8.4; iPhone OS; en_US;)",
          "X-Requested-With": "XMLHttpRequest",
          "X-Titanium-Id": "bb09dc9f-daba-443a-b382-87ee27fa7ff1"
        },
        "json": null,
        "origin": "213.3.53.205",
        "url": "http://httpbin.org/post"
      }
      

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              patrickr Patrick Reichardt
            • Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:

                Backbone Issue Sync

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

                  Git Source Code