Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-6832] iOS: Search for response headers is case sensitive

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2012-01-23T16:56:03.000+0000
Affected Version/sRelease 1.8.0.1
Fix Version/sSprint 2011-52, Release 2.0.0, Release 1.8.1
ComponentsiOS
Labelsparity
ReporterRadamantis Torres-Lechuga
AssigneeStephen Tramer
Created2011-12-21T15:26:15.000+0000
Updated2014-06-19T12:44:36.000+0000

Description

Expected Behavior

Create a custom header with a name, and find it by this name case insensitive

Actual Behavior

While upgrading from iOS4 to iOS5 we ran into some issues where iOS4 appeared to be changing the case of response header names--so "MY-Custom-Header" would become "My-Custom-Header". As a result when we tried searching for "MY-Custom-Header" it would not be found. To solve this problem we performed a case-insensitive search for response headers. In the Titanium Mobile's caseCorrect method (iPhone/Classes/TiUtils.m) it looks like the code is attempting to fix this case-changing problem on pre-iOS5 versions. There's a problem here though: if the a response header is called "my-custom-header" it will not be found in pre-iOS5 versions because caseCorrect converts it to "My-Custom-Header".

Test Case

var xhr = Titanium.Network.createHTTPClient();

xhr.onload = function()
{
    var customHeader = "my-custom-header";
    Titanium.API.debug( "Custom response header: " + customHeader + " = " + xhr.getResponseHeader( customHeader ) );
};

xhr.open( "GET", "http://localhost:8080/" );
xhr.send();

Response

The debug output on the iPhone 4.3 Simulator was: [DEBUG] Custom response header: my-custom-header = undefined The debug output on the iPhone 5 Simulator was: [DEBUG] Custom response header: my-custom-header = header value

Comments

  1. Stephen Tramer 2011-12-27

    The provided test is not valid without a properly configured server; we need something that feeds a custom header reliably from a remote source in order to properly test and QE a fix.
  2. Stephen Tramer 2011-12-27

    There is a fix ready but until there is a valid test, it cannot be submitted.
  3. Stephen Tramer 2011-12-27

    Fix was tested by redirecting to a file containing the following PHP snippet:
       <?php header("my-custom-header: durpdurp");?>
       
    Note that reviewers may require an external server to test this; I tested locally via an apache install.
  4. Thomas Huelbert 2012-01-18

    clean up - closing

JSON Source