Skip to content

A request with an unsupported media type should return 415 #88

@dariok

Description

@dariok

Currently, on POST at least, if a "Content-Type" header is sent with a type that is not declared in the spec, a 400 Bad Request is returned (from: body.xqm:130)

This should instead be a 415 Unsupported Media Type, ideally with an Accept: header containing a white space separated list of the media types defined in the spec for this method and path.

--

Request:

POST http://localhost:8080/exist/apps/project/endpoint
Content-Type: application/json

{ "test": "test" }

Current reply:

HTTP/1.1 400 Bad Request
Connection: close
Date: Sat, 25 Oct 2025 10:17:02 GMT
X-XQuery-Cached: true
Content-Type: application/json
Server: Jetty(9.4.57.v20241219)

{
   …,
  "module": "/db/system/repo/roaster-1.11.0/content/body.xqm",
  "line": 130,
  "description": "Body with media-type 'application/json' is not allowed"
}

improved reply:

HTTP/1.1 415 Unsuported Media Type
…
Accept: application/xml text/plain

[perhaps error JSON]

Cf. https://httpwg.org/specs/rfc9110.html#status.415 and https://httpwg.org/specs/rfc9110.html#field.accept


Edit: affected version: Roaster 1.11.0


Edit:

  • Status 400 could be considered a better fit if a Content-Type is absent from a PUT or POST.
  • if the encoding is wrong, the Accept-Encoding header should be sent indicating the supported encodings.

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