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

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

Issue 53111: Treat all 1xx the same as a 100 (continue). (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Move Ignores1xx to appear AFTER Ignores100, and add a comment on how it differs Created 11 years, 9 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 | « no previous file | 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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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/scoped_ptr.h" 7 #include "base/scoped_ptr.h"
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/field_trial.h" 9 #include "base/field_trial.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
(...skipping 1023 matching lines...) Expand 10 before | Expand all | Expand 10 after
1034 // example, Squid uses a 404 response to report the DNS error: "The 1034 // example, Squid uses a 404 response to report the DNS error: "The
1035 // domain name does not exist." 1035 // domain name does not exist."
1036 LogBlockedTunnelResponse(headers->response_code()); 1036 LogBlockedTunnelResponse(headers->response_code());
1037 return ERR_TUNNEL_CONNECTION_FAILED; 1037 return ERR_TUNNEL_CONNECTION_FAILED;
1038 } 1038 }
1039 } 1039 }
1040 1040
1041 // Check for an intermediate 100 Continue response. An origin server is 1041 // Check for an intermediate 100 Continue response. An origin server is
1042 // allowed to send this response even if we didn't ask for it, so we just 1042 // allowed to send this response even if we didn't ask for it, so we just
1043 // need to skip over it. 1043 // need to skip over it.
1044 if (headers->response_code() == 100) { 1044 // We treat any other 1xx in this same way (although in practice getting
1045 // a 1xx that isn't a 100 is rare).
1046 if (headers->response_code() / 100 == 1) {
1045 header_buf_len_ -= header_buf_body_offset_; 1047 header_buf_len_ -= header_buf_body_offset_;
1046 // If we've already received some bytes after the 100 Continue response, 1048 // If we've already received some bytes after the 1xx response,
1047 // move them to the beginning of header_buf_. 1049 // move them to the beginning of header_buf_.
1048 if (header_buf_len_) { 1050 if (header_buf_len_) {
1049 memmove(header_buf_.get(), header_buf_.get() + header_buf_body_offset_, 1051 memmove(header_buf_.get(), header_buf_.get() + header_buf_body_offset_,
1050 header_buf_len_); 1052 header_buf_len_);
1051 } 1053 }
1052 header_buf_body_offset_ = -1; 1054 header_buf_body_offset_ = -1;
1053 next_state_ = STATE_READ_HEADERS; 1055 next_state_ = STATE_READ_HEADERS;
1054 return OK; 1056 return OK;
1055 } 1057 }
1056 1058
1057 response_.headers = headers; 1059 response_.headers = headers;
1058 response_.vary_data.Init(*request_, *response_.headers); 1060 response_.vary_data.Init(*request_, *response_.headers);
1059 1061
1060 // Figure how to determine EOF: 1062 // Figure how to determine EOF:
1061 1063
1062 // For certain responses, we know the content length is always 0. From 1064 // For certain responses, we know the content length is always 0. From
1063 // RFC 2616 Section 4.3 Message Body: 1065 // RFC 2616 Section 4.3 Message Body:
1064 // 1066 //
1065 // For response messages, whether or not a message-body is included with 1067 // For response messages, whether or not a message-body is included with
1066 // a message is dependent on both the request method and the response 1068 // a message is dependent on both the request method and the response
1067 // status code (section 6.1.1). All responses to the HEAD request method 1069 // status code (section 6.1.1). All responses to the HEAD request method
1068 // MUST NOT include a message-body, even though the presence of entity- 1070 // MUST NOT include a message-body, even though the presence of entity-
1069 // header fields might lead one to believe they do. All 1xx 1071 // header fields might lead one to believe they do. All 1xx
1070 // (informational), 204 (no content), and 304 (not modified) responses 1072 // (informational), 204 (no content), and 304 (not modified) responses
1071 // MUST NOT include a message-body. All other responses do include a 1073 // MUST NOT include a message-body. All other responses do include a
1072 // message-body, although it MAY be of zero length. 1074 // message-body, although it MAY be of zero length.
1073 switch (response_.headers->response_code()) { 1075 switch (response_.headers->response_code()) {
1076 // Note that 1xx was already handled earlier.
1074 case 204: // No Content 1077 case 204: // No Content
1075 case 205: // Reset Content 1078 case 205: // Reset Content
1076 case 304: // Not Modified 1079 case 304: // Not Modified
1077 response_body_length_ = 0; 1080 response_body_length_ = 0;
1078 break; 1081 break;
1079 } 1082 }
1080 if (request_->method == "HEAD") 1083 if (request_->method == "HEAD")
1081 response_body_length_ = 0; 1084 response_body_length_ = 0;
1082 1085
1083 if (response_body_length_ == -1) { 1086 if (response_body_length_ == -1) {
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after
1512 if (target == HttpAuth::AUTH_PROXY) { 1515 if (target == HttpAuth::AUTH_PROXY) {
1513 auth_info->host = ASCIIToWide(proxy_info_.proxy_server().host_and_port()); 1516 auth_info->host = ASCIIToWide(proxy_info_.proxy_server().host_and_port());
1514 } else { 1517 } else {
1515 DCHECK(target == HttpAuth::AUTH_SERVER); 1518 DCHECK(target == HttpAuth::AUTH_SERVER);
1516 auth_info->host = ASCIIToWide(request_->url.host()); 1519 auth_info->host = ASCIIToWide(request_->url.host());
1517 } 1520 }
1518 response_.auth_challenge = auth_info; 1521 response_.auth_challenge = auth_info;
1519 } 1522 }
1520 1523
1521 } // namespace net 1524 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | net/http/http_network_transaction_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698