Example usage for com.squareup.okhttp.internal.http HttpEngine getResponse

List of usage examples for com.squareup.okhttp.internal.http HttpEngine getResponse

Introduction

In this page you can find the example usage for com.squareup.okhttp.internal.http HttpEngine getResponse.

Prototype


public Response getResponse() 

Source Link

Document

Returns the engine's response.

Usage

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();
}