Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-2339] Android Response Headers BUG

GitHub Issuen/a
TypeBug
PriorityTrivial
StatusClosed
ResolutionFixed
Resolution Date2011-04-17T01:58:49.000+0000
Affected Version/sn/a
Fix Version/sRelease 1.5.0 M05
ComponentsAndroid
Labelsandroid, defect, rplist
ReporterAndroid3000
AssigneeDon Thorp
Created2011-04-15T03:17:07.000+0000
Updated2011-04-17T01:58:49.000+0000

Description

ANDROID HTTPCLIENT BUG!
Source: android/modules/network/src/ti/modules/titanium/network/TiHTTPClient.java

In line #625 should be: response object instead of request:

public String getAllResponseHeaders() {
    String result = "";
    if (readyState >= READY_STATE_HEADERS_RECEIVED)
    {
        StringBuilder sb = new StringBuilder(1024);

*===> Header[] headers = request.getAllHeaders();

        int len = headers.length;
        for(int i = 0; i < len; i++) {
            Header h = headers[i];
            sb.append(h.getName()).append(":").append(h.getValue()).append("\n");
        }
        result = sb.toString();
    } else {
        // Spec says return "";
    }

    return result;
}

Comments

  1. Android3000 2011-04-15

    Maybe it should be changed in 1.4.X versions too.
    Thanks

  2. Android3000 2011-04-15

    IOS code is incorrect too!

  3. Bill Dawson 2011-04-15

    simple failcase app.js. Check logcat and you'll see only request headers are there.

       var xhr = Ti.Network.createHTTPClient();
       xhr.onload = function() {
           Ti.API.info('Response Headers');
           Ti.API.info(xhr.allResponseHeaders);
       };
       xhr.open('GET', 'http://www.appcelerator.com');
       xhr.send();
       
  4. Bill Dawson 2011-04-15

    (from [4f2561249677572219e50bfa7483c029da2953fd]) [#2339 state:fixed-in-qa] getAllResponseHeaders was actually returning request headers https://github.com/appcelerator/titanium_mobile/commit/4f2561249677572219e50bfa7483c029da2953fd"> https://github.com/appcelerator/titanium_mobile/commit/4f2561249677...

  5. Matt Schmulen 2011-04-15

    Titanium SDK version: 1.5.0 (12/07/10 10:00 8f4eea3...), bugTest, Android 1.6, 2.1

JSON Source