Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-2675] Can't set Content-Type request header

GitHub Issuen/a
TypeBug
PriorityTrivial
StatusClosed
ResolutionFixed
Resolution Date2011-04-17T01:59:47.000+0000
Affected Version/sn/a
Fix Version/sRelease 1.6.0 M06
ComponentsiOS
Labelscontent-type, headers, ios, release-1.6.0, rplist, xhr
ReporterStephen Tramer
AssigneeStephen Tramer
Created2011-04-15T03:26:37.000+0000
Updated2011-04-17T01:59:47.000+0000

Description

Self-explanitory. Sample code from #1983:

var xhr = Titanium.Network.createHTTPClient();
xhr.onload = function()
{
       Ti.API.info('I am in utf-8 onload for POST');
};
xhr.onerror = function()
{
       Ti.API.info('I am in utf-8 error for POST');
};
xhr.setRequestHeader("setoutside", "one");
xhr.open("POST","http://api.localmedia.fm/files/endpoint_webform.cfm");
xhr.setRequestHeader("content-type", "multipart/form-data");
xhr.setRequestHeader("setinside", "two");
xhr.send({"a":"hi", "b":"there"});

The response is always:

Content-Type     application/x-www-form-urlencoded; charset=utf-8

Should be considered part of the XHR refactor.

Comments

  1. Anthony Webb 2011-04-15

    @stephen, Any sort of an ETA on this bug being fixed? I'd rather go through this app store approval process once, so if it is coming soon then I will hang tight for a fix, if not then I should probably remove camera support from my app and go ahead and get the app submitted without it. Just give me an idea of how complicated/important this bug fix is to you guys right now. Thanks.

  2. Stephen Tramer 2011-04-15

    It will be fixed for 1.6.0. There is no other timeline on this bug.

  3. Stephen Tramer 2011-04-15

    Ticket is targeted to be fixed by Jan 17, but there are no guarantees.

  4. Taazza 2011-04-15

    Jan 17th is the target date for 1.6?

  5. Anthony Webb 2011-04-15

    Thanks Stephen. I'll hang tight, really appreciate the help, this is a bit of a blocker for me.

  6. Stephen Tramer 2011-04-15

    No. Only this ticket is targeted for that date.

  7. Dawson Toth 2011-04-15

    Associated Helpdesk Ticket

    http://developer.appcelerator.com/helpdesk/view/65171">http://developer.appcelerator.com/helpdesk/view/65171

  8. Stephen Tramer 2011-04-15

    Assigned to somebody else so moved to M06.

  9. Jeff Haynie 2011-04-15

    (from [623a1f982c3f4107d250179d52bd9ccbe3374994]) [#2675 state:fixed-in-qa] Allow setting of 'Content-Type'. https://github.com/appcelerator/titanium_mobile/commit/623a1f982c3f4107d250179d52bd9ccbe3374994"> https://github.com/appcelerator/titanium_mobile/commit/623a1f982c3f...

  10. Stephen Tramer 2011-04-15

    Two things to note:

    • The "Content-Type" header is case-sensitive. It is not "content-type".
    • We do not support multipart MIME messages. This is a feature which will be added at an unscheduled time; please keep in mind that HTTPClient right now is not a TRUE HTTP client, but rather an XHR (XML HTTP Request), meaning that it is only suitable for a single-request architecture.
  11. Anthony Webb 2011-04-15

    I see the code has been committed, at what point are these fixes picked up by nightly builds for testing? I assume "fixed-in-qa" is an internal thing? Thanks a bunch this should allow me to move forward.

  12. Anthony Webb 2011-04-15

    I saw in the continuous build that this change was in there so I gave it a shot:

        var xhr = Titanium.Network.createHTTPClient();
        xhr.onload = function()
        {Ti.API.info('onLoad for POST, firing event with data: ' + this.responseText);};
        xhr.onerror = function()
        {Ti.API.info('I am in utf-8 error for POST');};
        xhr.open("POST","http://api.localmedia.fm/files/test.cfm");
        xhr.setRequestHeader("Content-Type", "multipart/form-data");
        xhr.send({"a":"hi", "b":"there"});
        
    It appears as though it is still broke though. If I run the code above I get:
        [INFO] onLoad for POST, firing event with data: undefined
        
    If I comment out the setRequestHeader() then it goes through fine :(
  13. Stephen Tramer 2011-04-15

    As indicated in this ticket we do not support multipart messages. There is no timeline for this feature.

  14. Anthony Webb 2011-04-15

    Any fresh ideas on letting the user POST photos that the user takes to my server? Seems like something pretty basic I want to do here? Additionally, it would have been nice to know this a month ago when this ticket was opened so I could have asked this question back then.

  15. Dawson Toth 2011-04-15

    The customer's issue hasn't been fixed. The original code includes "multipart/form-data" as the content type, so I'm not sure why this is marked as fixed-in-qa when I believe it isn't.

    Please let me know if you would like an additional ticket created for supporting multipart messages.

  16. Stephen Tramer 2011-04-15

    Supporting multipart mime is a different issue from "Can't set Content-Type request header." The bug, as described in the original ticket, is fixed.

    Create a second bug for multipart support.

  17. Pedro Enrique 2011-04-15

    Initial bug fixed.

    Tested on iPhone Simulator 4.2 with code provided

    Ti SDK 1.6 (Jan 27 2011 16:11 rc27ef530)

  18. Andre Carregal 2011-04-15

    I've added a new bug report ((#3145)) for the multipart support.

JSON Source