Jonathan
Jonathan

Reputation: 1602

Using NSURLConnection with URL's with illegal characters

I have to call a third party webservice that expects and only accepts illegal characters (according to the RFC) in it's param string, like the below.

http://example.com?param1={foo=bar}

In this example the braces are the illegal characters, and should be encoded, however this webservice will not accept the parameters if these characters have been encoded.

NSURL correctly doesn't allow me to create a NSURL object with the URLWithString method, return nil using a string like the example.

The webservice is provided by a large corporate entity, so changing it would require submitting a bug report to them, which may or may not be actioned soon, if at all, especially considering that the API works as is.

My question is what are some possible solutions to this problem, that i can implement, without changing the Webservice.

Current ideas (downsides) Using CFStream to craft custom HTTP requests (Horrifically large amount of work) Using a webbased proxy that could send the request on my application's behalf (Additional external dependency)

Thanks

Upvotes: 0

Views: 228

Answers (1)

Cocoanetics
Cocoanetics

Reputation: 8247

What you are trying to do is impossible. You need to URL-encode these characters and the server will then automatically decode them.

If you could somehow hack NSURL there would be still many parts of the whole process that would choke on a malformed URL.

Upvotes: 2

Related Questions