Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fetch API does not seem to give access to response headers #7026

Open
sbc100 opened this issue Aug 21, 2018 · 5 comments

Comments

@sbc100
Copy link
Collaborator

@sbc100 sbc100 commented Aug 21, 2018

I'm I missing something? If not, could we add support for this?

@sbc100 sbc100 changed the title Fetch API doesn't not seem to give access to repsonse headers Fetch API does not seem to give access to repsonse headers Aug 21, 2018
@kripken kripken changed the title Fetch API does not seem to give access to repsonse headers Fetch API does not seem to give access to response headers Aug 22, 2018
@kripken

This comment has been minimized.

Copy link
Member

@kripken kripken commented Aug 22, 2018

cc @juj

@coopersimon

This comment has been minimized.

Copy link
Contributor

@coopersimon coopersimon commented Apr 23, 2019

@kripken any updates? I have also noticed this. I can look into adding support for it if nobody else is looking into it?

In addition, I could try and add a callback that is called when the headers are received, but before the data is? i.e. when the XHR's readyState changes to 2. This would be analogous to cURL's https://curl.haxx.se/libcurl/c/CURLOPT_HEADERFUNCTION.html

@coopersimon

This comment has been minimized.

Copy link
Contributor

@coopersimon coopersimon commented Apr 24, 2019

Made #8486 to implement what I mentioned above.

@Beuc

This comment has been minimized.

Copy link
Contributor

@Beuc Beuc commented Oct 23, 2019

Hi,
The initial implementation works reasonably well, however it crashes when used on a persisted request:

TypeError: Fetch.xhrs[(id - 1)] is undefined

because there is no more XHR object, and because the headers were not cached.
This does not crash when using EMSCRIPTEN_FETCH_PERSIST_FILE -- this crashes during later (silently cached) requests.

This needs to either cache headers, or return length=0/headers=NULL.

@Beuc

This comment has been minimized.

Copy link
Contributor

@Beuc Beuc commented Oct 23, 2019

Another point: the unpacked headers carry a leading space and a trailing newline which are not part of the header value:

'cache-control': ' no-store\r\n'
'content-length': ' 13\r\n'
'server': ' SimpleHTTP/0.6 Python/3.7.3\r\n'

(incidentally I'm writing Python bindings for this https://github.com/python-emscripten/python/blob/trunk/emscripten.pyx)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.