floooh / oryol

A small, portable and extensible C++ 3D coding framework
MIT License
2k stars 200 forks source link

Get error code on failure to load file for emscripten httpfs #316

Closed pixelherodev closed 6 years ago

pixelherodev commented 6 years ago

Switches to wget2_data as per the comments. Testing right now.

pixelherodev commented 6 years ago

Okay, so it seems to call OnLoaded even when it fails to load. ... I'll work on that.

pixelherodev commented 6 years ago

Ah. The wget2_data source contains this:

      if (http.status == 200 || _url.substr(0,4).toLowerCase() != "http") {

Stripping the beginning of the URL is what's causing this.

pixelherodev commented 6 years ago

It works now:

Failed to load https://google.com/: Redirect from 'https://google.com/' to 'https://www.google.com/' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'https://zany80.github.io' is therefore not allowed access.
(index):79 emscURLLoader::onFailed(url=https://google.com, code=0, message=(null))
zany80.js:23 emscURLLoader::onFailed(url=https://zany80.github.io/lua/emscripten/plugins/NonExistent/Deliberate404, code=404, message=(null))
pixelherodev commented 6 years ago

Question though: why does the IO README suggest using http and not https for the URI?

floooh commented 6 years ago

Ok, this is another one I need to look at and test a bit more carefully :) I'll try to find some time in the next 3..4 days or so.

When I wrote the IO docs I hadn't put much thought into http: vs https:, and when loading data from the same server (so not CORS), the protocol should be ignored anyway (it should use the same protocol the emscripten page was loaded with I think).

pixelherodev commented 6 years ago

I suspect it was only using the same protocol because the http:// part was dropped. In my tests, i get errors about how http:// resources are blocked on https:// pages because I'm using this in my live code.

floooh commented 6 years ago

Did some local testing on the Oryol and Oryol-Samples webpage and it looks fine I think. It's a tiny bit bigger then before (<1%) but that's ok.

Thanks for the PR :)

pixelherodev commented 6 years ago

no problem!