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

<6 bytes HTTP responses "vanish" #2420

Closed
bagder opened this Issue Mar 22, 2018 · 4 comments

Comments

Projects
None yet
2 participants
@bagder
Member

bagder commented Mar 22, 2018

I did this

$ nc -l -p 8080 -c "echo moom" &
[1] 28461
$ curl localhost:8080 -o dump
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
curl: (56) Recv failure: Connection reset by peer

The zeros in all columns is what's notable. The server sent 5 bytes. Adding -i doesn't help, the 5 bytes are not to be seen; they are not stored in the output file.

I expected the following

Not sure.

curl has support for "HTTP/0.9" which is header-less and is just a response-body until connection close. But since curl doesn't know what HTTP version that comes, it buffers the data to check the first header line. This small amount of data never gets checked since the code wants >5 bytes before it checks.

Since it never qualifies as a header, it should probably be considered a body and get delivered as such when it reaches the end of the transfer without confirming it to be a header.

curl/libcurl version

git master, but this is ancient bug. Presumably this is not an actual problem to many users.

operating system

doesn't matter

@bagder bagder added the HTTP label Mar 22, 2018

@danielgustafsson

This comment has been minimized.

Show comment
Hide comment
@danielgustafsson

danielgustafsson Apr 15, 2018

Member

Given how rare it will be in the wild compared to broken servers, is it reasonable to assume HTTP/0.9 unless explicitly specified? That being said, there is no --http0.9 command line switch (and it seems a bit excessive to add).

Member

danielgustafsson commented Apr 15, 2018

Given how rare it will be in the wild compared to broken servers, is it reasonable to assume HTTP/0.9 unless explicitly specified? That being said, there is no --http0.9 command line switch (and it seems a bit excessive to add).

@bagder

This comment has been minimized.

Show comment
Hide comment
@bagder

bagder Apr 19, 2018

Member

I would say that most users probably don't even think of HTTP/0.9 and will be surprised when curl would handle such responses.

While --http0.9 seems a bit weird to add at this point, I still think that's the best way forward for this...

Member

bagder commented Apr 19, 2018

I would say that most users probably don't even think of HTTP/0.9 and will be surprised when curl would handle such responses.

While --http0.9 seems a bit weird to add at this point, I still think that's the best way forward for this...

@danielgustafsson

This comment has been minimized.

Show comment
Hide comment
@danielgustafsson

danielgustafsson Apr 19, 2018

Member
Member

danielgustafsson commented Apr 19, 2018

@bagder

This comment has been minimized.

Show comment
Hide comment
@bagder

bagder Apr 19, 2018

Member

Please have a go at it! The only thing I've done on this is the recipe mentioned above that reproduces the problem...

Member

bagder commented Apr 19, 2018

Please have a go at it! The only thing I've done on this is the recipe mentioned above that reproduces the problem...

bagder added a commit that referenced this issue Aug 13, 2018

http: fix for tiny "HTTP/0.9" response
Deal with tiny "HTTP/0.9" (header-less) responses by checking the
status-line early, even before a full "HTTP/" is received to allow
detecting 0.9 properly.

Test 1266 and 1267 added to verify.

Fixes #2420

bagder added a commit that referenced this issue Aug 13, 2018

http: fix for tiny "HTTP/0.9" response
Deal with tiny "HTTP/0.9" (header-less) responses by checking the
status-line early, even before a full "HTTP/" is received to allow
detecting 0.9 properly.

Test 1266 and 1267 added to verify.

Fixes #2420

@bagder bagder closed this in 8440616 Aug 13, 2018

xquery added a commit to xquery/curl that referenced this issue Sep 3, 2018

http: fix for tiny "HTTP/0.9" response
Deal with tiny "HTTP/0.9" (header-less) responses by checking the
status-line early, even before a full "HTTP/" is received to allow
detecting 0.9 properly.

Test 1266 and 1267 added to verify.

Fixes #2420
Closes #2872

falconindy added a commit to falconindy/curl that referenced this issue Sep 10, 2018

http: fix for tiny "HTTP/0.9" response
Deal with tiny "HTTP/0.9" (header-less) responses by checking the
status-line early, even before a full "HTTP/" is received to allow
detecting 0.9 properly.

Test 1266 and 1267 added to verify.

Fixes #2420
Closes #2872
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment