summaryrefslogtreecommitdiffstats
path: root/net/http/http_proxy_utils.cc
diff options
context:
space:
mode:
authorrch@chromium.org <rch@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-28 03:28:27 +0000
committerrch@chromium.org <rch@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-28 03:28:27 +0000
commit3ee0489049bb17df3ec74213dbcc8e74d927d7c0 (patch)
tree475fbaafb8ecd58b4eaf5272b002752f62a7d4a3 /net/http/http_proxy_utils.cc
parente2150328d75a1ae7a7684a7e5fda90842886812d (diff)
downloadchromium_src-3ee0489049bb17df3ec74213dbcc8e74d927d7c0.zip
chromium_src-3ee0489049bb17df3ec74213dbcc8e74d927d7c0.tar.gz
chromium_src-3ee0489049bb17df3ec74213dbcc8e74d927d7c0.tar.bz2
Add a new class SpdyProxyClientSocket which implements ClientSocket
by sending a CONNECT request via a SPDY SYN_STREAM frame to a SPDY proxy, and then reading/writing data to/from SPDY Data frames. BUG=29625 TEST=none Review URL: http://codereview.chromium.org/3432009 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@60747 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/http/http_proxy_utils.cc')
-rw-r--r--net/http/http_proxy_utils.cc39
1 files changed, 39 insertions, 0 deletions
diff --git a/net/http/http_proxy_utils.cc b/net/http/http_proxy_utils.cc
new file mode 100644
index 0000000..3e4fb8b
--- /dev/null
+++ b/net/http/http_proxy_utils.cc
@@ -0,0 +1,39 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "net/http/http_proxy_utils.h"
+
+#include "base/string_util.h"
+#include "googleurl/src/gurl.h"
+#include "net/base/host_port_pair.h"
+#include "net/base/net_util.h"
+#include "net/http/http_request_info.h"
+
+namespace net {
+
+void BuildTunnelRequest(
+ const HttpRequestInfo& request_info,
+ const HttpRequestHeaders& auth_headers,
+ const HostPortPair& endpoint,
+ std::string* request_line,
+ HttpRequestHeaders* request_headers) {
+ // RFC 2616 Section 9 says the Host request-header field MUST accompany all
+ // HTTP/1.1 requests. Add "Proxy-Connection: keep-alive" for compat with
+ // HTTP/1.0 proxies such as Squid (required for NTLM authentication).
+ *request_line = StringPrintf(
+ "CONNECT %s HTTP/1.1\r\n", endpoint.ToString().c_str());
+ request_headers->SetHeader(HttpRequestHeaders::kHost,
+ GetHostAndOptionalPort(request_info.url));
+ request_headers->SetHeader(HttpRequestHeaders::kProxyConnection,
+ "keep-alive");
+
+ std::string user_agent;
+ if (request_info.extra_headers.GetHeader(HttpRequestHeaders::kUserAgent,
+ &user_agent))
+ request_headers->SetHeader(HttpRequestHeaders::kUserAgent, user_agent);
+
+ request_headers->MergeFrom(auth_headers);
+}
+
+} // namespace net