OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 package org.chromium.net; | 5 package org.chromium.net; |
6 | 6 |
7 import org.json.JSONArray; | 7 import org.json.JSONArray; |
8 import org.json.JSONException; | 8 import org.json.JSONException; |
9 import org.json.JSONObject; | 9 import org.json.JSONObject; |
10 | 10 |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 * Note that enableHttpCache(DISK) is needed to take advantage of 0-RTT | 104 * Note that enableHttpCache(DISK) is needed to take advantage of 0-RTT |
105 * connection establishment between sessions. | 105 * connection establishment between sessions. |
106 * | 106 * |
107 * @param host of the server that supports QUIC. | 107 * @param host of the server that supports QUIC. |
108 * @param port of the server that supports QUIC. | 108 * @param port of the server that supports QUIC. |
109 * @param alternatePort to use for QUIC. | 109 * @param alternatePort to use for QUIC. |
110 */ | 110 */ |
111 public HttpUrlRequestFactoryConfig addQuicHint(String host, | 111 public HttpUrlRequestFactoryConfig addQuicHint(String host, |
112 int port, | 112 int port, |
113 int alternatePort) { | 113 int alternatePort) { |
| 114 if (host.contains("/")) { |
| 115 throw new IllegalArgumentException("Illegal QUIC Hint Host: " + |
| 116 host); |
| 117 } |
114 try { | 118 try { |
115 JSONArray quicHints = mConfig.optJSONArray( | 119 JSONArray quicHints = mConfig.optJSONArray( |
116 UrlRequestContextConfig.QUIC_HINTS); | 120 UrlRequestContextConfig.QUIC_HINTS); |
117 if (quicHints == null) { | 121 if (quicHints == null) { |
118 quicHints = new JSONArray(); | 122 quicHints = new JSONArray(); |
119 mConfig.put(UrlRequestContextConfig.QUIC_HINTS, quicHints); | 123 mConfig.put(UrlRequestContextConfig.QUIC_HINTS, quicHints); |
120 } | 124 } |
121 | 125 |
122 JSONObject hint = new JSONObject(); | 126 JSONObject hint = new JSONObject(); |
123 hint.put(UrlRequestContextConfig.QUIC_HINT_HOST, host); | 127 hint.put(UrlRequestContextConfig.QUIC_HINT_HOST, host); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 try { | 176 try { |
173 mConfig.put(key, value); | 177 mConfig.put(key, value); |
174 } catch (JSONException e) { | 178 } catch (JSONException e) { |
175 // Intentionally do nothing. | 179 // Intentionally do nothing. |
176 } | 180 } |
177 return this; | 181 return this; |
178 } | 182 } |
179 | 183 |
180 private JSONObject mConfig = new JSONObject(); | 184 private JSONObject mConfig = new JSONObject(); |
181 } | 185 } |
OLD | NEW |