OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #include "net/proxy/proxy_server.h" | 5 #include "net/proxy/proxy_server.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/string_tokenizer.h" | 9 #include "base/string_tokenizer.h" |
10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 // Parse the proxy scheme from a URL-like representation, to a | 43 // Parse the proxy scheme from a URL-like representation, to a |
44 // ProxyServer::Scheme. This corresponds with the values used in | 44 // ProxyServer::Scheme. This corresponds with the values used in |
45 // ProxyServer::ToURI(). If no type could be matched, returns SCHEME_INVALID. | 45 // ProxyServer::ToURI(). If no type could be matched, returns SCHEME_INVALID. |
46 ProxyServer::Scheme GetSchemeFromURI(std::string::const_iterator begin, | 46 ProxyServer::Scheme GetSchemeFromURI(std::string::const_iterator begin, |
47 std::string::const_iterator end) { | 47 std::string::const_iterator end) { |
48 if (LowerCaseEqualsASCII(begin, end, "http")) | 48 if (LowerCaseEqualsASCII(begin, end, "http")) |
49 return ProxyServer::SCHEME_HTTP; | 49 return ProxyServer::SCHEME_HTTP; |
50 if (LowerCaseEqualsASCII(begin, end, "socks4")) | 50 if (LowerCaseEqualsASCII(begin, end, "socks4")) |
51 return ProxyServer::SCHEME_SOCKS4; | 51 return ProxyServer::SCHEME_SOCKS4; |
52 if (LowerCaseEqualsASCII(begin, end, "socks")) | 52 if (LowerCaseEqualsASCII(begin, end, "socks")) |
53 return ProxyServer::SCHEME_SOCKS4; | 53 return ProxyServer::SCHEME_SOCKS5; |
54 if (LowerCaseEqualsASCII(begin, end, "socks5")) | 54 if (LowerCaseEqualsASCII(begin, end, "socks5")) |
55 return ProxyServer::SCHEME_SOCKS5; | 55 return ProxyServer::SCHEME_SOCKS5; |
56 if (LowerCaseEqualsASCII(begin, end, "direct")) | 56 if (LowerCaseEqualsASCII(begin, end, "direct")) |
57 return ProxyServer::SCHEME_DIRECT; | 57 return ProxyServer::SCHEME_DIRECT; |
58 if (LowerCaseEqualsASCII(begin, end, "https")) | 58 if (LowerCaseEqualsASCII(begin, end, "https")) |
59 return ProxyServer::SCHEME_HTTPS; | 59 return ProxyServer::SCHEME_HTTPS; |
60 return ProxyServer::SCHEME_INVALID; | 60 return ProxyServer::SCHEME_INVALID; |
61 } | 61 } |
62 | 62 |
63 std::string HostNoBrackets(const std::string& host) { | 63 std::string HostNoBrackets(const std::string& host) { |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 if (port == -1) | 229 if (port == -1) |
230 port = GetDefaultPortForScheme(scheme); | 230 port = GetDefaultPortForScheme(scheme); |
231 | 231 |
232 host_port_pair = HostPortPair(HostNoBrackets(host), port); | 232 host_port_pair = HostPortPair(HostNoBrackets(host), port); |
233 } | 233 } |
234 | 234 |
235 return ProxyServer(scheme, host_port_pair); | 235 return ProxyServer(scheme, host_port_pair); |
236 } | 236 } |
237 | 237 |
238 } // namespace net | 238 } // namespace net |
OLD | NEW |