Why is System.Net.WebRequest unsupported in iOS?

Using System.Net.WebRequest on an iOS project results in a NotSupportedException.

Why is this? This is really crippling from my point of view, and really limits what can be done with web services within a Unity game.

Please don’t tell me to use WWW, I can’t even read a HTTP status code that, or set headers…

Is there a way around this, or am I going to be forced to write my own WebRequest class?

Okey so I’m not telling you to use WWW, you can always use System.Net and TCPSockets to pull it off yourself. The HTTP protocol is extremely easy actually.
Alternatively a native code plugin to NSURLRequest allows you to do it too.

As for WWW:
WWW uses the native NSURLRequest on iOS, the best and most stable form of request you can do.

.Net.WebRequests are basically nowhere supported by Unity (aside of perhaps standalone win / osx) as it focuses its usage on WWW which complies to the limitations of the various platforms (aot on iOS, security sandbox on webplayer etc), a thing that is not the case for WebRequests.

OK. Here is one laptop-battery-charge worth of coding. It still has a way to go, but it is starting to work.

http://code.google.com/p/unityweb/source/checkout

This project provides a replacement HTTP.Request class for Unity3D, based on System.Net.TcpClient, using Asynchronous IO.

TODO: Add proxy support, Gzip decompression, documentation and examples.

Hello Simon, thanks for sharing this! - Will this also be working when exporting to iOS ?

@Dreamora Hi, could you please confirm if UnityWebRequest is processing request on a background thread?

I can see that it is split to IEumerator yields, but I want to know if there is there a separate background thread is involved? The predecessor (WWW) was also Coroutine based, but still the calls between yields freezed the main thread. It is really annoying, when a web service is lagging / not available.

Has UnityWebRequest fixed this?