| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 package org.chromium.net.urlconnection; |
| 6 |
| 7 import org.chromium.net.UrlRequestContext; |
| 8 |
| 9 import java.io.IOException; |
| 10 import java.net.Proxy; |
| 11 import java.net.URL; |
| 12 import java.net.URLConnection; |
| 13 import java.net.URLStreamHandler; |
| 14 |
| 15 /** |
| 16 * An {@code URLStreamHandler} that handles http and https connections. |
| 17 */ |
| 18 public class CronetHttpURLStreamHandler extends URLStreamHandler { |
| 19 |
| 20 private final UrlRequestContext mUrlRequestContext; |
| 21 |
| 22 public CronetHttpURLStreamHandler(UrlRequestContext urlRequestContext) { |
| 23 mUrlRequestContext = urlRequestContext; |
| 24 } |
| 25 |
| 26 /** |
| 27 * Establishes a new connection to the resource specified by the URL u. |
| 28 */ |
| 29 @Override |
| 30 protected URLConnection openConnection(URL u) throws IOException { |
| 31 String protocol = u.getProtocol(); |
| 32 if ("http".equals(protocol) || "https".equals(protocol)) { |
| 33 return new CronetHttpURLConnection(u, mUrlRequestContext); |
| 34 } |
| 35 throw new UnsupportedOperationException( |
| 36 "Unexpected protocol:" + protocol); |
| 37 } |
| 38 |
| 39 /** |
| 40 * Establishes a new connection to the resource specified by the URL u |
| 41 * using the given proxy. |
| 42 */ |
| 43 @Override |
| 44 protected URLConnection openConnection(URL u, Proxy proxy) { |
| 45 throw new UnsupportedOperationException(); |
| 46 } |
| 47 } |
| OLD | NEW |