Example usage for com.squareup.okhttp.internal Platform get

List of usage examples for com.squareup.okhttp.internal Platform get

Introduction

In this page you can find the example usage for com.squareup.okhttp.internal Platform get.

Prototype

public static Platform get() 

Source Link

Usage

From source file:io.apiman.gateway.platforms.servlet.connectors.ok.HttpURLConnectionImpl.java

License:Apache License

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();
    }/* w w  w .  j  a va  2s . c o m*/
    return responseHeaders;
}

From source file:io.apiman.gateway.platforms.servlet.connectors.ok.HttpURLConnectionImpl.java

License:Apache License

@Override
public final void setRequestProperty(String field, String newValue) {
    if (connected) {
        throw new IllegalStateException("Cannot set request property after connection is made");
    }//from  w  w w  .  j  a v  a 2 s . com
    if (field == null) {
        throw new NullPointerException("field == null");
    }
    if (newValue == null) {
        // Silently ignore null header values for backwards compatibility with older
        // android versions as well as with other URLConnection implementations.
        //
        // Some implementations send a malformed HTTP header when faced with
        // such requests, we respect the spec and ignore the header.
        Platform.get().logW("Ignoring header " + field + " because its value was null.");
        return;
    }

    // TODO: Deprecate use of X-Android-Transports header?
    if ("X-Android-Transports".equals(field) || "X-Android-Protocols".equals(field)) {
        setProtocols(newValue, false /* append */);
    } else {
        requestHeaders.set(field, newValue);
    }
}

From source file:io.apiman.gateway.platforms.servlet.connectors.ok.HttpURLConnectionImpl.java

License:Apache License

@Override
public final void addRequestProperty(String field, String value) {
    if (connected) {
        throw new IllegalStateException("Cannot add request property after connection is made");
    }/*from   w ww .  j  av  a 2 s  . c om*/
    if (field == null) {
        throw new NullPointerException("field == null");
    }
    if (value == null) {
        // Silently ignore null header values for backwards compatibility with older
        // android versions as well as with other URLConnection implementations.
        //
        // Some implementations send a malformed HTTP header when faced with
        // such requests, we respect the spec and ignore the header.
        Platform.get().logW("Ignoring header " + field + " because its value was null.");
        return;
    }

    // TODO: Deprecate use of X-Android-Transports header?
    if ("X-Android-Transports".equals(field) || "X-Android-Protocols".equals(field)) {
        setProtocols(value, true /* append */);
    } else {
        requestHeaders.add(field, value);
    }
}