Skip to content
This repository was archived by the owner on Apr 5, 2022. It is now read-only.
This repository was archived by the owner on Apr 5, 2022. It is now read-only.

IllegalArgumentException with empty requesty body using OkHttpRequestFactory #25

Closed

Description

@WonderCsabo

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.

Activity

  1. WonderCsabo commented on Sep 11, 2015

    @WonderCsabo
    ContributorAuthor

    @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?

  2. WonderCsabo commented on Oct 10, 2015

    @WonderCsabo
    ContributorAuthor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions