IllegalArgumentException with empty requesty body using OkHttpRequestFactory
Closed this issue · 2 comments
WonderCsabo commented
When sending a request with empty body, an IllegalArgumentException
is thrown if one uses the new OkHttpRequestFactory
. The stacktrace is the following:
java.lang.IllegalArgumentException: method POST must have a request body.
at com.squareup.okhttp.Request$Builder.method(Request.java:244)
at org.springframework.http.client.OkHttpClientHttpRequest.executeInternal(OkHttpClientHttpRequest.java:85)
at org.springframework.http.client.AbstractBufferingClientHttpRequest.executeInternal(AbstractBufferingClientHttpRequest.java:48)
at org.springframework.http.client.AbstractClientHttpRequest.execute(AbstractClientHttpRequest.java:84)
at org.springframework.http.client.InterceptingClientHttpRequest$RequestExecution.execute(InterceptingClientHttpRequest.java:91)
at my.super.secret.package.AuthorizationInterceptor.intercept(AuthorizationInterceptor.java:29)
at org.springframework.http.client.InterceptingClientHttpRequest$RequestExecution.execute(InterceptingClientHttpRequest.java:81)
at org.springframework.http.client.InterceptingClientHttpRequest.executeInternal(InterceptingClientHttpRequest.java:67)
at org.springframework.http.client.AbstractBufferingClientHttpRequest.executeInternal(AbstractBufferingClientHttpRequest.java:48)
at org.springframework.http.client.AbstractClientHttpRequest.execute(AbstractClientHttpRequest.java:84)
at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:536)
at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:499)
at org.springframework.web.client.RestTemplate.exchange(RestTemplate.java:447)
This is a regression introduced by the new implementation of OkHttpRequestFactory
added by the M3 release.
WonderCsabo commented
@royclarkson looking at OkHttp and Retrofit issues, and it seems this is an intentional requirement. However they working it around in a higher level, by creating an empty body instead of sending a request with absent body. Can't we do the same here?
WonderCsabo commented