John Enters created HTTPCLIENT-2084:
---------------------------------------

             Summary: HttpClientBuilder placing last HttpRequestInterceptor 
first
                 Key: HTTPCLIENT-2084
                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-2084
             Project: HttpComponents HttpClient
          Issue Type: Bug
          Components: HttpClient (classic)
    Affects Versions: 5.0
            Reporter: John Enters
             Fix For: 5.0.2


With the following:
{code:java}
CloseableHttpClient client = HttpClients.custom()
    .addRequestInterceptorFirst((request, entity, context) -> {
        System.out.println("This should be first");
    })
    .addRequestInterceptorLast((request, entity, context) -> {
        System.out.println("This should be last");
    })
    .build();

client.execute(new HttpGet("http://www.example.com";));
{code}
Result:
{code:java}
This should be last
This should be first
{code}
In org.apache.hc.client5.http.impl.classic.HttpClientBuilder

lines 830-832 adds the interceptor to the start of the list instead of the end.
{code:java}
if (entry.postion == RequestInterceptorEntry.Postion.LAST) {
    b.addFirst(entry.interceptor);
}
{code}
This should probably be the following:
{code:java}
if (entry.postion == RequestInterceptorEntry.Postion.LAST) {
    b.addLast(entry.interceptor); 
}
{code}
 

 

 



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