Navigation Menu

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

<6 bytes HTTP responses "vanish" #2420

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

<6 bytes HTTP responses "vanish" #2420

bagder opened this issue Mar 22, 2018 · 4 comments
Labels

Comments

@bagder
Copy link
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
Copy link
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).

@bagder
Copy link
Member Author

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
Copy link
Member

danielgustafsson commented Apr 19, 2018 via email

@bagder
Copy link
Member Author

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
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
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 as completed in 8440616 Aug 13, 2018
xquery pushed a commit to xquery/curl that referenced this issue Sep 3, 2018
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 curl#2420
Closes curl#2872
falconindy pushed a commit to falconindy/curl that referenced this issue Sep 10, 2018
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 curl#2420
Closes curl#2872
@lock lock bot locked as resolved and limited conversation to collaborators Nov 11, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Development

No branches or pull requests

2 participants