npcode
npcode

Reputation: 1400

The maximum length of HTTP Start-Line

Does HTTP limit the length of Start-Line(Request-Line or Status-Line)?

If it does, Which status-code HTTP Server should response when received a HTTP request whose Request-Line is longer than the maximum length?

Upvotes: 2

Views: 1512

Answers (1)

Don Roby
Don Roby

Reputation: 41137

Quoting from THE HTTP 1.1 RFC(2616),

The Request-Line begins with a method token, followed by the Request-URI and the protocol version, and ending with CRLF. The elements are separated by SP characters. No CR or LF is allowed except in the final CRLF sequence.

   Request-Line   = Method SP Request-URI SP HTTP-Version CRLF

This does not specify a limit on the length.

The Request-URI can itself be long, and the rfc also says about that:

The HTTP protocol does not place any a priori limit on the length of a URI. Servers MUST be able to handle the URI of any resource they serve, and SHOULD be able to handle URIs of unbounded length if they provide GET-based forms that could generate such URIs. A server SHOULD return 414 (Request-URI Too Long) status if a URI is longer than the server can handle (see section 10.4.15).

So a "too long" status exists for Request-URI, but it means "too long for this server to handle" and not "longer than the spec allows."

Upvotes: 3

Related Questions