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

Content-Length header missing on GET but present on HEAD request #163

Open
call-a3 opened this issue Feb 1, 2022 · 1 comment
Open

Content-Length header missing on GET but present on HEAD request #163

call-a3 opened this issue Feb 1, 2022 · 1 comment

Comments

@call-a3
Copy link

call-a3 commented Feb 1, 2022

When trying to request a file (both when using fetch from the browser or via httpie), the Content-Length header is present when performing a HEAD request, but absent when performing a GET request for the same file.

$ npx serve . & # running serve in the folder that contains a file named sizes.csv
$ http get http://localhost:3000/sizes.csv
HTTP/1.1 200 OK
Accept-Ranges: bytes
Connection: keep-alive
Content-Disposition: inline; filename="sizes.csv"
Content-Encoding: gzip
Content-Type: text/csv; charset=utf-8
Date: Tue, 01 Feb 2022 16:41:31 GMT
ETag: "fe6386cd1487ccd8226d4750f395b4bac29a9465"
Keep-Alive: timeout=5
Transfer-Encoding: chunked
Vary: Accept-Encoding

^C # aborted because I didn't want to download the actual file in this test
$ http head http://localhost:3000/sizes.csv
HTTP/1.1 200 OK
Accept-Ranges: bytes
Connection: keep-alive
Content-Disposition: inline; filename="sizes.csv"
Content-Length: 920509727
Content-Type: text/csv; charset=utf-8
Date: Tue, 01 Feb 2022 16:41:38 GMT
ETag: "fe6386cd1487ccd8226d4750f395b4bac29a9465"
Keep-Alive: timeout=5
Vary: Accept-Encoding

@warren-bank
Copy link

warren-bank commented Feb 9, 2022

get response Transfer-Encoding: chunked

Data is sent in a series of chunks. The Content-Length header is omitted in this case, and at the beginning of each chunk you need to add the length of the current chunk in hexadecimal format...

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

No branches or pull requests

2 participants