Hi,
HTTPClient seems to work with a windows IL2CPP client using Unity 2021.3. However, I didn’t have the chance to test it with IOS/Android clients.
Is UnityWebRequest the best solution? The only reason I am asking is that, frankly, I don’t trust Unity implementations, but if you tell me that UnityWebRequest is solid, I’ll switch to it.
1 Like
As far as I know HttpClient doesn’t work in a WebGL environment. (Threads are required for internal operation, the WebGL environment does not support threads.)
Also, if you’re not using async/await support libraries like UniTask, you can write messy code.
However, it is clear that the .Net BCL API is a bit more robust than the Unity API.
Decide on the direction of your project. Maybe this is the realm of taste.
1 Like
That’s right but not the only reason why the HTTPClient doesn’t work in a WebGL build. The class also needs lowlevel socket support which you don’t have in a browser. In a browser the UnityWebRequest wraps around the XMLHttpRequest in javascript. Yes, it’s true that Unity’s implementation has some shortcommings, but generally works fine for most usecases. The advantage is that it is truely cross platform.
I just learned today that the HttpClient’s PATCH method is not working on iOS.
All is fine with UnityWebRequest.