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.

Michal Charemza
  • 25,940
  • 14
  • 98
  • 165
  • check RFC2616 for further informations on this: https://tools.ietf.org/html/rfc2616 – Thomas Schwärzl Jan 06 '19 at 08:27
  • Possible duplicate of [Http response with no http header](https://stackoverflow.com/questions/13483781/http-response-with-no-http-header) – GSerg Jan 06 '19 at 08:43
  • Possible duplicate of [What HTTP response headers are required](https://stackoverflow.com/q/4726515/11683) – GSerg Jan 06 '19 at 08:44
  • Possible duplicate of [What HTTP response headers are required](https://stackoverflow.com/questions/4726515/what-http-response-headers-are-required) – MSalters Jan 06 '19 at 12:13

1 Answers1

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.

Julian Reschke
  • 40,156
  • 8
  • 95
  • 98