Skip to content

Exception in HttpRequestHandlingEndpointSupport for incoming DELETE request without body #8806

Closed
@gekoukoul

Description

@gekoukoul

In what version(s) of Spring Integration are you seeing this issue?

In 5.5.15

Describe the bug

When a DELETE HTTP request without body is incoming, the following exception occurs:

org.springframework.messaging.MessagingException: Could not convert request: no suitable HttpMessageConverter found for expected type [omitted.for.brevity] and content type [application/octet-stream]
	at org.springframework.integration.http.inbound.HttpRequestHandlingEndpointSupport.extractRequestBody(HttpRequestHandlingEndpointSupport.java:538)
	at org.springframework.integration.http.inbound.HttpRequestHandlingEndpointSupport.prepareRequestEntity(HttpRequestHandlingEndpointSupport.java:497)
	at org.springframework.integration.http.inbound.HttpRequestHandlingMessagingGateway.handleRequest(HttpRequestHandlingMessagingGateway.java:109)
	at org.springframework.web.servlet.mvc.HttpRequestHandlerAdapter.handle(HttpRequestHandlerAdapter.java:52)

Expected behaviour
DELETE request should not require a message converter if there is no request body present.

A bit more analysis
From the RFC perspective, which is a bit vague and does not dictate that a DELETE request must have a request body, there are no defined body semantics.
However, the following code in HttpRequestHandlingEndpointSupport require DELETE requests to have body, so it fails when it sees there's no content-type along with the corresponding request body for a supported message converter to handle:

protected RequestEntity<Object> prepareRequestEntity(ServletServerHttpRequest request) throws IOException {
		Object requestBody = null;
		if (isReadable(request.getMethod())) {
			requestBody = extractRequestBody(request);
		}

		return new RequestEntity<>(requestBody, request.getHeaders(), request.getMethod(), request.getURI());
	}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions