Randymo created HTTPCLIENT-2105:
-----------------------------------

             Summary: HttpClient5 makes post call with no body after 307 
redirect
                 Key: HTTPCLIENT-2105
                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-2105
             Project: HttpComponents HttpClient
          Issue Type: Bug
          Components: HttpClient (async)
    Affects Versions: 5.0.1
            Reporter: Randymo


I have switched from the Apache HttpAsyncClient 4 (4.1.4) library to the 
httpClient 5 (5.0.1)

I have found that when I make a POST call with body and get back a 307, the 
subsequent call does NOT include the data body any more, but it does still 
contain the Content-Type and Content-Length so the server then hangs waiting to 
receive the rest of the request which never comes.

 
 I do not see anything like this while debugging in the HttpClient5 libs
{code:java}
FROM: org.apache.http.impl.client.DefaultRedirectStrategy

    public HttpUriRequest getRedirect(HttpRequest request, HttpResponse 
response, HttpContext context) throws ProtocolException {
        URI uri = this.getLocationURI(request, response, context);
        String method = request.getRequestLine().getMethod();
        if (method.equalsIgnoreCase("HEAD")) {
            return new HttpHead(uri);
        } else if (method.equalsIgnoreCase("GET")) {
            return new HttpGet(uri);
        } else {
            int status = response.getStatusLine().getStatusCode();
            return (HttpUriRequest)(status != 307 && status != 308 ? new 
HttpGet(uri) : RequestBuilder.copy(request).setUri(uri).build());
        }
    }{code}
Here is an example from my logs
{noformat}
>> POST /ws/v3/batch HTTP/1.1
>> User-Agent: Apache-HttpAsyncClient/5.0.1 (Java/11.0.7)
>> Content-Length: 1043
>> Content-Type: application/json; charset=UTF-8
>> Host: ORIGINAL_HOST:4443
>> Connection: keep-alive
2020-08-05T20:52:24,377Z DEBUG 
[httpclient-dispatch-1][HttpAsyncMainClientExec:97] - ex-00000001: produce 
request data
2020-08-05T20:52:24,378Z DEBUG 
[httpclient-dispatch-1][HttpAsyncMainClientExec:109] - ex-00000001: produce 
request data, len 1043 bytes
2020-08-05T20:52:24,379Z DEBUG 
[httpclient-dispatch-1][HttpAsyncMainClientExec:117] - ex-00000001: end of 
request data

<< HTTP/1.1 307 Temporary Redirect
<< Cache-Control: max-age=300
<< Location: https://NEW_HOST:4443/ws/v3/batch
<< X-Server-Response-Time: 40ms
<< X-Server-Chain: ORIGINAL_HOST
<< X-Server-Timestamp: Wed, 05 Aug 2020 20:52:24 GMT
<< Content-Length: 0

>> POST /ws/v3/batch HTTP/1.1
>> User-Agent: Apache-HttpAsyncClient/5.0.1 (Java/11.0.7)
>> Content-Length: 1043
>> Content-Type: application/json; charset=UTF-8
>> Host: NEW_HOST:4443
>> Connection: keep-alive
2020-08-05T20:52:24,722Z DEBUG 
[httpclient-dispatch-2][HttpAsyncMainClientExec:97] - ex-00000001: produce 
request data
2020-08-05T20:52:24,722Z DEBUG 
[httpclient-dispatch-2][HttpAsyncMainClientExec:117] - ex-00000001: end of 
request data
{noformat}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to