1

I'm writing a HTTP client, and wondering if HTTP responses are required to have any headers?

So is the following a valid HTTP response? (where \r\n == CRLF). How should a client handle it?

HTTP/1.1 200 OK\r\n \r\n 

The related questions Http response with no http header and What HTTP response headers are required are similar, but I think they are subtly-but-crucially different. They are both from the point of view of a server generating headers, rather than a parser parsing a response.

For example, a detailed answer to the current question could include how the client should interpret the above minimal response: whether it should accept the 200 response or abort, and what it should do with the underlying connection in terms of keeping it open or closing it.

4

1 Answer 1

1

The syntax of the message is defined in RFC 7231 (see https://greenbytes.de/tech/webdav/rfc7230.html#http.message), and that says that header fields are syntactically optional. So a message parser should accept that.

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.