Titanium JIRA Archive
Appcelerator Community (AC)

[AC-2097] iOS: Network.HTTPClient is cleaning all request headers

GitHub Issuen/a
TypeBug
Priorityn/a
StatusClosed
ResolutionInvalid
Resolution Date2013-02-06T18:12:43.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsTitanium SDK & CLI
Labelsbug, headers, http, ios, network
ReporterRafael Kellermann Streit
AssigneeMauro Parra-Miranda
Created2013-02-06T17:15:16.000+0000
Updated2016-03-08T07:41:04.000+0000

Description

I'm working in a application that have this request:
var xhr = Ti.Network.createHTTPClient();

xhr.setRequestHeader("foo", "bar");
xhr.setRequestHeader("Content-Type", "text/plain");

xhr.open("POST", "http://foo.bar");

xhr.send("Foobar");
But I'm having some problems with it (and other people too: http://developer.appcelerator.com/question/147651/setrequestheader-doesnt-work). In *TiNetworkHTTPClientProxy.m* we have this following statement (line 384):
-(void)open:(id)args
{
   ...
   request = [[ASIFormDataRequest requestWithURL:url] retain];
   ... 
}
I think this is cleaning all headers included in request. Am i correctly? So, I changed the code to (because the request already exists):
[request requestWithURL:url];
And it works fine. If I'm correctly, I will make a PR ASAP to titanium_mobile project.

Comments

  1. Rafael Kellermann Streit 2013-02-06

    Sorry, apparently I'm wrong. :-(
  2. Daniel Sefton 2013-02-06

    Could you elaborate?
  3. Rafael Kellermann Streit 2013-02-06

    If I put the request headers after the "open" statement, it will works fine, because of request instance will exists.
  4. Daniel Sefton 2013-02-06

    Thanks, I'll close it now.
  5. Mauro Parra-Miranda 2013-11-24

    Invalid issue.

JSON Source