Question

NSURL *url = [NSURL URLWithString:@"appName://<?xml version=\"1.0\" encoding=\"UTF-8\"?>"];

But the url = nil. I found if I remove the "<" and ">" signs, it will be ok. So, the two signs cannot be used in a URL? Should I replace the signs with another one?

Thanks!

Was it helpful?

Solution

I solved this problem. Before I do NSURL *url = [NSURL URLWithString:@"...."]; I first do:

    NSString *urlStr = [string stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];

And when parse this url on the receiver side, I firstly do:

NSString *urlString = [[url absoluteString] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; // url is a NSURL

OTHER TIPS

Why would you not just POST the document in the body of the request?

GET requests are not designed for this. You may get into difficulty if there are UTF-8 chars in the document.

Also What is the maximum length of a URL in different browsers? implies a max of 2083 chars.

You're into a very browser/proxy dependent scenario.

Theoretically yes. You can use urlEncode to do this. The HTTP protocol does not place any limit on the length of the URL.

RFC says:

Note: Servers ought to be cautious about depending on URI lengths above 255 bytes, because some older client or proxy implementations might not properly support these lengths.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top