Skip to content

GET request with request body results in a 400/bad request #33

Description

@rubenmoor

A GET request with request body results in a 400/bad request, while

  • HTTP in principle allows request bodies for GET requests
  • ... but according to the lastest HTTP standard, "A payload within a GET request message has no defined semantics"
  • the servant API is entirely permissive without warning regarding request bodies for GET requests

There are good arguments for prohibiting request bodies in GET bodies, as this would conform to the HTTP standard. The only problem: servant API does allow them and the current situation breaks the compile-time validation of the API.

Allowing request bodies in GET bodies doesn't strictly violate HTTP standards, by the way. One could consider it an abuse of the protocol though.

So either of these would be preferable to the current situation:

  • allowing request bodies in GET requests and restoring compile-time safety of the API
  • producing a meaningful error (preferably at compile time) whenever someone tries to use request bodies in GET requests, e.g. by adapting the HasServer instance such that the ReqBody is ignored and a handler that expects the payload as argument doesn't typecheck

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions