com.squareup.okhttp.internal.Platform Java Examples
The following examples show how to use
com.squareup.okhttp.internal.Platform.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: HttpEngine.java From bluemix-parking-meter with MIT License | 6 votes |
/** * @param requestHeaders the client's supplied request headers. This class * creates a private copy that it can mutate. * @param connection the connection used for an intermediate response * immediately prior to this request/response pair, such as a same-host * redirect. This engine assumes ownership of the connection and must * release it when it is unneeded. */ public HttpEngine(OkHttpClient client, Policy policy, String method, RawHeaders requestHeaders, Connection connection, RetryableOutputStream requestBodyOut) throws IOException { this.client = client; this.policy = policy; this.method = method; this.connection = connection; this.requestBodyOut = requestBodyOut; try { uri = Platform.get().toUriLenient(policy.getURL()); } catch (URISyntaxException e) { throw new IOException(e.getMessage()); } this.requestHeaders = new RequestHeaders(uri, new RawHeaders(requestHeaders)); }
Example #2
Source File: HttpURLConnectionImpl.java From L.TileLayer.Cordova with MIT License | 6 votes |
@Override public final void setRequestProperty(String field, String newValue) { if (connected) { throw new IllegalStateException("Cannot set request property after connection is made"); } 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; } if ("X-Android-Transports".equals(field)) { setTransports(newValue, false /* append */); } else { rawRequestHeaders.set(field, newValue); } }
Example #3
Source File: Connection.java From wildfly-samples with MIT License | 6 votes |
public void connect(int connectTimeout, int readTimeout, TunnelRequest tunnelRequest) throws IOException { if (connected) throw new IllegalStateException("already connected"); socket = (route.proxy.type() != Proxy.Type.HTTP) ? new Socket(route.proxy) : new Socket(); Platform.get().connectSocket(socket, route.inetSocketAddress, connectTimeout); socket.setSoTimeout(readTimeout); in = socket.getInputStream(); out = socket.getOutputStream(); if (route.address.sslSocketFactory != null) { upgradeToTls(tunnelRequest); } else { streamWrapper(); } connected = true; }
Example #4
Source File: HttpEngine.java From IoTgo_Android_App with MIT License | 6 votes |
/** * @param requestHeaders the client's supplied request headers. This class * creates a private copy that it can mutate. * @param connection the connection used for an intermediate response * immediately prior to this request/response pair, such as a same-host * redirect. This engine assumes ownership of the connection and must * release it when it is unneeded. */ public HttpEngine(OkHttpClient client, Policy policy, String method, RawHeaders requestHeaders, Connection connection, RetryableOutputStream requestBodyOut) throws IOException { this.client = client; this.policy = policy; this.method = method; this.connection = connection; this.requestBodyOut = requestBodyOut; try { uri = Platform.get().toUriLenient(policy.getURL()); } catch (URISyntaxException e) { throw new IOException(e.getMessage()); } this.requestHeaders = new RequestHeaders(uri, new RawHeaders(requestHeaders)); }
Example #5
Source File: HttpURLConnectionImpl.java From IoTgo_Android_App with MIT License | 6 votes |
@Override public final void addRequestProperty(String field, String value) { if (connected) { throw new IllegalStateException("Cannot add request property after connection is made"); } 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; } if ("X-Android-Transports".equals(field)) { setTransports(value, true /* append */); } else { rawRequestHeaders.add(field, value); } }
Example #6
Source File: HttpURLConnectionImpl.java From IoTgo_Android_App with MIT License | 6 votes |
@Override public final void setRequestProperty(String field, String newValue) { if (connected) { throw new IllegalStateException("Cannot set request property after connection is made"); } 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; } if ("X-Android-Transports".equals(field)) { setTransports(newValue, false /* append */); } else { rawRequestHeaders.set(field, newValue); } }
Example #7
Source File: HttpURLConnectionImpl.java From L.TileLayer.Cordova with MIT License | 6 votes |
@Override public final void addRequestProperty(String field, String value) { if (connected) { throw new IllegalStateException("Cannot add request property after connection is made"); } 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; } if ("X-Android-Transports".equals(field)) { setTransports(value, true /* append */); } else { rawRequestHeaders.add(field, value); } }
Example #8
Source File: HttpEngine.java From wildfly-samples with MIT License | 6 votes |
/** * @param requestHeaders the client's supplied request headers. This class * creates a private copy that it can mutate. * @param connection the connection used for an intermediate response * immediately prior to this request/response pair, such as a same-host * redirect. This engine assumes ownership of the connection and must * release it when it is unneeded. */ public HttpEngine(OkHttpClient client, Policy policy, String method, RawHeaders requestHeaders, Connection connection, RetryableOutputStream requestBodyOut) throws IOException { this.client = client; this.policy = policy; this.method = method; this.connection = connection; this.requestBodyOut = requestBodyOut; try { uri = Platform.get().toUriLenient(policy.getURL()); } catch (URISyntaxException e) { throw new IOException(e.getMessage()); } this.requestHeaders = new RequestHeaders(uri, new RawHeaders(requestHeaders)); }
Example #9
Source File: Connection.java From IoTgo_Android_App with MIT License | 6 votes |
public void connect(int connectTimeout, int readTimeout, TunnelRequest tunnelRequest) throws IOException { if (connected) throw new IllegalStateException("already connected"); socket = (route.proxy.type() != Proxy.Type.HTTP) ? new Socket(route.proxy) : new Socket(); Platform.get().connectSocket(socket, route.inetSocketAddress, connectTimeout); socket.setSoTimeout(readTimeout); in = socket.getInputStream(); out = socket.getOutputStream(); if (route.address.sslSocketFactory != null) { upgradeToTls(tunnelRequest); } else { streamWrapper(); } connected = true; }
Example #10
Source File: Connection.java From CordovaYoutubeVideoPlayer with MIT License | 6 votes |
public void connect(int connectTimeout, int readTimeout, TunnelRequest tunnelRequest) throws IOException { if (connected) throw new IllegalStateException("already connected"); socket = (route.proxy.type() != Proxy.Type.HTTP) ? new Socket(route.proxy) : new Socket(); Platform.get().connectSocket(socket, route.inetSocketAddress, connectTimeout); socket.setSoTimeout(readTimeout); in = socket.getInputStream(); out = socket.getOutputStream(); if (route.address.sslSocketFactory != null) { upgradeToTls(tunnelRequest); } else { streamWrapper(); } connected = true; }
Example #11
Source File: HttpEngine.java From android-discourse with Apache License 2.0 | 6 votes |
/** * @param requestHeaders the client's supplied request headers. This class * creates a private copy that it can mutate. * @param connection the connection used for an intermediate response * immediately prior to this request/response pair, such as a same-host * redirect. This engine assumes ownership of the connection and must * release it when it is unneeded. */ public HttpEngine(OkHttpClient client, Policy policy, String method, RawHeaders requestHeaders, Connection connection, RetryableOutputStream requestBodyOut) throws IOException { this.client = client; this.policy = policy; this.method = method; this.connection = connection; this.requestBodyOut = requestBodyOut; try { uri = Platform.get().toUriLenient(policy.getURL()); } catch (URISyntaxException e) { throw new IOException(e.getMessage()); } this.requestHeaders = new RequestHeaders(uri, new RawHeaders(requestHeaders)); }
Example #12
Source File: HttpURLConnectionImpl.java From crosswalk-cordova-android with Apache License 2.0 | 6 votes |
@Override public final void addRequestProperty(String field, String value) { if (connected) { throw new IllegalStateException("Cannot add request property after connection is made"); } 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; } if ("X-Android-Transports".equals(field)) { setTransports(value, true /* append */); } else { rawRequestHeaders.add(field, value); } }
Example #13
Source File: HttpURLConnectionImpl.java From wildfly-samples with MIT License | 6 votes |
@Override public final void addRequestProperty(String field, String value) { if (connected) { throw new IllegalStateException("Cannot add request property after connection is made"); } 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; } if ("X-Android-Transports".equals(field)) { setTransports(value, true /* append */); } else { rawRequestHeaders.add(field, value); } }
Example #14
Source File: Connection.java From crosswalk-cordova-android with Apache License 2.0 | 6 votes |
public void connect(int connectTimeout, int readTimeout, TunnelRequest tunnelRequest) throws IOException { if (connected) throw new IllegalStateException("already connected"); socket = (route.proxy.type() != Proxy.Type.HTTP) ? new Socket(route.proxy) : new Socket(); Platform.get().connectSocket(socket, route.inetSocketAddress, connectTimeout); socket.setSoTimeout(readTimeout); in = socket.getInputStream(); out = socket.getOutputStream(); if (route.address.sslSocketFactory != null) { upgradeToTls(tunnelRequest); } else { streamWrapper(); } connected = true; }
Example #15
Source File: Connection.java From phonegapbootcampsite with MIT License | 6 votes |
public void connect(int connectTimeout, int readTimeout, TunnelRequest tunnelRequest) throws IOException { if (connected) throw new IllegalStateException("already connected"); socket = (route.proxy.type() != Proxy.Type.HTTP) ? new Socket(route.proxy) : new Socket(); Platform.get().connectSocket(socket, route.inetSocketAddress, connectTimeout); socket.setSoTimeout(readTimeout); in = socket.getInputStream(); out = socket.getOutputStream(); if (route.address.sslSocketFactory != null) { upgradeToTls(tunnelRequest); } else { streamWrapper(); } connected = true; }
Example #16
Source File: Connection.java From bluemix-parking-meter with MIT License | 6 votes |
public void connect(int connectTimeout, int readTimeout, TunnelRequest tunnelRequest) throws IOException { if (connected) throw new IllegalStateException("already connected"); socket = (route.proxy.type() != Proxy.Type.HTTP) ? new Socket(route.proxy) : new Socket(); Platform.get().connectSocket(socket, route.inetSocketAddress, connectTimeout); socket.setSoTimeout(readTimeout); in = socket.getInputStream(); out = socket.getOutputStream(); if (route.address.sslSocketFactory != null) { upgradeToTls(tunnelRequest); } else { streamWrapper(); } connected = true; }
Example #17
Source File: Connection.java From reader with MIT License | 6 votes |
public void connect(int connectTimeout, int readTimeout, TunnelRequest tunnelRequest) throws IOException { if (connected) throw new IllegalStateException("already connected"); socket = (route.proxy.type() != Proxy.Type.HTTP) ? new Socket(route.proxy) : new Socket(); Platform.get().connectSocket(socket, route.inetSocketAddress, connectTimeout); socket.setSoTimeout(readTimeout); in = socket.getInputStream(); out = socket.getOutputStream(); if (route.address.sslSocketFactory != null) { upgradeToTls(tunnelRequest); } else { streamWrapper(); } connected = true; }
Example #18
Source File: HttpEngine.java From cordova-android-chromeview with Apache License 2.0 | 6 votes |
/** * @param requestHeaders the client's supplied request headers. This class * creates a private copy that it can mutate. * @param connection the connection used for an intermediate response * immediately prior to this request/response pair, such as a same-host * redirect. This engine assumes ownership of the connection and must * release it when it is unneeded. */ public HttpEngine(HttpURLConnectionImpl policy, String method, RawHeaders requestHeaders, Connection connection, RetryableOutputStream requestBodyOut) throws IOException { this.policy = policy; this.method = method; this.connection = connection; this.requestBodyOut = requestBodyOut; try { uri = Platform.get().toUriLenient(policy.getURL()); } catch (URISyntaxException e) { throw new IOException(e.getMessage()); } this.requestHeaders = new RequestHeaders(uri, new RawHeaders(requestHeaders)); }
Example #19
Source File: HttpEngine.java From cordova-amazon-fireos with Apache License 2.0 | 6 votes |
/** * @param requestHeaders the client's supplied request headers. This class * creates a private copy that it can mutate. * @param connection the connection used for an intermediate response * immediately prior to this request/response pair, such as a same-host * redirect. This engine assumes ownership of the connection and must * release it when it is unneeded. */ public HttpEngine(OkHttpClient client, Policy policy, String method, RawHeaders requestHeaders, Connection connection, RetryableOutputStream requestBodyOut) throws IOException { this.client = client; this.policy = policy; this.method = method; this.connection = connection; this.requestBodyOut = requestBodyOut; try { uri = Platform.get().toUriLenient(policy.getURL()); } catch (URISyntaxException e) { throw new IOException(e.getMessage()); } this.requestHeaders = new RequestHeaders(uri, new RawHeaders(requestHeaders)); }
Example #20
Source File: HttpURLConnectionImpl.java From cordova-amazon-fireos with Apache License 2.0 | 6 votes |
@Override public final void addRequestProperty(String field, String value) { if (connected) { throw new IllegalStateException("Cannot add request property after connection is made"); } 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; } if ("X-Android-Transports".equals(field)) { setTransports(value, true /* append */); } else { rawRequestHeaders.add(field, value); } }
Example #21
Source File: HttpURLConnectionImpl.java From reader with MIT License | 6 votes |
@Override public final void setRequestProperty(String field, String newValue) { if (connected) { throw new IllegalStateException("Cannot set request property after connection is made"); } 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; } if ("X-Android-Transports".equals(field)) { setTransports(newValue, false /* append */); } else { rawRequestHeaders.set(field, newValue); } }
Example #22
Source File: HttpURLConnectionImpl.java From reader with MIT License | 6 votes |
@Override public final void addRequestProperty(String field, String value) { if (connected) { throw new IllegalStateException("Cannot add request property after connection is made"); } 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; } if ("X-Android-Transports".equals(field)) { setTransports(value, true /* append */); } else { rawRequestHeaders.add(field, value); } }
Example #23
Source File: HttpEngine.java From reader with MIT License | 6 votes |
/** * @param requestHeaders the client's supplied request headers. This class * creates a private copy that it can mutate. * @param connection the connection used for an intermediate response * immediately prior to this request/response pair, such as a same-host * redirect. This engine assumes ownership of the connection and must * release it when it is unneeded. */ public HttpEngine(OkHttpClient client, Policy policy, String method, RawHeaders requestHeaders, Connection connection, RetryableOutputStream requestBodyOut) throws IOException { this.client = client; this.policy = policy; this.method = method; this.connection = connection; this.requestBodyOut = requestBodyOut; try { uri = Platform.get().toUriLenient(policy.getURL()); } catch (URISyntaxException e) { throw new IOException(e.getMessage()); } this.requestHeaders = new RequestHeaders(uri, new RawHeaders(requestHeaders)); }
Example #24
Source File: HttpURLConnectionImpl.java From cordova-amazon-fireos with Apache License 2.0 | 6 votes |
@Override public final void setRequestProperty(String field, String newValue) { if (connected) { throw new IllegalStateException("Cannot set request property after connection is made"); } 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; } if ("X-Android-Transports".equals(field)) { setTransports(newValue, false /* append */); } else { rawRequestHeaders.set(field, newValue); } }
Example #25
Source File: HttpEngine.java From phonegap-plugin-loading-spinner with Apache License 2.0 | 6 votes |
/** * @param requestHeaders the client's supplied request headers. This class * creates a private copy that it can mutate. * @param connection the connection used for an intermediate response * immediately prior to this request/response pair, such as a same-host * redirect. This engine assumes ownership of the connection and must * release it when it is unneeded. */ public HttpEngine(HttpURLConnectionImpl policy, String method, RawHeaders requestHeaders, Connection connection, RetryableOutputStream requestBodyOut) throws IOException { this.policy = policy; this.method = method; this.connection = connection; this.requestBodyOut = requestBodyOut; try { uri = Platform.get().toUriLenient(policy.getURL()); } catch (URISyntaxException e) { throw new IOException(e.getMessage()); } this.requestHeaders = new RequestHeaders(uri, new RawHeaders(requestHeaders)); }
Example #26
Source File: Connection.java From L.TileLayer.Cordova with MIT License | 6 votes |
public void connect(int connectTimeout, int readTimeout, TunnelRequest tunnelRequest) throws IOException { if (connected) throw new IllegalStateException("already connected"); socket = (route.proxy.type() != Proxy.Type.HTTP) ? new Socket(route.proxy) : new Socket(); Platform.get().connectSocket(socket, route.inetSocketAddress, connectTimeout); socket.setSoTimeout(readTimeout); in = socket.getInputStream(); out = socket.getOutputStream(); if (route.address.sslSocketFactory != null) { upgradeToTls(tunnelRequest); } else { streamWrapper(); } connected = true; }
Example #27
Source File: HttpURLConnectionImpl.java From reader with MIT License | 6 votes |
@Override public final void setRequestProperty(String field, String newValue) { if (connected) { throw new IllegalStateException("Cannot set request property after connection is made"); } 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; } if ("X-Android-Transports".equals(field)) { setTransports(newValue, false /* append */); } else { rawRequestHeaders.set(field, newValue); } }
Example #28
Source File: HttpEngine.java From crosswalk-cordova-android with Apache License 2.0 | 6 votes |
/** * @param requestHeaders the client's supplied request headers. This class * creates a private copy that it can mutate. * @param connection the connection used for an intermediate response * immediately prior to this request/response pair, such as a same-host * redirect. This engine assumes ownership of the connection and must * release it when it is unneeded. */ public HttpEngine(OkHttpClient client, Policy policy, String method, RawHeaders requestHeaders, Connection connection, RetryableOutputStream requestBodyOut) throws IOException { this.client = client; this.policy = policy; this.method = method; this.connection = connection; this.requestBodyOut = requestBodyOut; try { uri = Platform.get().toUriLenient(policy.getURL()); } catch (URISyntaxException e) { throw new IOException(e.getMessage()); } this.requestHeaders = new RequestHeaders(uri, new RawHeaders(requestHeaders)); }
Example #29
Source File: HttpEngine.java From reader with MIT License | 6 votes |
/** * @param requestHeaders the client's supplied request headers. This class * creates a private copy that it can mutate. * @param connection the connection used for an intermediate response * immediately prior to this request/response pair, such as a same-host * redirect. This engine assumes ownership of the connection and must * release it when it is unneeded. */ public HttpEngine(OkHttpClient client, Policy policy, String method, RawHeaders requestHeaders, Connection connection, RetryableOutputStream requestBodyOut) throws IOException { this.client = client; this.policy = policy; this.method = method; this.connection = connection; this.requestBodyOut = requestBodyOut; try { uri = Platform.get().toUriLenient(policy.getURL()); } catch (URISyntaxException e) { throw new IOException(e.getMessage()); } this.requestHeaders = new RequestHeaders(uri, new RawHeaders(requestHeaders)); }
Example #30
Source File: Connection.java From cordova-amazon-fireos with Apache License 2.0 | 6 votes |
public void connect(int connectTimeout, int readTimeout, TunnelRequest tunnelRequest) throws IOException { if (connected) throw new IllegalStateException("already connected"); socket = (route.proxy.type() != Proxy.Type.HTTP) ? new Socket(route.proxy) : new Socket(); Platform.get().connectSocket(socket, route.inetSocketAddress, connectTimeout); socket.setSoTimeout(readTimeout); in = socket.getInputStream(); out = socket.getOutputStream(); if (route.address.sslSocketFactory != null) { upgradeToTls(tunnelRequest); } else { streamWrapper(); } connected = true; }