phiresky / sql.js-httpvfs

Hosting read-only SQLite databases on static file hosters like Github Pages
Apache License 2.0
3.47k stars 105 forks source link

Error in detecting partial file support #8

Closed wheybags closed 3 years ago

wheybags commented 3 years ago

Hey, I'm testing this with http-server, and getting the following error message in console:

server does not support byte serving (`Accept-Ranges: bytes` header missing), or your database is hosted on CORS and the server doesn't mark the accept-ranges header as exposed seen response headers cache-control: max-age=3600
connection: keep-alive
content-length: 169918464
content-type: application/octet-stream; charset=utf-8
date: Tue, 11 May 2021 23:20:46 GMT
etag: W/"23335773-169918464-2021-05-11T22:58:16.861Z"
keep-alive: timeout=5
last-modified: Tue, 11 May 2021 22:58:16 GMT
server: ecstatic-3.3.2

However, it is working fine. I think there is an error in the code checking for partial file support? It would (correctly) report the same error when I used python http.server, and indeed it did not work with that server.

(PS: This is an awesome project <3)

phiresky commented 3 years ago

Yeah, originally that error message threw an error, but it turns out some servers actually do support byte serving, they just don't advertise it (like npm http-server) - and when doing CORS then in some cases you can't see the header but it still works anyways, and you can't always change the server side CORS policy to allow you to see the header.

So it doesn't really have a clean solution I think - I've tweaked the message a bit and made it a warning instead of an error to hopefully make it clearer.

wheybags commented 3 years ago

Ah, that seems a reasonable compromise. Thanks!