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
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.
There is a fix ready but until there is a valid test, it cannot be submitted.
Fix was tested by redirecting to a file containing the following PHP snippet:
Note that reviewers may require an external server to test this; I tested locally via an apache install.
clean up - closing