Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-1461] HTTP PUT method fails with SDK 1.4.0 due to url-encoded path

GitHub Issuen/a
TypeBug
PriorityTrivial
StatusClosed
ResolutionFixed
Resolution Date2011-04-17T01:56:14.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsiOS
Labelsencoded, encoding, get, httpclient, ios, method, percent, put, url
ReporterMartin Lasak
AssigneeJeff Haynie
Created2011-04-15T02:53:28.000+0000
Updated2011-04-17T01:56:14.000+0000

Description

We upgraded to Titanium Mobile SDK from 1.3.0 to 1.4.0 and use the same code base, but the effect differs.

Trying to perform a HTTP request with PUT method fails and results always in call of onerror and in a 404 errorcode.
Due to Wireshark analysis of HTTP request, we figured out that the path part of uri is url-encoded now.

Requests towards uris like
http://www.ourdomain.com/our,comma,separated,path/">http://www.ourdomain.com/our,comma,separated,path/
will not work anymore in titanium mobile sdk 1.4.0

Following code snippet works with 1.3.0 on iOS 3.1.3 and does not work with 1.4.0 on iOS 4.0.1

        var xhrPut = Titanium.Network.createHTTPClient();
        xhrPut.onload = function()
        {
            if (this.status===204){
                log("calling succes callback.");
            }else{
                log("error loading "+this.status+" "+this.responseData);
            }
        };
        xhrPut.onerror = function()
        {
            log("error loading "+this.status+" "+this.responseData);
        };

        xhrPut.open("PUT",baseuri+uri);
        xhrPut.setRequestHeader('Authorization','Basic '+authstrPut);
        xhrPut.setRequestHeader('Content-Type', 'application/json; charset=utf-8');
        xhrPut.setRequestHeader('Accept', 'application/json');
        xhrPut.send(JSON.stringify(params));

        //variables: baseuri, uri, authstrPut, params

With regards.

Comments

  1. Damien Elmes 2011-04-15

    I believe this is fixed in the latest git already.

  2. Hugo Josefson 2011-04-15

    I have this problem too in Titanium SDK 1.4.0.

    For me, it's when I do a GET like this:

       var url = 'http://www.ourdomain.com/page?Einstein=E%3Dmc2&;paramWithSlashInIt=asd%2Fasd';
       

    When the xhr fetches that, it becomes:

       http://www.ourdomain.com/page?Einstein=E%253Dmc2&;paramWithSlashInIt=asd%252Fasd
       

    ...because the percent characters are encoded again. For us this makes it impossible to do OAuth signed GET requests, which are vital for our application.

    I can confirm that nightly build from Aug 3 fixes the problem.

    !! Please cut a 1.4.1 release soon :) !!

    Thanks for all your hard work.
    /Hugo

  3. Stephen Tramer 2011-04-15

    I know that this is a duplicate of a bug that either Jeff or I have fixed; we fiddled with URL encoding for a while. ',' characters are no longer escaped. Checked 1.6.0RC1.

JSON Source