| 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/http/http_network_transaction.h" | 5 #include "net/http/http_network_transaction.h" |
| 6 | 6 |
| 7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
| 8 #include "base/field_trial.h" | 8 #include "base/field_trial.h" |
| 9 #include "base/format_macros.h" | 9 #include "base/format_macros.h" |
| 10 #include "base/histogram.h" | 10 #include "base/histogram.h" |
| (...skipping 556 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 567 DCHECK_EQ(OK, rv); | 567 DCHECK_EQ(OK, rv); |
| 568 TRACE_EVENT_BEGIN("http.read_headers", request_, request_->url.spec()); | 568 TRACE_EVENT_BEGIN("http.read_headers", request_, request_->url.spec()); |
| 569 net_log_.BeginEvent(NetLog::TYPE_HTTP_TRANSACTION_READ_HEADERS); | 569 net_log_.BeginEvent(NetLog::TYPE_HTTP_TRANSACTION_READ_HEADERS); |
| 570 rv = DoReadHeaders(); | 570 rv = DoReadHeaders(); |
| 571 break; | 571 break; |
| 572 case STATE_READ_HEADERS_COMPLETE: | 572 case STATE_READ_HEADERS_COMPLETE: |
| 573 rv = DoReadHeadersComplete(rv); | 573 rv = DoReadHeadersComplete(rv); |
| 574 TRACE_EVENT_END("http.read_headers", request_, request_->url.spec()); | 574 TRACE_EVENT_END("http.read_headers", request_, request_->url.spec()); |
| 575 net_log_.EndEvent(NetLog::TYPE_HTTP_TRANSACTION_READ_HEADERS); | 575 net_log_.EndEvent(NetLog::TYPE_HTTP_TRANSACTION_READ_HEADERS); |
| 576 break; | 576 break; |
| 577 case STATE_RESOLVE_CANONICAL_NAME: |
| 578 rv = DoResolveCanonicalName(); |
| 579 break; |
| 580 case STATE_RESOLVE_CANONICAL_NAME_COMPLETE: |
| 581 rv = DoResolveCanonicalNameComplete(rv); |
| 582 break; |
| 577 case STATE_READ_BODY: | 583 case STATE_READ_BODY: |
| 578 DCHECK_EQ(OK, rv); | 584 DCHECK_EQ(OK, rv); |
| 579 TRACE_EVENT_BEGIN("http.read_body", request_, request_->url.spec()); | 585 TRACE_EVENT_BEGIN("http.read_body", request_, request_->url.spec()); |
| 580 net_log_.BeginEvent(NetLog::TYPE_HTTP_TRANSACTION_READ_BODY); | 586 net_log_.BeginEvent(NetLog::TYPE_HTTP_TRANSACTION_READ_BODY); |
| 581 rv = DoReadBody(); | 587 rv = DoReadBody(); |
| 582 break; | 588 break; |
| 583 case STATE_READ_BODY_COMPLETE: | 589 case STATE_READ_BODY_COMPLETE: |
| 584 rv = DoReadBodyComplete(rv); | 590 rv = DoReadBodyComplete(rv); |
| 585 TRACE_EVENT_END("http.read_body", request_, request_->url.spec()); | 591 TRACE_EVENT_END("http.read_body", request_, request_->url.spec()); |
| 586 net_log_.EndEvent(NetLog::TYPE_HTTP_TRANSACTION_READ_BODY); | 592 net_log_.EndEvent(NetLog::TYPE_HTTP_TRANSACTION_READ_BODY); |
| (...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1109 if (using_ssl_ && !establishing_tunnel_) { | 1115 if (using_ssl_ && !establishing_tunnel_) { |
| 1110 SSLClientSocket* ssl_socket = | 1116 SSLClientSocket* ssl_socket = |
| 1111 reinterpret_cast<SSLClientSocket*>(connection_->socket()); | 1117 reinterpret_cast<SSLClientSocket*>(connection_->socket()); |
| 1112 ssl_socket->GetSSLInfo(&response_.ssl_info); | 1118 ssl_socket->GetSSLInfo(&response_.ssl_info); |
| 1113 } | 1119 } |
| 1114 | 1120 |
| 1115 headers_valid_ = true; | 1121 headers_valid_ = true; |
| 1116 return OK; | 1122 return OK; |
| 1117 } | 1123 } |
| 1118 | 1124 |
| 1125 int HttpNetworkTransaction::DoResolveCanonicalName() { |
| 1126 HttpAuthHandler* auth_handler = auth_handler_[pending_auth_target_]; |
| 1127 DCHECK(auth_handler); |
| 1128 next_state_ = STATE_RESOLVE_CANONICAL_NAME_COMPLETE; |
| 1129 return auth_handler->ResolveCanonicalName(session_->host_resolver(), |
| 1130 &io_callback_, net_log_); |
| 1131 } |
| 1132 |
| 1133 int HttpNetworkTransaction::DoResolveCanonicalNameComplete(int result) { |
| 1134 // The STATE_RESOLVE_CANONICAL_NAME state ends the Start sequence when the |
| 1135 // canonical name of the server needs to be determined. Normally |
| 1136 // DoReadHeadersComplete completes the sequence. The next state is |
| 1137 // intentionally not set as it should be STATE_NONE; |
| 1138 DCHECK_EQ(STATE_NONE, next_state_); |
| 1139 return result; |
| 1140 } |
| 1141 |
| 1119 int HttpNetworkTransaction::DoReadBody() { | 1142 int HttpNetworkTransaction::DoReadBody() { |
| 1120 DCHECK(read_buf_); | 1143 DCHECK(read_buf_); |
| 1121 DCHECK_GT(read_buf_len_, 0); | 1144 DCHECK_GT(read_buf_len_, 0); |
| 1122 DCHECK(connection_->is_initialized()); | 1145 DCHECK(connection_->is_initialized()); |
| 1123 | 1146 |
| 1124 next_state_ = STATE_READ_BODY_COMPLETE; | 1147 next_state_ = STATE_READ_BODY_COMPLETE; |
| 1125 return http_stream_->ReadResponseBody(read_buf_, read_buf_len_, | 1148 return http_stream_->ReadResponseBody(read_buf_, read_buf_len_, |
| 1126 &io_callback_); | 1149 &io_callback_); |
| 1127 } | 1150 } |
| 1128 | 1151 |
| (...skipping 781 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1910 | 1933 |
| 1911 // Make a note that we are waiting for auth. This variable is inspected | 1934 // Make a note that we are waiting for auth. This variable is inspected |
| 1912 // when the client calls RestartWithAuth() to pick up where we left off. | 1935 // when the client calls RestartWithAuth() to pick up where we left off. |
| 1913 pending_auth_target_ = target; | 1936 pending_auth_target_ = target; |
| 1914 | 1937 |
| 1915 if (auth_identity_[target].invalid) { | 1938 if (auth_identity_[target].invalid) { |
| 1916 // We have exhausted all identity possibilities, all we can do now is | 1939 // We have exhausted all identity possibilities, all we can do now is |
| 1917 // pass the challenge information back to the client. | 1940 // pass the challenge information back to the client. |
| 1918 PopulateAuthChallenge(target, auth_origin); | 1941 PopulateAuthChallenge(target, auth_origin); |
| 1919 } | 1942 } |
| 1943 |
| 1944 // SPN determination (for Negotiate) requires a DNS lookup to find the |
| 1945 // canonical name. This needs to be done asynchronously to prevent blocking |
| 1946 // the IO thread. |
| 1947 if (auth_handler_[target]->NeedsCanonicalName()) |
| 1948 next_state_ = STATE_RESOLVE_CANONICAL_NAME; |
| 1949 |
| 1920 return OK; | 1950 return OK; |
| 1921 } | 1951 } |
| 1922 | 1952 |
| 1923 void HttpNetworkTransaction::PopulateAuthChallenge(HttpAuth::Target target, | 1953 void HttpNetworkTransaction::PopulateAuthChallenge(HttpAuth::Target target, |
| 1924 const GURL& auth_origin) { | 1954 const GURL& auth_origin) { |
| 1925 // Populates response_.auth_challenge with the authentication challenge info. | 1955 // Populates response_.auth_challenge with the authentication challenge info. |
| 1926 // This info is consumed by URLRequestHttpJob::GetAuthChallengeInfo(). | 1956 // This info is consumed by URLRequestHttpJob::GetAuthChallengeInfo(). |
| 1927 | 1957 |
| 1928 AuthChallengeInfo* auth_info = new AuthChallengeInfo; | 1958 AuthChallengeInfo* auth_info = new AuthChallengeInfo; |
| 1929 auth_info->is_proxy = target == HttpAuth::AUTH_PROXY; | 1959 auth_info->is_proxy = target == HttpAuth::AUTH_PROXY; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1943 http_host_port_pair); | 1973 http_host_port_pair); |
| 1944 | 1974 |
| 1945 alternate_protocol_mode_ = kDoNotUseAlternateProtocol; | 1975 alternate_protocol_mode_ = kDoNotUseAlternateProtocol; |
| 1946 if (connection_->socket()) | 1976 if (connection_->socket()) |
| 1947 connection_->socket()->Disconnect(); | 1977 connection_->socket()->Disconnect(); |
| 1948 connection_->Reset(); | 1978 connection_->Reset(); |
| 1949 next_state_ = STATE_INIT_CONNECTION; | 1979 next_state_ = STATE_INIT_CONNECTION; |
| 1950 } | 1980 } |
| 1951 | 1981 |
| 1952 } // namespace net | 1982 } // namespace net |
| OLD | NEW |