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:
(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
```
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:
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:
(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