You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
HttpRequestSnippet incorrectly infers Content-Type for POST/PUT/PATCH requests without a body #1017
HttpRequestSnippet currently inserts a 'Content-Type: application/x-www-form-urlencoded' header in the following scenario:
The method is POST/PUT/PATCH
No Content-Type header is provided
No request body
No request parameters included in the URI
Example of the generated documentation:
POST /foo HTTP/1.1
Content-Type: application/x-www-form-urlencoded
Host: localhost
However, the actual request had no Content-Type header, and Spring MVC would also receive it without one.
Since HTTP does not define a default media type and Spring does not infer one, this results in documentation that doesn’t match the real request.
Expected behavior
When a request has:
no Content-Type header
no body
no multipart parts
REST Docs should not add a Content-Type header automatically.
Only Content-Type values explicitly present in the request should be documented.
Activity
fix: avoid inferring Content-Type without body
wilkinsona commentedon Apr 7, 2026
Closing in favor of #1018. Thanks for the PR, @banseok1216.