Unity Web Request with Header/Cookie support?

So I have run into the problem of needing the usage of Cookie (not for Web Player, but for Windows game). Running around this Answer and the forum, I see the best I can do is manually set the headers of request and get the response header. I am ok with that, because I am originally ASP.NET MVC developer.

However, I then realize they use Dictionary for both the request and response. Now that’s the problem. We know that the header can be duplicated, in my case is the Set-Cookie.

Then I tried another, and find out UnityWebRequest class, which is still in UnityEngine.Experimental.Networking namespace (so I suppose it is still in beta?), but I try my luck anyway; only sad to realize they also use Dictionary for header items.

So now my only chance is the vanilla .NET WebRequest (in System.Net namespace). However, I see no documentation on the .NET Framework compability in Unity. Can anyone tell me if it is supported on most platform? My main targets are Windows, Android and Web. If possible, even for WebClient would be nicer.

Hi @datvm

To be honest to moved away from unity “www” class long time ago and I was using native C# WebClient, it definitely works on most of the platforms.

Now since Unity 5.2, they introduced “UNET” - new networking for Multiplayer together with new UnityWebRequest which is a replacement for old “www” class.

To be honest, right now I’m checking up on what they did with new “UnityWebRequest”, and still find WebClient better and more flexible, especially with it async stuff…
By some reason Unity still stacked with their Coroutine, which are slower then async and in general, I prefer to deal with delegates and callbacks.
There is one downside of async callbacks which u have to consider - they are received in non-Main thread where most of the unity stuff (like physics, UI etc…) is not accessible. So you would need to implement some sort of buffering queue to enqueue response from non-Main thread, and deque it on next “Update” which is the Main thread.

Just in case you can check my old blog post about Coroutines and Async