List of usage examples for org.apache.http.nio.protocol HttpAsyncResponseConsumer responseReceived
void responseReceived(HttpResponse response) throws IOException, HttpException;
From source file:org.apache.http.impl.nio.client.MainClientExec.java
@Override public void responseReceived(final HttpResponse response, final InternalState state, final AbstractClientExchangeHandler<?> handler) throws IOException, HttpException { if (this.log.isDebugEnabled()) { this.log.debug("[exchange: " + state.getId() + "] Response received " + response.getStatusLine()); }/*from w w w . j a va 2s . c om*/ final HttpClientContext context = state.getLocalContext(); context.setAttribute(HttpCoreContext.HTTP_RESPONSE, response); this.httpProcessor.process(response, context); handler.setCurrentResponse(response); if (!handler.isRouteEstablished()) { final int status = response.getStatusLine().getStatusCode(); if (status < 200) { throw new HttpException("Unexpected response to CONNECT request: " + response.getStatusLine()); } if (status == HttpStatus.SC_OK) { handler.onRouteTunnelToTarget(); handler.setCurrentRequest(null); } else { if (!handleConnectResponse(state, handler)) { state.setFinalResponse(response); } } } else { if (!handleResponse(state, handler)) { state.setFinalResponse(response); } } if (state.getFinalResponse() != null) { final HttpAsyncResponseConsumer<?> responseConsumer = state.getResponseConsumer(); responseConsumer.responseReceived(response); } }
From source file:org.apache.http.impl.nio.client.PipeliningClientExchangeHandlerImpl.java
@Override public void responseReceived(final HttpResponse response) throws IOException, HttpException { if (this.log.isDebugEnabled()) { this.log.debug("[exchange: " + getId() + "] Response received " + response.getStatusLine()); }//from ww w.jav a 2 s .co m Asserts.check(this.responseConsumerRef.get() == null, "Inconsistent state: response consumer is not null"); final HttpAsyncResponseConsumer<T> responseConsumer = this.responseConsumerQueue.poll(); Asserts.check(responseConsumer != null, "Inconsistent state: response consumer queue is empty"); this.responseConsumerRef.set(responseConsumer); final HttpRequest request = this.requestQueue.poll(); Asserts.check(request != null, "Inconsistent state: request queue is empty"); this.localContext.setAttribute(HttpCoreContext.HTTP_REQUEST, request); this.localContext.setAttribute(HttpCoreContext.HTTP_RESPONSE, response); this.httpProcessor.process(response, this.localContext); responseConsumer.responseReceived(response); setCurrentResponse(response); }