[TIMOB-24177] Android : TiHTTPClient / Request Length Expected Wrong (6.1.0 regression)
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Critical |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2016-12-01T02:55:14.000+0000 |
Affected Version/s | Release 6.1.0 |
Fix Version/s | Release 6.1.0 |
Components | Android |
Labels | android, httpclient, qe-6.1.0, regression |
Reporter | Dongwoo Gim |
Assignee | Gary Mathews |
Created | 2016-11-21T04:59:59.000+0000 |
Updated | 2016-12-01T19:21:58.000+0000 |
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
File | Date | Size |
---|---|---|
스크린샷 2016-11-22 오후 2.12.48.png | 2016-11-22T05:18:23.000+0000 | 933778 |
Hello, Please provide a sample code which regenerates the issue. Thanks.
Add runnable sample code. Thank you. Maybe, this is critical bug.
Hello, With your sample code, I did not saw the error when I run on Android 6.0.0 emulator with SDK 6.0.0.GA. Here is my log
Yes, Ti SDK 6.0.0.GA is ok. But, Ti SDK 6.1.0+ has this error.
Hey, This is a critical problems. Why is there no action?
Hello, We would suggest you to use the latest SDK 6.0.0.GA. As 6.1.0+ are master release we will keep that in mand and fixed it for the later official release. Right now you need to use the GA release which is fine. Thanks.
Of course, I know that there is no problem if I use 6.0.0.GA. But this is a simple but critical problem. However, even after several days of reporting, why will not issues issue to TIMOB? Please, change to TIMOB. Thank you.
[~engross] Because it was holiday and weekend :-). [~gmathews], I remember we did some HTTP-Client changes for Android in 6.1.0 already, do you remember the exact ones? /cc [~michael] who also did one I think
Thanks! So TIMOB-20483 caused the regression with [this changes](https://github.com/appcelerator/titanium_mobile/pull/8522/files).
master: https://github.com/appcelerator/titanium_mobile/pull/8646
Verified as fixed TiHTTPClient requests are now handled correctly. Tested on: {noformat} macOS Sierra 10.12.1 Nexus 5X(6.0.1) Nexus 6p (7.0) android emulator (4.4.2) Studio: 4.8.0.201611121409 Ti SDK: 6.1.0.v20161201064221 Appc NPM: 4.2.8 App CLI: 6.1.0-302 Node v4.4.7 {noformat} *Closing Ticket.*