Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(17)

Side by Side Diff: components/cronet/android/java/src/org/chromium/net/HttpUrlRequestFactoryConfig.java

Issue 642913004: Throw IllegalArgumentException from addQuicHint if host is URL. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add IsCanonicalizedHostCompliant check to Quic Hint parsing. Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | components/cronet/android/test/javatests/src/org/chromium/cronet_test_apk/HttpUrlRequestFactoryTest.java » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 }
OLDNEW
« no previous file with comments | « no previous file | components/cronet/android/test/javatests/src/org/chromium/cronet_test_apk/HttpUrlRequestFactoryTest.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698