[ 
https://issues.apache.org/jira/browse/HTTPCLIENT-1456?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Oleg Kalnichevski updated HTTPCLIENT-1456:
------------------------------------------

    Affects Version/s:     (was: 4.3.1)
        Fix Version/s: 4.3.3
           Issue Type: Bug  (was: Improvement)

The Content-Length header generated by the protocol pipeline should actually be 
removed prior to re-trial of the request. This looks like a bug to me. I'll 
look into it.

Oleg

> ClientProtocolException occurs when retries after receiving 503
> ---------------------------------------------------------------
>
>                 Key: HTTPCLIENT-1456
>                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-1456
>             Project: HttpComponents HttpClient
>          Issue Type: Bug
>          Components: HttpClient
>    Affects Versions: 4.3.2
>            Reporter: Liu Kumai
>            Priority: Minor
>             Fix For: 4.3.3
>
>         Attachments: HTTPCLIENT-1456.patch
>
>
> When HttpClient retries a POST request after receiving 503 (service temporary 
> unavailable), ClientProtocolException occurs. On second request, 
> Content-Length header is already set and the RequestContent created by 
> HttpClientBuilder doesn't allow overriding it.
> There's a workaround:
> {code}
> HttpClientBuilder builder = HttpClientBuilder.create();
> builder.setServiceUnavailableRetryStrategy(new 
> DefaultServiceUnavailableRetryStrategy(2, 100));
> builder.addInterceptorFirst(new HttpRequestInterceptor() {
>     @Override
>     public void process(HttpRequest request, HttpContext context) throws 
> HttpException, IOException {
>       if (request.containsHeader(HTTP.CONTENT_LEN)) {
>         request.removeHeaders(HTTP.CONTENT_LEN);
>       }
>     }
> });
> {code}
> I think HttpClientBuilder should provide an option like this:
> {code}
> HttpClientBuilder.create()
>   .setServiceUnavailableRetryStrategy(new 
> DefaultServiceUnavailableRetryStrategy()
>   .enableOverrideContentLength()
>  ...
> {code}



--
This message was sent by Atlassian JIRA
(v6.1.5#6160)

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

Reply via email to