/** * Returns an input stream from the server in the case of error such as the * requested file (txt, htm, html) is not found on the remote server. */ @Override public final InputStream getErrorStream() { try { HttpEngine response = getResponse(); if (HttpEngine.hasBody(response.getResponse()) && response.getResponse().code() >= HTTP_BAD_REQUEST) { return response.getResponse().body().byteStream(); } return null; } catch (IOException e) { return null; } }
boolean releaseConnection = true; try { httpEngine.sendRequest(); Connection connection = httpEngine.getConnection(); if (connection != null) { route = connection.getRoute(); httpEngine.readResponse(); } catch (RouteException e) { HttpEngine retryEngine = httpEngine.recover(e); if (retryEngine != null) { releaseConnection = false; } catch (IOException e) { HttpEngine retryEngine = httpEngine.recover(e); if (retryEngine != null) { releaseConnection = false; StreamAllocation streamAllocation = httpEngine.close(); streamAllocation.release();
@Override public final OutputStream getOutputStream() throws IOException { connect(); BufferedSink sink = httpEngine.getBufferedRequestBody(); if (sink == null) { throw new ProtocolException("method does not support a request body: " + method); } else if (httpEngine.hasResponse()) { throw new ProtocolException("cannot write request body after response has been read"); } return sink.outputStream(); }
@Override protected Handshake handshake() { if (delegate.httpEngine == null) { throw new IllegalStateException("Connection has not yet been established"); } // If there's a response, get the handshake from there so that caching // works. Otherwise get the handshake from the connection because we might // have not connected yet. return delegate.httpEngine.hasResponse() ? delegate.httpEngine.getResponse().handshake() : delegate.handshake; }
httpEngine.sendRequest(); route = httpEngine.getRoute(); handshake = httpEngine.getConnection() != null ? httpEngine.getConnection().getHandshake() : null; if (readResponse) { httpEngine.readResponse(); } catch (RouteException e) { HttpEngine retryEngine = httpEngine.recover(e); if (retryEngine != null) { httpEngine = retryEngine; } catch (IOException e) { HttpEngine retryEngine = httpEngine.recover(e); if (retryEngine != null) { httpEngine = retryEngine;
initHttpEngine(); if (httpEngine.hasResponse()) { return httpEngine; Response response = httpEngine.getResponse(); Request followUp = httpEngine.followUpRequest(); httpEngine.releaseConnection(); return httpEngine; Sink requestBody = httpEngine.getRequestBody(); if (!followUp.method().equals(method)) { requestBody = null; if (!httpEngine.sameConnection(followUp.url())) { httpEngine.releaseConnection(); Connection connection = httpEngine.close(); httpEngine = newHttpEngine(followUp.method(), connection, (RetryableSink) requestBody, response);
initHttpEngine(); if (httpEngine.hasResponse()) { return httpEngine; Response response = httpEngine.getResponse(); Request followUp = httpEngine.followUpRequest(); httpEngine.releaseStreamAllocation(); return httpEngine; Sink requestBody = httpEngine.getRequestBody(); if (!followUp.method().equals(method)) { requestBody = null; StreamAllocation streamAllocation = httpEngine.close(); if (!httpEngine.sameConnection(followUp.httpUrl())) { streamAllocation.release(); streamAllocation = null;
@Override protected boolean hasResponseBody(Response response) { return HttpEngine.hasBody(response); }
@Override public final int getResponseCode() throws IOException { return getResponse().getResponse().code(); }
return new HttpEngine(engineClient, request, bufferRequestBody, true, false, streamAllocation, requestBody, priorResponse);
initHttpEngine(); if (httpEngine.hasResponse()) { return httpEngine; Response response = httpEngine.getResponse(); Request followUp = httpEngine.followUpRequest(); httpEngine.releaseConnection(); return httpEngine; Sink requestBody = httpEngine.getRequestBody(); if (!followUp.method().equals(method)) { requestBody = null; if (!httpEngine.sameConnection(followUp.url())) { httpEngine.releaseConnection(); Connection connection = httpEngine.close(); httpEngine = newHttpEngine(followUp.method(), connection, (RetryableSink) requestBody, response);
httpEngine.sendRequest(); route = httpEngine.getRoute(); handshake = httpEngine.getConnection() != null ? httpEngine.getConnection().getHandshake() : null; if (readResponse) { httpEngine.readResponse(); } catch (RouteException e) { HttpEngine retryEngine = httpEngine.recover(e); if (retryEngine != null) { httpEngine = retryEngine; } catch (IOException e) { HttpEngine retryEngine = httpEngine.recover(e); if (retryEngine != null) { httpEngine = retryEngine;
if (!logBody || !HttpEngine.hasBody(response)) { logger.log("<-- END HTTP"); } else if (bodyEncoded(response.headers())) {
@Override public String getResponseMessage() throws IOException { return getResponse().getResponse().message(); }
@Override protected Handshake handshake() { if (delegate.httpEngine == null) { throw new IllegalStateException("Connection has not yet been established"); } // If there's a response, get the handshake from there so that caching // works. Otherwise get the handshake from the connection because we might // have not connected yet. return delegate.httpEngine.hasResponse() ? delegate.httpEngine.getResponse().handshake() : delegate.handshake; }
return new HttpEngine(engineClient, request, bufferRequestBody, true, false, connection, null, requestBody, priorResponse);
/** * Returns an input stream from the server in the case of error such as the * requested file (txt, htm, html) is not found on the remote server. */ @Override public final InputStream getErrorStream() { try { HttpEngine response = getResponse(); if (HttpEngine.hasBody(response.getResponse()) && response.getResponse().code() >= HTTP_BAD_REQUEST) { return response.getResponse().body().byteStream(); } return null; } catch (IOException e) { return null; } }
if (!logBody || !HttpEngine.hasBody(response)) { log("<-- END HTTP"); } else if (!isResponseBodyPrintable(response)) {
@Override public final int getResponseCode() throws IOException { return getResponse().getResponse().code(); }
@Override public final OutputStream getOutputStream() throws IOException { connect(); BufferedSink sink = httpEngine.getBufferedRequestBody(); if (sink == null) { throw new ProtocolException("method does not support a request body: " + method); } else if (httpEngine.hasResponse()) { throw new ProtocolException("cannot write request body after response has been read"); } return sink.outputStream(); }