Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

[BUG] xhr won't accept foreign characters in URL path

Attempting to download a file with foreign characters in the filename or directory name fails with "bad url":

var xhr3 = Titanium.Network.createHTTPClient();
xhr3.onload = function()
    Ti.API.info('in utf-8 onload for GET with QS');
xhr3.onerror = function(e)
    Ti.API.info('in utf-8 error for GET with QS:' + e.error);


The culprit seems to be in TiUtils.m:

            NSRange range = [object rangeOfString:@"?"];
            if (range.location != NSNotFound)
                NSString *qs = [TiUtils encodeURIParameters:[object substringFromIndex:ra

What's the rationale here? Why isn't the whole URL encoded?


It seems I can work around the problem by munging the URL myself:

url = Ti.Network.encodeURIComponent(url);
url = url.replace(/%3A/g, ":");
url = url.replace(/%2F/g, "/");

I would have expected Ti to handle this for me, however.

— asked May 23rd 2010 by Damien Elmes
  • iphone
  • mobile
  • xhr

0 Answers

The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.