List of usage examples for com.squareup.okhttp.internal.http HttpEngine getResponse
public Response getResponse()
From source file:io.apiman.gateway.platforms.servlet.connectors.ok.HttpURLConnectionImpl.java
License:Apache License
/** * 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. */// ww w .j a v a 2 s. co m @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; } }
From source file:io.apiman.gateway.platforms.servlet.connectors.ok.HttpURLConnectionImpl.java
License:Apache License
@Override public final InputStream getInputStream() throws IOException { if (!doInput) { throw new ProtocolException("This protocol does not support input"); }// ww w.j a v a 2 s. c o m 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(); }