| 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 <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 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 HaveAuth(pending_auth_target_); | 278 HaveAuth(pending_auth_target_); |
| 279 } | 279 } |
| 280 | 280 |
| 281 int HttpNetworkTransaction::Read(IOBuffer* buf, int buf_len, | 281 int HttpNetworkTransaction::Read(IOBuffer* buf, int buf_len, |
| 282 CompletionCallback* callback) { | 282 CompletionCallback* callback) { |
| 283 DCHECK(buf); | 283 DCHECK(buf); |
| 284 DCHECK_LT(0, buf_len); | 284 DCHECK_LT(0, buf_len); |
| 285 | 285 |
| 286 State next_state = STATE_NONE; | 286 State next_state = STATE_NONE; |
| 287 | 287 |
| 288 scoped_refptr<HttpResponseHeaders> headers = GetResponseHeaders(); | 288 scoped_refptr<HttpResponseHeaders> headers(GetResponseHeaders()); |
| 289 if (headers_valid_ && headers.get() && stream_request_.get()) { | 289 if (headers_valid_ && headers.get() && stream_request_.get()) { |
| 290 // We're trying to read the body of the response but we're still trying | 290 // We're trying to read the body of the response but we're still trying |
| 291 // to establish an SSL tunnel through the proxy. We can't read these | 291 // to establish an SSL tunnel through the proxy. We can't read these |
| 292 // bytes when establishing a tunnel because they might be controlled by | 292 // bytes when establishing a tunnel because they might be controlled by |
| 293 // an active network attacker. We don't worry about this for HTTP | 293 // an active network attacker. We don't worry about this for HTTP |
| 294 // because an active network attacker can already control HTTP sessions. | 294 // because an active network attacker can already control HTTP sessions. |
| 295 // We reach this case when the user cancels a 407 proxy auth prompt. | 295 // We reach this case when the user cancels a 407 proxy auth prompt. |
| 296 // See http://crbug.com/8473. | 296 // See http://crbug.com/8473. |
| 297 DCHECK(proxy_info_.is_http() || proxy_info_.is_https()); | 297 DCHECK(proxy_info_.is_http() || proxy_info_.is_https()); |
| 298 DCHECK_EQ(headers->response_code(), 407); | 298 DCHECK_EQ(headers->response_code(), 407); |
| (...skipping 772 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1071 bool HttpNetworkTransaction::ShouldApplyProxyAuth() const { | 1071 bool HttpNetworkTransaction::ShouldApplyProxyAuth() const { |
| 1072 return !is_https_request() && | 1072 return !is_https_request() && |
| 1073 (proxy_info_.is_https() || proxy_info_.is_http()); | 1073 (proxy_info_.is_https() || proxy_info_.is_http()); |
| 1074 } | 1074 } |
| 1075 | 1075 |
| 1076 bool HttpNetworkTransaction::ShouldApplyServerAuth() const { | 1076 bool HttpNetworkTransaction::ShouldApplyServerAuth() const { |
| 1077 return !(request_->load_flags & LOAD_DO_NOT_SEND_AUTH_DATA); | 1077 return !(request_->load_flags & LOAD_DO_NOT_SEND_AUTH_DATA); |
| 1078 } | 1078 } |
| 1079 | 1079 |
| 1080 int HttpNetworkTransaction::HandleAuthChallenge() { | 1080 int HttpNetworkTransaction::HandleAuthChallenge() { |
| 1081 scoped_refptr<HttpResponseHeaders> headers = GetResponseHeaders(); | 1081 scoped_refptr<HttpResponseHeaders> headers(GetResponseHeaders()); |
| 1082 DCHECK(headers); | 1082 DCHECK(headers); |
| 1083 | 1083 |
| 1084 int status = headers->response_code(); | 1084 int status = headers->response_code(); |
| 1085 if (status != 401 && status != 407) | 1085 if (status != 401 && status != 407) |
| 1086 return OK; | 1086 return OK; |
| 1087 HttpAuth::Target target = status == 407 ? | 1087 HttpAuth::Target target = status == 407 ? |
| 1088 HttpAuth::AUTH_PROXY : HttpAuth::AUTH_SERVER; | 1088 HttpAuth::AUTH_PROXY : HttpAuth::AUTH_SERVER; |
| 1089 if (target == HttpAuth::AUTH_PROXY && proxy_info_.is_direct()) | 1089 if (target == HttpAuth::AUTH_PROXY && proxy_info_.is_direct()) |
| 1090 return ERR_UNEXPECTED_PROXY_AUTH; | 1090 return ERR_UNEXPECTED_PROXY_AUTH; |
| 1091 | 1091 |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1166 default: | 1166 default: |
| 1167 return priority; | 1167 return priority; |
| 1168 } | 1168 } |
| 1169 } | 1169 } |
| 1170 | 1170 |
| 1171 | 1171 |
| 1172 | 1172 |
| 1173 #undef STATE_CASE | 1173 #undef STATE_CASE |
| 1174 | 1174 |
| 1175 } // namespace net | 1175 } // namespace net |
| OLD | NEW |