| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_stream_parser.h" | 5 #include "net/http/http_stream_parser.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 DCHECK(callback_.is_null()); | 238 DCHECK(callback_.is_null()); |
| 239 DCHECK(!callback.is_null()); | 239 DCHECK(!callback.is_null()); |
| 240 DCHECK(response); | 240 DCHECK(response); |
| 241 | 241 |
| 242 net_log_.AddEvent( | 242 net_log_.AddEvent( |
| 243 NetLog::TYPE_HTTP_TRANSACTION_SEND_REQUEST_HEADERS, | 243 NetLog::TYPE_HTTP_TRANSACTION_SEND_REQUEST_HEADERS, |
| 244 base::Bind(&HttpRequestHeaders::NetLogCallback, | 244 base::Bind(&HttpRequestHeaders::NetLogCallback, |
| 245 base::Unretained(&headers), | 245 base::Unretained(&headers), |
| 246 &request_line)); | 246 &request_line)); |
| 247 | 247 |
| 248 DVLOG(1) << __FUNCTION__ << "()" | 248 DVLOG(1) << __func__ << "() request_line = \"" << request_line << "\"" |
| 249 << " request_line = \"" << request_line << "\"" | |
| 250 << " headers = \"" << headers.ToString() << "\""; | 249 << " headers = \"" << headers.ToString() << "\""; |
| 251 response_ = response; | 250 response_ = response; |
| 252 | 251 |
| 253 // Put the peer's IP address and port into the response. | 252 // Put the peer's IP address and port into the response. |
| 254 IPEndPoint ip_endpoint; | 253 IPEndPoint ip_endpoint; |
| 255 int result = connection_->socket()->GetPeerAddress(&ip_endpoint); | 254 int result = connection_->socket()->GetPeerAddress(&ip_endpoint); |
| 256 if (result != OK) | 255 if (result != OK) |
| 257 return result; | 256 return result; |
| 258 response_->socket_address = HostPortPair::FromIPEndPoint(ip_endpoint); | 257 response_->socket_address = HostPortPair::FromIPEndPoint(ip_endpoint); |
| 259 | 258 |
| (...skipping 772 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1032 | 1031 |
| 1033 response_->headers = headers; | 1032 response_->headers = headers; |
| 1034 if (headers->GetHttpVersion() == HttpVersion(0, 9)) { | 1033 if (headers->GetHttpVersion() == HttpVersion(0, 9)) { |
| 1035 response_->connection_info = HttpResponseInfo::CONNECTION_INFO_HTTP0_9; | 1034 response_->connection_info = HttpResponseInfo::CONNECTION_INFO_HTTP0_9; |
| 1036 } else if (headers->GetHttpVersion() == HttpVersion(1, 0)) { | 1035 } else if (headers->GetHttpVersion() == HttpVersion(1, 0)) { |
| 1037 response_->connection_info = HttpResponseInfo::CONNECTION_INFO_HTTP1_0; | 1036 response_->connection_info = HttpResponseInfo::CONNECTION_INFO_HTTP1_0; |
| 1038 } else if (headers->GetHttpVersion() == HttpVersion(1, 1)) { | 1037 } else if (headers->GetHttpVersion() == HttpVersion(1, 1)) { |
| 1039 response_->connection_info = HttpResponseInfo::CONNECTION_INFO_HTTP1_1; | 1038 response_->connection_info = HttpResponseInfo::CONNECTION_INFO_HTTP1_1; |
| 1040 } | 1039 } |
| 1041 response_->vary_data.Init(*request_, *response_->headers); | 1040 response_->vary_data.Init(*request_, *response_->headers); |
| 1042 DVLOG(1) << __FUNCTION__ << "()" | 1041 DVLOG(1) << __func__ << "() content_length = \"" |
| 1043 << " content_length = \"" << response_->headers->GetContentLength() | 1042 << response_->headers->GetContentLength() << "\n\"" |
| 1044 << "\n\"" | |
| 1045 << " headers = \"" << GetResponseHeaderLines(*response_->headers) | 1043 << " headers = \"" << GetResponseHeaderLines(*response_->headers) |
| 1046 << "\""; | 1044 << "\""; |
| 1047 return OK; | 1045 return OK; |
| 1048 } | 1046 } |
| 1049 | 1047 |
| 1050 void HttpStreamParser::CalculateResponseBodySize() { | 1048 void HttpStreamParser::CalculateResponseBodySize() { |
| 1051 // Figure how to determine EOF: | 1049 // Figure how to determine EOF: |
| 1052 | 1050 |
| 1053 // For certain responses, we know the content length is always 0. From | 1051 // For certain responses, we know the content length is always 0. From |
| 1054 // RFC 7230 Section 3.3 Message Body: | 1052 // RFC 7230 Section 3.3 Message Body: |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1224 UMA_HISTOGRAM_ENUMERATION("Net.HttpStatusLineStatus", status, | 1222 UMA_HISTOGRAM_ENUMERATION("Net.HttpStatusLineStatus", status, |
| 1225 HttpStatusLineValidator::STATUS_LINE_MAX); | 1223 HttpStatusLineValidator::STATUS_LINE_MAX); |
| 1226 } | 1224 } |
| 1227 | 1225 |
| 1228 bool HttpStreamParser::SendRequestBuffersEmpty() { | 1226 bool HttpStreamParser::SendRequestBuffersEmpty() { |
| 1229 return request_headers_ == nullptr && request_body_send_buf_ == nullptr && | 1227 return request_headers_ == nullptr && request_body_send_buf_ == nullptr && |
| 1230 request_body_send_buf_ == nullptr; | 1228 request_body_send_buf_ == nullptr; |
| 1231 } | 1229 } |
| 1232 | 1230 |
| 1233 } // namespace net | 1231 } // namespace net |
| OLD | NEW |