@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; }
@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; }
@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; }
/** * 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; } }
/** * 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; } }
@Override public String getResponseMessage() throws IOException { return getResponse().getResponse().message(); }
@Override public final int getResponseCode() throws IOException { return getResponse().getResponse().code(); }
@Override public final int getResponseCode() throws IOException { return getResponse().getResponse().code(); }
@Override public String getResponseMessage() throws IOException { return getResponse().getResponse().message(); }
@Override public String getResponseMessage() throws IOException { return getResponse().getResponse().message(); }
@Override public final InputStream getInputStream() throws IOException { if (!doInput) { throw new ProtocolException("This protocol does not support input"); } HttpEngine response = getResponse(); // if the requested file does not exist, throw an exception formerly the // Error page from the server was returned if the requested file was // text/html this has changed to return FileNotFoundException for all // file types if (getResponseCode() >= HTTP_BAD_REQUEST) { throw new FileNotFoundException(url.toString()); } return response.getResponse().body().byteStream(); }
@Override public final Map<String, List<String>> getHeaderFields() { try { return OkHeaders.toMultimap(getHeaders(), StatusLine.get(getResponse().getResponse()).toString()); } catch (IOException e) { return Collections.emptyMap(); } }
@Override public final Map<String, List<String>> getHeaderFields() { try { return OkHeaders.toMultimap(getHeaders(), StatusLine.get(getResponse().getResponse()).toString()); } catch (IOException e) { return Collections.emptyMap(); } }
@Override public final Map<String, List<String>> getHeaderFields() { try { return OkHeaders.toMultimap(getHeaders(), StatusLine.get(getResponse().getResponse()).toString()); } catch (IOException e) { return Collections.emptyMap(); } }
@Override public final InputStream getInputStream() throws IOException { if (!doInput) { throw new ProtocolException("This protocol does not support input"); } HttpEngine response = getResponse(); // if the requested file does not exist, throw an exception formerly the // Error page from the server was returned if the requested file was // text/html this has changed to return FileNotFoundException for all // file types // if (getResponseCode() >= HTTP_BAD_REQUEST) { // throw new FileNotFoundException(url.toString()); // } return response.getResponse().body().byteStream(); }
/** * Returns the value of the field corresponding to the {@code fieldName}, or * null if there is no such field. If the field has multiple values, the * last value is returned. */ @Override public final String getHeaderField(String fieldName) { try { return fieldName == null ? StatusLine.get(getResponse().getResponse()).toString() : getHeaders().get(fieldName); } catch (IOException e) { return null; } }
/** * Returns the value of the field corresponding to the {@code fieldName}, or * null if there is no such field. If the field has multiple values, the * last value is returned. */ @Override public final String getHeaderField(String fieldName) { try { return fieldName == null ? StatusLine.get(getResponse().getResponse()).toString() : getHeaders().get(fieldName); } catch (IOException e) { return null; } }
private Headers getHeaders() throws IOException { if (responseHeaders == null) { Response response = getResponse().getResponse(); Headers headers = response.headers(); responseHeaders = headers.newBuilder() .add(Platform.get().getPrefix() + "-Response-Source", responseSourceHeader(response)) .build(); } return responseHeaders; }
private Headers getHeaders() throws IOException { if (responseHeaders == null) { Response response = getResponse().getResponse(); Headers headers = response.headers(); responseHeaders = headers.newBuilder() .add(Platform.get().getPrefix() + "-Response-Source", responseSourceHeader(response)) .build(); } return responseHeaders; }
private Headers getHeaders() throws IOException { if (responseHeaders == null) { Response response = getResponse().getResponse(); Headers headers = response.headers(); responseHeaders = headers.newBuilder() .add(OkHeaders.SELECTED_PROTOCOL, response.protocol().toString()) .add(OkHeaders.RESPONSE_SOURCE, responseSourceHeader(response)) .build(); } return responseHeaders; }