Search code examples
httpquery-stringstandardshttp-method

Is sending query string while using any HTTP method compliant with HTTP protocol?


Are all these combinations compliant with HTTP standard?

GET /entities/?param=value HTTP/1.1
POST /entities/?param=value HTTP/1.1
PUT /entities/?param=value HTTP/1.1
DELETE /entities/?param=value HTTP/1.1
HEAD /entities/?param=value HTTP/1.1
PATCH /entities/?param=value HTTP/1.1

Solution

  • According to the specification (as I read it), they are allowed.

    This is how the Request-Line is constructed (like the ones in your example):

    5.1 Request-Line

    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
    

    And then about Request-URI:

    The Request-URI is a Uniform Resource Identifier (section 3.2) and identifies the resource upon which to apply the request.

    As I see it, the specification makes no restriction on what kind of URIs can be used, and whether they are limited by the use of certain Methods.