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

HEAD requests should never write a body #1112

Open
pankgeorg opened this issue Sep 20, 2023 · 0 comments · May be fixed by #1113
Open

HEAD requests should never write a body #1112

pankgeorg opened this issue Sep 20, 2023 · 0 comments · May be fixed by #1113

Comments

@pankgeorg
Copy link

according to this: https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/HEAD

Context:
I'm investigating why it's hard to invoke the connection reuse code.

I'm running a simple server:

using HTTP
HTTP.serve("0.0.0.0", 1234;verbose=3) do req
    return HTTP.Response(200, [], "ok")
end

and testing the connection keep-alive with curl, as follows:

curl -Ivvvvvvvvvvvvvvvv http://localhost:1234 http://localhost:1234 http://localhost:1234 (that should make three HTTP requests over the same connection). It crashes somewhere in the middle.

The reason is that cURL issues a HEAD first:

image

(which it can do)

It seems that clients aren't very happy to reusing connections that have been initiated with a HEAD request because a body is being sent nevertheless

* Received HTTP/0.9 when not allowed

*   Trying 127.0.0.1:1234...
* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 1234 (#0)
> HEAD / HTTP/1.1
> Host: localhost:1234
> User-Agent: curl/7.68.0
> Accept: */*
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
HTTP/1.1 200 OK

<
* Connection #0 to host localhost left intact
* Found bundle for host localhost: 0x55925266eeb0 [serially]
* Can not multiplex, even if we wanted to!
* Re-using existing connection! (#0) with host localhost
* Connected to localhost (127.0.0.1) port 1234 (#0)
> HEAD / HTTP/1.1
> Host: localhost:1234
> User-Agent: curl/7.68.0
> Accept: */*
>
* Received HTTP/0.9 when not allowed

* Closing connection 0
curl: (1) Received HTTP/0.9 when not allowed

* Hostname localhost was found in DNS cache
*   Trying 127.0.0.1:1234...
* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 1234 (#1)
> HEAD / HTTP/1.1
> Host: localhost:1234
> User-Agent: curl/7.68.0
> Accept: */*
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
HTTP/1.1 200 OK

<
* Connection #1 to host localhost left intact

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

Successfully merging a pull request may close this issue.

1 participant