22

Solved: pasting the bytes here made me realise that I was missing empty lines between chunks...


Does an HTTP/1.1 request need to specify a Connection: keep-alive header, or is it always keep-alive by default?

This guide made me think it would; that, when my http server gets a 1.1 request, it is keep-alive unless explicitly receiving a Connection: close header.

I ask since my the different client behaviour of ab and httperf is driving me mad enough to wonder my sanity on this one...


Here's what httperf --hog --port 42042 --print-reply body sends:

GET / HTTP/1.1 User-Agent: httperf/0.9.0 Host: localhost 

And here's my server's response:

HTTP/1.1 200 OK Connection: keep-alive Transfer-Encoding: chunked Content-Length: 18 12 Hello World 1 0 

httpref promptly prints out the response, but then just sits there, neither side closing the connection and httpref not exiting.

Where's my bug?

2
  • 1
    Yes, keep-alive is the HTTP/1.1 default. Commented Oct 28, 2011 at 9:42
  • 2
    content length in chunked encoding doesn't make much sense Commented Nov 4, 2013 at 6:38

1 Answer 1

31

From RFC 2616, section 8.1.2:

A significant difference between HTTP/1.1 and earlier versions of HTTP is that persistent connections are the default behavior of any HTTP connection. That is, unless otherwise indicated, the client SHOULD assume that the server will maintain a persistent connection, even after error responses from the server.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.