Java Code Examples for com.squareup.okhttp.Connection#getSocket()
The following examples show how to use
com.squareup.okhttp.Connection#getSocket() .
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: HttpTransport.java From phonegap-plugin-loading-spinner with Apache License 2.0 | 6 votes |
/** * Discards the response body so that the connection can be reused. This * needs to be done judiciously, since it delays the current request in * order to speed up a potential future request that may never occur. */ private static boolean discardStream(HttpEngine httpEngine, InputStream responseBodyIn) { Connection connection = httpEngine.connection; if (connection == null) return false; Socket socket = connection.getSocket(); if (socket == null) return false; try { int socketTimeout = socket.getSoTimeout(); socket.setSoTimeout(DISCARD_STREAM_TIMEOUT_MILLIS); try { Util.skipAll(responseBodyIn); return true; } finally { socket.setSoTimeout(socketTimeout); } } catch (IOException e) { return false; } }
Example 2
Source File: HttpTransport.java From CordovaYoutubeVideoPlayer with MIT License | 6 votes |
/** * Discards the response body so that the connection can be reused. This * needs to be done judiciously, since it delays the current request in * order to speed up a potential future request that may never occur. * * <p>A stream may be discarded to encourage response caching (a response * cannot be cached unless it is consumed completely) or to enable connection * reuse. */ private static boolean discardStream(HttpEngine httpEngine, InputStream responseBodyIn) { Connection connection = httpEngine.connection; if (connection == null) return false; Socket socket = connection.getSocket(); if (socket == null) return false; try { int socketTimeout = socket.getSoTimeout(); socket.setSoTimeout(DISCARD_STREAM_TIMEOUT_MILLIS); try { Util.skipAll(responseBodyIn); return true; } finally { socket.setSoTimeout(socketTimeout); } } catch (IOException e) { return false; } }
Example 3
Source File: HttpTransport.java From IoTgo_Android_App with MIT License | 6 votes |
/** * Discards the response body so that the connection can be reused. This * needs to be done judiciously, since it delays the current request in * order to speed up a potential future request that may never occur. * * <p>A stream may be discarded to encourage response caching (a response * cannot be cached unless it is consumed completely) or to enable connection * reuse. */ private static boolean discardStream(HttpEngine httpEngine, InputStream responseBodyIn) { Connection connection = httpEngine.connection; if (connection == null) return false; Socket socket = connection.getSocket(); if (socket == null) return false; try { int socketTimeout = socket.getSoTimeout(); socket.setSoTimeout(DISCARD_STREAM_TIMEOUT_MILLIS); try { Util.skipAll(responseBodyIn); return true; } finally { socket.setSoTimeout(socketTimeout); } } catch (IOException e) { return false; } }
Example 4
Source File: HttpTransport.java From cordova-android-chromeview with Apache License 2.0 | 6 votes |
/** * Discards the response body so that the connection can be reused. This * needs to be done judiciously, since it delays the current request in * order to speed up a potential future request that may never occur. */ private static boolean discardStream(HttpEngine httpEngine, InputStream responseBodyIn) { Connection connection = httpEngine.connection; if (connection == null) return false; Socket socket = connection.getSocket(); if (socket == null) return false; try { int socketTimeout = socket.getSoTimeout(); socket.setSoTimeout(DISCARD_STREAM_TIMEOUT_MILLIS); try { Util.skipAll(responseBodyIn); return true; } finally { socket.setSoTimeout(socketTimeout); } } catch (IOException e) { return false; } }
Example 5
Source File: HttpTransport.java From cordova-amazon-fireos with Apache License 2.0 | 6 votes |
/** * Discards the response body so that the connection can be reused. This * needs to be done judiciously, since it delays the current request in * order to speed up a potential future request that may never occur. * * <p>A stream may be discarded to encourage response caching (a response * cannot be cached unless it is consumed completely) or to enable connection * reuse. */ private static boolean discardStream(HttpEngine httpEngine, InputStream responseBodyIn) { Connection connection = httpEngine.connection; if (connection == null) return false; Socket socket = connection.getSocket(); if (socket == null) return false; try { int socketTimeout = socket.getSoTimeout(); socket.setSoTimeout(DISCARD_STREAM_TIMEOUT_MILLIS); try { Util.skipAll(responseBodyIn); return true; } finally { socket.setSoTimeout(socketTimeout); } } catch (IOException e) { return false; } }
Example 6
Source File: HttpTransport.java From wildfly-samples with MIT License | 6 votes |
/** * Discards the response body so that the connection can be reused. This * needs to be done judiciously, since it delays the current request in * order to speed up a potential future request that may never occur. * * <p>A stream may be discarded to encourage response caching (a response * cannot be cached unless it is consumed completely) or to enable connection * reuse. */ private static boolean discardStream(HttpEngine httpEngine, InputStream responseBodyIn) { Connection connection = httpEngine.connection; if (connection == null) return false; Socket socket = connection.getSocket(); if (socket == null) return false; try { int socketTimeout = socket.getSoTimeout(); socket.setSoTimeout(DISCARD_STREAM_TIMEOUT_MILLIS); try { Util.skipAll(responseBodyIn); return true; } finally { socket.setSoTimeout(socketTimeout); } } catch (IOException e) { return false; } }
Example 7
Source File: HttpTransport.java From bluemix-parking-meter with MIT License | 6 votes |
/** * Discards the response body so that the connection can be reused. This * needs to be done judiciously, since it delays the current request in * order to speed up a potential future request that may never occur. * * <p>A stream may be discarded to encourage response caching (a response * cannot be cached unless it is consumed completely) or to enable connection * reuse. */ private static boolean discardStream(HttpEngine httpEngine, InputStream responseBodyIn) { Connection connection = httpEngine.connection; if (connection == null) return false; Socket socket = connection.getSocket(); if (socket == null) return false; try { int socketTimeout = socket.getSoTimeout(); socket.setSoTimeout(DISCARD_STREAM_TIMEOUT_MILLIS); try { Util.skipAll(responseBodyIn); return true; } finally { socket.setSoTimeout(socketTimeout); } } catch (IOException e) { return false; } }
Example 8
Source File: HttpsEngine.java From bluemix-parking-meter with MIT License | 4 votes |
@Override protected void connected(Connection connection) { this.sslSocket = (SSLSocket) connection.getSocket(); super.connected(connection); }
Example 9
Source File: HttpsURLConnectionImpl.java From phonegap-plugin-loading-spinner with Apache License 2.0 | 4 votes |
/** * @param policy the HttpURLConnectionImpl with connection configuration */ public HttpsEngine(HttpURLConnectionImpl policy, String method, RawHeaders requestHeaders, Connection connection, RetryableOutputStream requestBody) throws IOException { super(policy, method, requestHeaders, connection, requestBody); this.sslSocket = connection != null ? (SSLSocket) connection.getSocket() : null; }
Example 10
Source File: HttpsEngine.java From crosswalk-cordova-android with Apache License 2.0 | 4 votes |
@Override protected void connected(Connection connection) { this.sslSocket = (SSLSocket) connection.getSocket(); super.connected(connection); }
Example 11
Source File: HttpsEngine.java From reader with MIT License | 4 votes |
@Override protected void connected(Connection connection) { this.sslSocket = (SSLSocket) connection.getSocket(); super.connected(connection); }
Example 12
Source File: HttpsEngine.java From CordovaYoutubeVideoPlayer with MIT License | 4 votes |
@Override protected void connected(Connection connection) { this.sslSocket = (SSLSocket) connection.getSocket(); super.connected(connection); }
Example 13
Source File: HttpsEngine.java From reader with MIT License | 4 votes |
public HttpsEngine(OkHttpClient client, Policy policy, String method, RawHeaders requestHeaders, Connection connection, RetryableOutputStream requestBody) throws IOException { super(client, policy, method, requestHeaders, connection, requestBody); this.sslSocket = connection != null ? (SSLSocket) connection.getSocket() : null; }
Example 14
Source File: HttpsEngine.java From L.TileLayer.Cordova with MIT License | 4 votes |
public HttpsEngine(OkHttpClient client, Policy policy, String method, RawHeaders requestHeaders, Connection connection, RetryableOutputStream requestBody) throws IOException { super(client, policy, method, requestHeaders, connection, requestBody); this.sslSocket = connection != null ? (SSLSocket) connection.getSocket() : null; }
Example 15
Source File: HttpsEngine.java From bluemix-parking-meter with MIT License | 4 votes |
public HttpsEngine(OkHttpClient client, Policy policy, String method, RawHeaders requestHeaders, Connection connection, RetryableOutputStream requestBody) throws IOException { super(client, policy, method, requestHeaders, connection, requestBody); this.sslSocket = connection != null ? (SSLSocket) connection.getSocket() : null; }
Example 16
Source File: HttpsEngine.java From phonegapbootcampsite with MIT License | 4 votes |
public HttpsEngine(OkHttpClient client, Policy policy, String method, RawHeaders requestHeaders, Connection connection, RetryableOutputStream requestBody) throws IOException { super(client, policy, method, requestHeaders, connection, requestBody); this.sslSocket = connection != null ? (SSLSocket) connection.getSocket() : null; }
Example 17
Source File: HttpsEngine.java From wildfly-samples with MIT License | 4 votes |
@Override protected void connected(Connection connection) { this.sslSocket = (SSLSocket) connection.getSocket(); super.connected(connection); }
Example 18
Source File: HttpsEngine.java From IoTgo_Android_App with MIT License | 4 votes |
@Override protected void connected(Connection connection) { this.sslSocket = (SSLSocket) connection.getSocket(); super.connected(connection); }
Example 19
Source File: HttpsEngine.java From CordovaYoutubeVideoPlayer with MIT License | 4 votes |
public HttpsEngine(OkHttpClient client, Policy policy, String method, RawHeaders requestHeaders, Connection connection, RetryableOutputStream requestBody) throws IOException { super(client, policy, method, requestHeaders, connection, requestBody); this.sslSocket = connection != null ? (SSLSocket) connection.getSocket() : null; }
Example 20
Source File: HttpsEngine.java From L.TileLayer.Cordova with MIT License | 4 votes |
@Override protected void connected(Connection connection) { this.sslSocket = (SSLSocket) connection.getSocket(); super.connected(connection); }