@Override public String getResponseMessage() throws IOException { return getResponse(true).message(); }
@Override public int getResponseCode() throws IOException { return getResponse(true).code(); }
@Override public InputStream getInputStream() throws IOException { if (!doInput) { throw new ProtocolException("This protocol does not support input"); } Response response = getResponse(false); if (response.code() >= HTTP_BAD_REQUEST) { throw new FileNotFoundException(url.toString()); } return response.body().byteStream(); }
/** * 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 InputStream getErrorStream() { try { Response response = getResponse(true); if (HttpHeaders.hasBody(response) && response.code() >= HTTP_BAD_REQUEST) { return response.body().byteStream(); } return null; } catch (IOException e) { return null; } }
@Override public Map<String, List<String>> getHeaderFields() { try { return JavaNetHeaders.toMultimap(getHeaders(), StatusLine.get(getResponse(true)).toString()); } catch (IOException e) { return Collections.emptyMap(); } }
/** * 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 String getHeaderField(String fieldName) { try { return fieldName == null ? StatusLine.get(getResponse(true)).toString() : getHeaders().get(fieldName); } catch (IOException e) { return null; } }
private Headers getHeaders() throws IOException { if (responseHeaders == null) { Response response = getResponse(true); Headers headers = response.headers(); responseHeaders = headers.newBuilder() .add(SELECTED_PROTOCOL, response.protocol().toString()) .add(RESPONSE_SOURCE, responseSourceHeader(response)) .build(); } return responseHeaders; }
@Override public int getResponseCode() throws IOException { return getResponse(true).code(); }
@Override public String getResponseMessage() throws IOException { return getResponse(true).message(); }
@Override public InputStream getInputStream() throws IOException { if (!doInput) { throw new ProtocolException("This protocol does not support input"); } Response response = getResponse(false); if (response.code() >= HTTP_BAD_REQUEST) { throw new FileNotFoundException(url.toString()); } return response.body().byteStream(); }
@Override public InputStream getInputStream() throws IOException { if (!doInput) { throw new ProtocolException("This protocol does not support input"); } Response response = getResponse(false); if (response.code() >= HTTP_BAD_REQUEST) { throw new FileNotFoundException(url.toString()); } return response.body().byteStream(); }
@Override public InputStream getInputStream() throws IOException { if (!doInput) { throw new ProtocolException("This protocol does not support input"); } Response response = getResponse(false); if (response.code() >= HTTP_BAD_REQUEST) { throw new FileNotFoundException(url.toString()); } return response.body().byteStream(); }
@Override public Map<String, List<String>> getHeaderFields() { try { return JavaNetHeaders.toMultimap(getHeaders(), StatusLine.get(getResponse(true)).toString()); } catch (IOException e) { return Collections.emptyMap(); } }
@Override public Map<String, List<String>> getHeaderFields() { try { return JavaNetHeaders.toMultimap(getHeaders(), StatusLine.get(getResponse(true)).toString()); } catch (IOException e) { return Collections.emptyMap(); } }
@Override public Map<String, List<String>> getHeaderFields() { try { return JavaNetHeaders.toMultimap(getHeaders(), StatusLine.get(getResponse(true)).toString()); } catch (IOException e) { return Collections.emptyMap(); } }
/** * 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 String getHeaderField(String fieldName) { try { return fieldName == null ? StatusLine.get(getResponse(true)).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 String getHeaderField(String fieldName) { try { return fieldName == null ? StatusLine.get(getResponse(true)).toString() : getHeaders().get(fieldName); } catch (IOException e) { return null; } }
private Headers getHeaders() throws IOException { if (responseHeaders == null) { Response response = getResponse(true); Headers headers = response.headers(); responseHeaders = headers.newBuilder() .add(SELECTED_PROTOCOL, response.protocol().toString()) .add(RESPONSE_SOURCE, responseSourceHeader(response)) .build(); } return responseHeaders; }
private Headers getHeaders() throws IOException { if (responseHeaders == null) { Response response = getResponse(true); Headers headers = response.headers(); responseHeaders = headers.newBuilder() .add(SELECTED_PROTOCOL, response.protocol().toString()) .add(RESPONSE_SOURCE, responseSourceHeader(response)) .build(); } return responseHeaders; }
private Headers getHeaders() throws IOException { if (responseHeaders == null) { Response response = getResponse(true); Headers headers = response.headers(); responseHeaders = headers.newBuilder() .add(SELECTED_PROTOCOL, response.protocol().toString()) .add(RESPONSE_SOURCE, responseSourceHeader(response)) .build(); } return responseHeaders; }