OkHttpClientHttpRequestFactory should allow POST requests without body [SPR-15015] #19582
Comments
Juergen Hoeller commented Since all other |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Mark Paluch opened SPR-15015 and commented
OkHttp 2 and 3 require a request body for certain HTTP methods (
PUT
,POST
,PATCH
, …).OkHttpClientHttpRequestFactory
andOkHttp3ClientHttpRequestFactory
passes anull
argument as body if the request entity isnull
or the content is empty. The empty-body check prevents a workaround by passing in an emptybyte[]
.Exception:
Test code:
Proposed fix:
The proposed fix (see OkHttp #2651) coerces an absent body into an empty body.
OkHttp provides internal APIs to determine whether a request body is required. The fix would use
HttpMethod.requiresRequestBody(…)
to determine whether to create an empty body if the request entity isnull
or thecontent
is empty.Affects: 4.2.4, 4.3 GA
The text was updated successfully, but these errors were encountered: