Skip to content

Conversation

@vellotis
Copy link

@vellotis vellotis commented Mar 2, 2021

…est or response body.

By RFC7231, only some of the HTTP methods shall contain a request and response body. The mw.Codec method should not fail if the request or response doesn't require a body.

HTTP method Request
body
Response
body
GET Required
HEAD
POST Required Required
PUT Required
DELETE Optional Optional
CONNECT Required
OPTIONS Required
TRACE
PATCH Required Required

Request body

The request body should be required

  • IF
    HEADER Transfer-Encoding is defined and has other value than identity
  • OR
    HEADER Content-Length value is greater than 0

which means that the Content-Type header should be present for them in the request headers.

By RFC7231 the condition of HEADER(Content-Length) < 0 or not a number or missing should be considered invalid and the body should be ignored. Only DELETE method may have Transfer-Encoding and Content-Length headers missing in which case the request doesn't have a body.

Response body

If the response body is required it means that the Accept header should be present in the request headers.

…est or response body.

By RFC7231, only some of the HTTP methods shall contain request and response body. The `mw.Codec` method should not fail if the request or response doesn't require a body.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant