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

Side by Side Diff: net/http/http_util_icu.cc

Issue 73633002: Add more test cases for HttpUtil::PathForRequest() and SpecForRequest() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | net/http/http_util_unittest.cc » ('j') | net/http/http_util_unittest.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 // The rules for parsing content-types were borrowed from Firefox: 5 // The rules for parsing content-types were borrowed from Firefox:
6 // http://lxr.mozilla.org/mozilla/source/netwerk/base/src/nsURLHelper.cpp#834 6 // http://lxr.mozilla.org/mozilla/source/netwerk/base/src/nsURLHelper.cpp#834
7 7
8 #include "net/http/http_util.h" 8 #include "net/http/http_util.h"
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "net/base/net_util.h" 11 #include "net/base/net_util.h"
12 12
13 namespace net { 13 namespace net {
14 14
15 static bool SchemeIsWebSocket(const GURL& url) {
16 return url.SchemeIs("ws") || url.SchemeIs("wss");
17 }
18
15 // static 19 // static
16 std::string HttpUtil::PathForRequest(const GURL& url) { 20 std::string HttpUtil::PathForRequest(const GURL& url) {
17 DCHECK(url.is_valid() && url.SchemeIsHTTPOrHTTPS()); 21 DCHECK(url.is_valid() && (url.SchemeIsHTTPOrHTTPS() ||
22 SchemeIsWebSocket(url)));
18 if (url.has_query()) 23 if (url.has_query())
19 return url.path() + "?" + url.query(); 24 return url.path() + "?" + url.query();
20 return url.path(); 25 return url.path();
21 } 26 }
22 27
23 // static 28 // static
24 std::string HttpUtil::SpecForRequest(const GURL& url) { 29 std::string HttpUtil::SpecForRequest(const GURL& url) {
25 // We may get ftp scheme when fetching ftp resources through proxy. 30 // We may get ftp scheme when fetching ftp resources through proxy.
26 DCHECK(url.is_valid() && (url.SchemeIsHTTPOrHTTPS() || 31 DCHECK(url.is_valid() && (url.SchemeIsHTTPOrHTTPS() ||
27 url.SchemeIs("ftp"))); 32 url.SchemeIs("ftp") ||
33 SchemeIsWebSocket(url)));
28 return SimplifyUrlForRequest(url).spec(); 34 return SimplifyUrlForRequest(url).spec();
29 } 35 }
30 36
31 } // namespace net 37 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | net/http/http_util_unittest.cc » ('j') | net/http/http_util_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698