Skip to content

HttpPutFormContentFilter and ServletServerHttpRequest.getBody() don't play nicely together #6519

@tapina

Description

@tapina

HttpPutFormContentFilter makes PUT requests behave like POST requests with respect to parameters, and is enabled by default (#3643). This causes the body to be read in the filter.

ServletServerHttpRequest.getBody() treats POST requests specially and reconstructs a body from the parameters. But not for PUT (https://jira.spring.io/browse/SPR-8688).

If you map a form encoded PUT to a controller method (such as this one in Activiti) with @RequestBody, the body is null because the input stream has been read already and the PUTted parameters are not used to reconstruct a new one. This makes the controller useless in a Spring Boot 1.3+ environment.

org.activiti.rest.editor.model.ModelSaveRestResource:

    @RequestMapping(
        value = {"/model/{modelId}/save"},
        method = {RequestMethod.PUT}
    )
    @ResponseStatus(HttpStatus.OK)
    public void saveModel(@PathVariable String modelId, @RequestBody MultiValueMap<String, String> values) {

Is there a way of disabling HttpPutFormContentFilter, or causing the request body to still be available even if it's there?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions