[cs631apue] do we accept empty lines before formal request line?

Jan Schaumann jschauma at stevens.edu
Sun Nov 24 16:20:33 EST 2013


Minhui Gu <mgu1 at stevens.edu> wrote:
> If we receive \r\n\r\nGET / HTTP/1.0\r\n ...,
> should we reply 400 or take it as a valid request?
> 
> I am curious about this since RFC says the request should start with the
> method, but it works in telnet.

It looks like many web servers allow the client to send empty lines
before issuing a request.  RFC2616 states:

"A request message from a client to a server includes, within the
   first line of that message, the method to be applied to the resource,
   the identifier of the resource, and the protocol version in use."

So you do not need to support a client sending empty lines before a
request line, but you may choose to do so to be compatible with other
servers.

(This would be an example of the application of Postel's Law: "Be
conservative in what you do, be liberal in what you accept from
others.")

-Jan


More information about the cs631apue mailing list