[ https://issues.apache.org/jira/browse/HTTPCLIENT-2265?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17704147#comment-17704147 ]
Oleg Kalnichevski commented on HTTPCLIENT-2265: ----------------------------------------------- [~patrickjamesbarry] I am not sure why you still need the whole entity when generally entity details should be enough. Anyway, you might want to use an execution interceptor instead of a request interceptor as shown here: https://github.com/apache/httpcomponents-client/blob/master/httpclient5/src/test/java/org/apache/hc/client5/http/examples/AsyncClientInterceptors.java Oleg > Need advice on accessing Entity > ------------------------------- > > Key: HTTPCLIENT-2265 > URL: https://issues.apache.org/jira/browse/HTTPCLIENT-2265 > Project: HttpComponents HttpClient > Issue Type: Task > Reporter: Patrick Barry > Priority: Trivial > > I am currently testing with a 'production configured client' and am trying to > see the entity of outbound request and inbound response. I created a > UnitTestExecutionContext to help me capture requests/responses and since > there can be multiple due to retries, I capture a list of them. All of this > is working well, and I have access to EntityDetails, Headers, URL, Response > codes, etc, however, I cannot seem to figure out how to capture the entities. > Can you point me to code or advice me on how I might accomplish this? I have > been hacking things together using ExecInterceptorLast, wrapping the > entityProducer and some other crazy things. Hoping someone can point me in > right direction. > > {code:java} > public class UnitTestExecutionContext extends ExecutionContext { > List<HttpCapture<HttpResponse>> httpResponses = new ArrayList<>(); > List<HttpCapture<HttpRequest>> httpRequests = new ArrayList<>(); > } {code} > snippet of how I am appending some interceptors onto to some previous > configurations used in production. > {code:java} > HttpAsyncClientBuilder builder = super.asyncClientBuilder(ioReactorConfig, > connectionManager, dynamicRequestInterceptor); > builder.addRequestInterceptorLast((httpRequest, entityDetails, httpContext) > -> ((UnitTestExecutionContext)httpContext).addHttpRequest(httpRequest, > entityDetails)); > builder.addResponseInterceptorFirst((httpResponse, entityDetails, > httpContext) -> > ((UnitTestExecutionContext)httpContext).addHttpResponse(httpResponse, > entityDetails)); {code} -- This message was sent by Atlassian Jira (v8.20.10#820010) --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@hc.apache.org For additional commands, e-mail: dev-h...@hc.apache.org