diff options
author | Jake Wharton <jakewharton@gmail.com> | 2013-05-20 18:01:38 -0700 |
---|---|---|
committer | Jake Wharton <jakewharton@gmail.com> | 2013-05-20 18:02:59 -0700 |
commit | 05a1b0edb25ed84c95523df7a81bd87a44b697d7 (patch) | |
tree | 630789670af876d77433b186d9fb2d23d3d30d6f /src | |
parent | c6b2aaa5641f0f1c03b8126e1b617eb2f9b45b18 (diff) | |
download | volley-05a1b0edb25ed84c95523df7a81bd87a44b697d7.tar.gz |
Allow override point for connection creation.
This provides an easy insertion point for alternate implementations
of the HttpUrlConnection API (e.g., OkHttp).
Change-Id: I84482c7a66ce7106680d2efc9865743b8ecb0248
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/volley/toolbox/HurlStack.java | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/com/android/volley/toolbox/HurlStack.java b/src/com/android/volley/toolbox/HurlStack.java index bbfb12a..97f94f0 100644 --- a/src/com/android/volley/toolbox/HurlStack.java +++ b/src/com/android/volley/toolbox/HurlStack.java @@ -146,13 +146,20 @@ public class HurlStack implements HttpStack { } /** + * Create an {@link HttpURLConnection} for the specified {@code url}. + */ + protected HttpURLConnection createConnection(URL url) throws IOException { + return (HttpURLConnection) url.openConnection(); + } + + /** * Opens an {@link HttpURLConnection} with parameters. * @param url * @return an open connection * @throws IOException */ private HttpURLConnection openConnection(URL url, Request<?> request) throws IOException { - HttpURLConnection connection = (HttpURLConnection) url.openConnection(); + HttpURLConnection connection = createConnection(url); int timeoutMs = request.getTimeoutMs(); connection.setConnectTimeout(timeoutMs); |