Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-9976] MobileWeb: HttpClient in the MobileWeb drops responseText when error happens

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2012-07-17T15:19:22.000+0000
Affected Version/sRelease 2.1.0
Fix Version/sSprint 2012-15 Core, Release 3.0.0
ComponentsMobileWeb
Labelscore, httpclient, qe-port
ReporterSehyo Chang
AssigneeChris Barber
Created2012-07-12T20:22:25.000+0000
Updated2013-01-15T13:29:07.000+0000

Description

1. Client make ajax request using HttpClient 2. Server return HTTP error code 4xx (for example 400) with detail error in the response body There is no way to get response body because HttpClient perform abort after receiving error. Here is method abort for HttpClient
abort: function() {

     var c = this.constants;
     c.responseText = c.responseXML = c.responseData = "";
     this._completed = true;
     clearTimeout(this._timeoutTimer);
--------------------- when abort happens this._xhr.reponseText is cleared --------
     this.connected && this._xhr.abort();
     c.readyState = this.UNSENT;
     this._fireStateChange();

}
So before performing abort on xhr, the responseText should be saved.

Attachments

FileDateSize
app.js2012-07-17T01:30:32.000+00001748
TC1061.zip2012-07-16T15:39:47.000+00002212223

Comments

  1. Junaid Younus 2012-07-16

    Hey Sehyo, Can you please provide a small, runnable test case to reproduce this issue? Instead of providing a small part of the code, please provide something that we can run instantly, in order to get your issue resolved asap. Thanks
  2. Sehyo Chang 2012-07-16

    Attached is sample project
  3. Sehyo Chang 2012-07-16

    Attached sample project that reproduce the case. Here is instruction how to set up (1) unzip the project (2) install nginx. (3) copy nginx conf from "/server/nginx.conf" to nginx installation directory (4) in the nginx.conf, change "root" to point to the /build/mobileweb (3) install node.js (4) cd /server (5) "node good.js" (6) from Studio, run the project as mobileweb. open safari on "http://localhost:8080" (7) click text. It should return string return from node.js server. That shows success is return ok (8) kill node.js and run "node bad.js" (9) refresh the browser and click text. In this case error message is not return properly. UI code is in the "FirstView.js"
  4. Junaid Younus 2012-07-16

    Thanks Sehyo, I have moved the ticket so that the platform team can look into this issue and fix it.
  5. Chris Barber 2012-07-17

    Pull request: https://github.com/appcelerator/titanium_mobile/pull/2582
  6. Sehyo Chang 2012-07-20

    Can you move this to 2.1.1? since this is high priority issue for us
  7. Olga Romero 2013-01-15

    Closing as fixed. Tested and verified with: Titanium Studio, build: 3.0.1.201212181159 Titanium SDK, build: 3.0.O.GA iPad mini iOS 6.0 safari MacBook Pro 10.8.2 Mountain Lion Chrome 23.0

JSON Source