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

Android : TiHTTPClient / Request Length Expected Wrong (6.1.0 regression)

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Critical
    • Resolution: Fixed
    • Affects Version/s: Release 6.1.0
    • Fix Version/s: Release 6.1.0
    • Component/s: Android
    • Environment:
    • Story Points:
      5
    • Sprint:
      2016 Sprint 24 SDK

      Description

      Ti SDK 6.1.0+ (6.1.0.v20161121162514) has error. But, 6.0.0.GA is ok

      When using TiHTTPClient with Non-english language + POST json request, raised errors.
      (No error in only english request)

      [ERROR] TiHTTPClient: (TiHttpClient-1) [308,308] HTTP Error (java.net.ProtocolException): expected 17 bytes but received 21
      [ERROR] TiHTTPClient: java.net.ProtocolException: expected 17 bytes but received 21
      [ERROR] TiHTTPClient: 	at com.android.okhttp.internal.http.HttpConnection$FixedLengthSink.write(HttpConnection.java:299)
      [ERROR] TiHTTPClient: 	at com.android.okhttp.okio.RealBufferedSink.flush(RealBufferedSink.java:221)
      [ERROR] TiHTTPClient: 	at com.android.okhttp.okio.RealBufferedSink$1.flush(RealBufferedSink.java:204)
      [ERROR] TiHTTPClient: 	at java.io.FilterOutputStream.flush(FilterOutputStream.java:88)
      [ERROR] TiHTTPClient: 	at ti.modules.titanium.network.httpurlconnection.StringEntity.writeTo(StringEntity.java:64)
      [ERROR] TiHTTPClient: 	at ti.modules.titanium.network.TiHTTPClient$ClientRunnable.handleURLEncodedData(TiHTTPClient.java:1394)
      [ERROR] TiHTTPClient: 	at ti.modules.titanium.network.TiHTTPClient$ClientRunnable.run(TiHTTPClient.java:1199)
      [ERROR] TiHTTPClient: 	at java.lang.Thread.run(Thread.java:818)
      [ERROR] {"tlsVersion":3,"timeout":120000,"domain":null,"autoEncodeUrl":true,"username":null,"autoRedirect":true,"password":null,"readyState":1,"responseText":"","statusText":null,"connectionType":"POST","connected":false,"responseXML":null,"status":0,"location":"http://parseserver-bsmcf-env.us-east-1.elasticbeanstalk.com/parse/functions/findUsers","allResponseHeaders":"","validatesSecureCertificate":false,"responseData":null,"bubbleParent":true,"apiName":"Ti.Network.HTTPClient","_events":{"disposehandle":{}}}
      

      This is sample code
      First call raised error.
      But second call is ok(english only).

      httpCall('POST', 'http://parseserver-bsmcf-env.us-east-1.elasticbeanstalk.com/parse/functions/findUsers', JSON.stringify({username: "인연"}), console.log, console.error);
      httpCall('POST', 'http://parseserver-bsmcf-env.us-east-1.elasticbeanstalk.com/parse/functions/findUsers', JSON.stringify({username: "test"}), console.log, console.error);
       
      function httpCall(method, url, data, success, error) {
        var handled = false;
       
        var xhr = Ti.Network.createHTTPClient({
          timeout : 120000
        });
       
        xhr.onload = function(e) {
          if (handled)
            return;
          handled = !0;
       
          if (xhr.status >= 200 && xhr.status < 300) {
            var response;
            try {
              response = JSON.parse(xhr.responseText);
            } catch (e) {
              // error(e.toString());
              success(xhr.responseText, xhr.status, xhr);
            }
            if (response) {
              success(response, xhr.status, xhr);
            }
          } else {
            error(xhr);
          }
        };
       
        xhr.onerror = function(e) {
          if (handled)
            return;
          handled = !0;
       
          error(xhr);
        };
       
        xhr.open(method, url, !0);
        xhr.setRequestHeader("Content-Type", "text/plain");
        xhr.setRequestHeader('X-Parse-Application-Id', 'G7Iqo0zI1d02WsznzwiI6zTl6UL2g5b5');
        xhr.send(data);
      }
      

      Calc expected length functions related unicode string has problem.
      "인연" is 4+4=8byte. "received 21" is right.
      Maybe, string is claculateded 2+2=4byte, it is wrong.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                gmathews Gary Mathews
                Reporter:
                engross Dongwoo Gim
                Reviewer:
                Farzad Merzadyan (Inactive)
                Tester:
                Josh Longton
              • Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Backbone Issue Sync

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

                    Git Source Code