ClientResponse obj = new ClientResponse(); Class clazz = obj.getClass();
public ClientResponse handle(ClientRequest clientRequest) { final InProcRequest cRequest = new JerseyClientInprocRequest(clientRequest); InProcResponse cResponse = w.getResponses(cRequest); return new ClientResponse( cResponse.getStatus(), getInBoundHeaders(cResponse), new ByteArrayInputStream(cResponse.getContentBytes()), getMessageBodyWorkers()); }
public ClientResponse handle(ClientRequest clientRequest) { final InProcRequest cRequest = new JerseyClientInprocRequest(clientRequest); InProcResponse cResponse = w.getResponses(cRequest); ClientResponse clientResponse; try { clientResponse = new ClientResponse( cResponse.getStatus(), getInBoundHeaders(cResponse), new ByteArrayInputStream(getContent(cResponse)), getMessageBodyWorkers()); } catch (UnsupportedEncodingException e) { throw new ContainerException(e); } return clientResponse; }
public ClientResponse handle(final ClientRequest cr) throws ClientHandlerException { final HttpUriRequest request = getUriHttpRequest(cr); writeOutBoundHeaders(cr.getHeaders(), request); try { HttpResponse response; if(preemptiveBasicAuth) { AuthCache authCache = new BasicAuthCache(); BasicScheme basicScheme = new BasicScheme(); authCache.put(getHost(request), basicScheme); BasicHttpContext localContext = new BasicHttpContext(); localContext.setAttribute(ClientContext.AUTH_CACHE, authCache); response = getHttpClient().execute(getHost(request), request, localContext); } else { response = getHttpClient().execute(getHost(request), request); } ClientResponse r = new ClientResponse(response.getStatusLine().getStatusCode(), getInBoundHeaders(response), new HttpClientResponseInputStream(response), getMessageBodyWorkers()); if (!r.hasEntity()) { r.bufferEntity(); r.close(); } return r; } catch (Exception e) { throw new ClientHandlerException(e); } }
@Override public ClientResponse handle(final ClientRequest cr) throws ClientHandlerException { final HttpMethod method = getHttpMethod(cr); methodExecutor.executeMethod(method, cr); try { ClientResponse r = new ClientResponse(method.getStatusCode(), getInBoundHeaders(method), new HttpClientResponseInputStream(method), workers); if (!r.hasEntity()) { r.bufferEntity(); r.close(); } return r; } catch (Exception e) { method.releaseConnection(); throw new ClientHandlerException(e); } }
/** * Translate the {@link ClientRequest} into a AsyncHttpClient request, and execute it. * * @param cr the HTTP request. * @return the {@link ClientResponse} * @throws ClientHandlerException */ @Override public ClientResponse handle(final ClientRequest cr) throws ClientHandlerException { try { final RequestBuilder requestBuilder = getRequestBuilder(cr); handleCookie(requestBuilder); requestWriter.configureRequest(requestBuilder, cr, allowBody(cr.getMethod())); final Response response = client.executeRequest(requestBuilder.build()).get(); applyResponseCookies(response.getCookies()); ClientResponse r = new ClientResponse(response.getStatusCode(), getInBoundHeaders(response), response.getResponseBodyAsStream(), workers); if (!r.hasEntity()) { r.bufferEntity(); r.close(); } return r; } catch (Exception e) { throw new ClientHandlerException(e); } }
/** * Translate the {@link ClientRequest} into a AsyncHttpClient request, and execute it. * * @param cr the HTTP request. * @return the {@link ClientResponse} * @throws ClientHandlerException */ @Override public ClientResponse handle(final ClientRequest cr) throws ClientHandlerException { try { final RequestBuilder requestBuilder = getRequestBuilder(cr); handleCookie(requestBuilder); requestWriter.configureRequest(requestBuilder, cr, allowBody(cr.getMethod())); final Response response = client.executeRequest(requestBuilder.build()).get(); applyResponseCookies(response.getCookies()); ClientResponse r = new ClientResponse(response.getStatusCode(), getInBoundHeaders(response), response.getResponseBodyAsStream(), workers); if (!r.hasEntity()) { r.bufferEntity(); r.close(); } return r; } catch (Exception e) { throw new ClientHandlerException(e); } }