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

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

Issue 3091001: Revert 54528 - Digest authentication uses a uri field to prevent replay attac... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 10 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « net/http/http_auth_handler_mock.cc ('k') | net/http/http_network_transaction_unittest.cc » ('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 (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/http/http_network_transaction.h" 5 #include "net/http/http_network_transaction.h"
6 6
7 #include <set> 7 #include <set>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 const HttpAlternateProtocols::PortProtocolPair existing_alternate = 187 const HttpAlternateProtocols::PortProtocolPair existing_alternate =
188 alternate_protocols->GetAlternateProtocolFor(host_port); 188 alternate_protocols->GetAlternateProtocolFor(host_port);
189 // If we think the alternate protocol is broken, don't change it. 189 // If we think the alternate protocol is broken, don't change it.
190 if (existing_alternate.protocol == HttpAlternateProtocols::BROKEN) 190 if (existing_alternate.protocol == HttpAlternateProtocols::BROKEN)
191 return; 191 return;
192 } 192 }
193 193
194 alternate_protocols->SetAlternateProtocolFor(host_port, port, protocol); 194 alternate_protocols->SetAlternateProtocolFor(host_port, port, protocol);
195 } 195 }
196 196
197 GURL UpgradeUrlToHttps(const GURL& original_url) {
198 GURL::Replacements replacements;
199 // new_sheme and new_port need to be in scope here because GURL::Replacements
200 // references the memory contained by them directly.
201 const std::string new_scheme = "https";
202 const std::string new_port = IntToString(443);
203 replacements.SetSchemeStr(new_scheme);
204 replacements.SetPortStr(new_port);
205 return original_url.ReplaceComponents(replacements);
206 }
207
208 } // namespace 197 } // namespace
209 198
210 //----------------------------------------------------------------------------- 199 //-----------------------------------------------------------------------------
211 200
212 bool HttpNetworkTransaction::g_ignore_certificate_errors = false; 201 bool HttpNetworkTransaction::g_ignore_certificate_errors = false;
213 202
214 HttpNetworkTransaction::HttpNetworkTransaction(HttpNetworkSession* session) 203 HttpNetworkTransaction::HttpNetworkTransaction(HttpNetworkSession* session)
215 : pending_auth_target_(HttpAuth::AUTH_NONE), 204 : pending_auth_target_(HttpAuth::AUTH_NONE),
216 ALLOW_THIS_IN_INITIALIZER_LIST( 205 ALLOW_THIS_IN_INITIALIZER_LIST(
217 io_callback_(this, &HttpNetworkTransaction::OnIOComplete)), 206 io_callback_(this, &HttpNetworkTransaction::OnIOComplete)),
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after
686 if (alternate_protocol_mode_ == kUnspecified) { 675 if (alternate_protocol_mode_ == kUnspecified) {
687 HttpAlternateProtocols::PortProtocolPair alternate = 676 HttpAlternateProtocols::PortProtocolPair alternate =
688 alternate_protocols.GetAlternateProtocolFor(endpoint_); 677 alternate_protocols.GetAlternateProtocolFor(endpoint_);
689 if (alternate.protocol != HttpAlternateProtocols::BROKEN) { 678 if (alternate.protocol != HttpAlternateProtocols::BROKEN) {
690 DCHECK_LE(HttpAlternateProtocols::NPN_SPDY_1, alternate.protocol); 679 DCHECK_LE(HttpAlternateProtocols::NPN_SPDY_1, alternate.protocol);
691 DCHECK_GT(HttpAlternateProtocols::NUM_ALTERNATE_PROTOCOLS, 680 DCHECK_GT(HttpAlternateProtocols::NUM_ALTERNATE_PROTOCOLS,
692 alternate.protocol); 681 alternate.protocol);
693 endpoint_.set_port(alternate.port); 682 endpoint_.set_port(alternate.port);
694 alternate_protocol_ = alternate.protocol; 683 alternate_protocol_ = alternate.protocol;
695 alternate_protocol_mode_ = kUsingAlternateProtocol; 684 alternate_protocol_mode_ = kUsingAlternateProtocol;
696 alternate_endpoint_url = UpgradeUrlToHttps(*curr_endpoint_url); 685
686 url_canon::Replacements<char> replacements;
687 replacements.SetScheme("https",
688 url_parse::Component(0, strlen("https")));
689 const std::string port_str = base::IntToString(endpoint_.port());
690 replacements.SetPort(port_str.c_str(),
691 url_parse::Component(0, port_str.size()));
692 alternate_endpoint_url =
693 curr_endpoint_url->ReplaceComponents(replacements);
697 curr_endpoint_url = &alternate_endpoint_url; 694 curr_endpoint_url = &alternate_endpoint_url;
698 } 695 }
699 } 696 }
700 } 697 }
701 698
702 if (request_->load_flags & LOAD_BYPASS_PROXY) { 699 if (request_->load_flags & LOAD_BYPASS_PROXY) {
703 proxy_info_.UseDirect(); 700 proxy_info_.UseDirect();
704 return OK; 701 return OK;
705 } 702 }
706 703
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
776 request_->referrer, 773 request_->referrer,
777 disable_resolver_cache); 774 disable_resolver_cache);
778 } else { 775 } else {
779 ProxyServer proxy_server = proxy_info_.proxy_server(); 776 ProxyServer proxy_server = proxy_info_.proxy_server();
780 proxy_host_port.reset(new HostPortPair(proxy_server.host_port_pair())); 777 proxy_host_port.reset(new HostPortPair(proxy_server.host_port_pair()));
781 scoped_refptr<TCPSocketParams> proxy_tcp_params = 778 scoped_refptr<TCPSocketParams> proxy_tcp_params =
782 new TCPSocketParams(*proxy_host_port, request_->priority, 779 new TCPSocketParams(*proxy_host_port, request_->priority,
783 request_->referrer, disable_resolver_cache); 780 request_->referrer, disable_resolver_cache);
784 781
785 if (proxy_info_.is_http()) { 782 if (proxy_info_.is_http()) {
786 GURL authentication_url = request_->url;
787 if (using_ssl_) {
788 if (!authentication_url.SchemeIs("https")) {
789 // If a proxy tunnel connection needs to be established due to
790 // an Alternate-Protocol, the URL needs to be changed to indicate
791 // https or digest authentication attempts will fail.
792 // For example, suppose the initial request was for
793 // "http://www.example.com/index.html". If this is an SSL
794 // upgrade due to alternate protocol, the digest authorization
795 // should have a uri="www.example.com:443" field rather than a
796 // "/index.html" entry, even though the original request URL has not
797 // changed.
798 authentication_url = UpgradeUrlToHttps(authentication_url);
799 }
800 }
801 establishing_tunnel_ = using_ssl_; 783 establishing_tunnel_ = using_ssl_;
802 http_proxy_params = new HttpProxySocketParams(proxy_tcp_params, 784 http_proxy_params = new HttpProxySocketParams(proxy_tcp_params,
803 authentication_url, 785 request_->url, endpoint_,
804 endpoint_,
805 session_, using_ssl_); 786 session_, using_ssl_);
806 } else { 787 } else {
807 DCHECK(proxy_info_.is_socks()); 788 DCHECK(proxy_info_.is_socks());
808 char socks_version; 789 char socks_version;
809 if (proxy_server.scheme() == ProxyServer::SCHEME_SOCKS5) 790 if (proxy_server.scheme() == ProxyServer::SCHEME_SOCKS5)
810 socks_version = '5'; 791 socks_version = '5';
811 else 792 else
812 socks_version = '4'; 793 socks_version = '4';
813 connection_group = 794 connection_group =
814 StringPrintf("socks%c/%s", socks_version, connection_group.c_str()); 795 StringPrintf("socks%c/%s", socks_version, connection_group.c_str());
(...skipping 1115 matching lines...) Expand 10 before | Expand all | Expand 10 after
1930 default: 1911 default:
1931 return priority; 1912 return priority;
1932 } 1913 }
1933 } 1914 }
1934 1915
1935 1916
1936 1917
1937 #undef STATE_CASE 1918 #undef STATE_CASE
1938 1919
1939 } // namespace net 1920 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_auth_handler_mock.cc ('k') | net/http/http_network_transaction_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698