mw88
mw88

Reputation: 499

Spring integration http disable multipart in get requests

I have a problem with sending GET requests to my HTTP resource. I can't control the client side requests and Spring seems to think that they want to do multipart requests. But they don't do that, they are just sending me JSON in the payload.

It works fine in POST requests but in GET requests I receive an empty LinkedMultiValueMap. I have tried a few methods but I wasn't able to disable the multipart feature.

<int:channel id="myChannel" />
<int-http:inbound-gateway request-channel="myChannel"
                          supported-methods="GET,POST"
                          path="/testResource"
                          request-payload-type="java.util.Map">
</int-http:inbound-gateway>

<int:service-activator ref="TestEndPoint"
                       method="testMethod"
                       input-channel="myChannel" />

<bean id="TestEndPoint" class="com.example.TestEndPoint" />

This is my test method:

public Message<?> testMethod(Message<Map> message)
{
     Map payload = message.getPayload();

     // Do stuff with the payload, create a result...

     return MessageBuilder.withPayload(result)
            .setHeader(HttpHeaders.STATUS_CODE, HttpStatus.OK)
            .build();
}

How can I disable the multipart feature or is there a better way to handle this?

Note: I'm aware of this property but it does not fix the problem:

spring.servlet.multipart.enabled=false

Upvotes: 1

Views: 244

Answers (1)

user404
user404

Reputation: 2028

Quoting Ref :

A payload within a GET request message has no defined semantics;
sending a payload body on a GET request might cause some existing
implementations to reject the request.

So, you must send your payload in POST to be working perfectly.

Upvotes: 1

Related Questions