Skip to content
This repository has been archived by the owner on Nov 25, 2019. It is now read-only.

Optimize http requests - IFileSource: replace UnityWebRequest with WWW #30

Closed
wilhelmberg opened this issue Jan 18, 2017 · 6 comments
Closed

Comments

@wilhelmberg
Copy link
Contributor

refs #11

background: https://github.com/mapbox/mapbox-go/issues/28

http://answers.unity3d.com/answers/1172963/view.html
Apple blocks access to HTTPS through non-approved code paths, and HttpWebRequest is not part of the approved code path. We switched our implementation around and used Unity.WWW to get around the problem.

https://docs.unity3d.com/ScriptReference/WWW.html

@wilhelmberg
Copy link
Contributor Author

hmm!
Getting 401 Unauthorized using WWW:
image

The URL works in the browser and with UnityWebRequest.

@david-rhodes
Copy link
Contributor

I spent 5 minutes converting UnityWebRequest into WWW last night and saw errors on iOS, as well. It seemed to work in the editor, though.

Rather than replacing UnityWebRequest, I think we should make a different concrete version of IFileSource that uses WWW. There may be a fix for all this in the near future (being hopeful here).

The other thing to look out for with WWW is making it cancelable. I'm very surprised there isn't more discussion about this on the internet, given how much this affects so many developers . . .

@wilhelmberg
Copy link
Contributor Author

Oops, my bad I added the access_token to the request url twice.
It does work with WWW.

The other thing to look out for with WWW is making it cancelable. I'm very surprised there isn't more discussion about this on the internet, given how much this affects so many developers . . .

Yes, noticed that too - that's not good.
Luckily we don't transfer a lot of data per request.

@david-rhodes
Copy link
Contributor

If you throw this on a branch today, I can test on iOS. 😄

@wilhelmberg
Copy link
Contributor Author

Working branch is here: https://github.com/mapbox/mapbox-sdk-unity-core/tree/optimize-http-requests

It's not yet completely usable, but that's the HTTPRequest.cs using WWW.

Maybe you could just replace the file?
Should be a drop-in replacement.

EDIT -->
updated Response.cs is also needed as I added the response headers
<-- EDIT.

@david-rhodes
Copy link
Contributor

FWIW, this should not be a replacement, but an additional option.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants