| 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_stream_parser.h" | 5 #include "net/http/http_stream_parser.h" |
| 6 | 6 |
| 7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
| 8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
| 9 #include "net/base/auth.h" | 9 #include "net/base/auth.h" |
| 10 #include "net/base/io_buffer.h" | 10 #include "net/base/io_buffer.h" |
| 11 #include "net/base/ssl_cert_request_info.h" | 11 #include "net/base/ssl_cert_request_info.h" |
| 12 #include "net/http/http_net_log_params.h" | 12 #include "net/http/http_net_log_params.h" |
| 13 #include "net/http/http_request_headers.h" | 13 #include "net/http/http_request_headers.h" |
| 14 #include "net/base/load_flags.h" |
| 14 #include "net/http/http_request_info.h" | 15 #include "net/http/http_request_info.h" |
| 15 #include "net/http/http_response_headers.h" | 16 #include "net/http/http_response_headers.h" |
| 16 #include "net/http/http_util.h" | 17 #include "net/http/http_util.h" |
| 17 #include "net/socket/ssl_client_socket.h" | 18 #include "net/socket/ssl_client_socket.h" |
| 18 #include "net/socket/client_socket_handle.h" | 19 #include "net/socket/client_socket_handle.h" |
| 19 | 20 |
| 20 namespace net { | 21 namespace net { |
| 21 | 22 |
| 22 HttpStreamParser::HttpStreamParser(ClientSocketHandle* connection, | 23 HttpStreamParser::HttpStreamParser(ClientSocketHandle* connection, |
| 23 const HttpRequestInfo* request, | 24 const HttpRequestInfo* request, |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 } else { | 230 } else { |
| 230 coalesce = NO_ADVANTAGE; | 231 coalesce = NO_ADVANTAGE; |
| 231 } | 232 } |
| 232 } | 233 } |
| 233 UMA_HISTOGRAM_ENUMERATION("Net.CoalescePotential", coalesce, | 234 UMA_HISTOGRAM_ENUMERATION("Net.CoalescePotential", coalesce, |
| 234 COALESCE_POTENTIAL_MAX); | 235 COALESCE_POTENTIAL_MAX); |
| 235 } | 236 } |
| 236 result = connection_->socket()->Write(request_headers_, | 237 result = connection_->socket()->Write(request_headers_, |
| 237 bytes_remaining, | 238 bytes_remaining, |
| 238 &io_callback_); | 239 &io_callback_); |
| 239 } else if (request_body_ != NULL && request_body_->size()) { | 240 } else if (request_body_ != NULL && |
| 241 (request_body_->is_chunked() || request_body_->size())) { |
| 240 io_state_ = STATE_SENDING_BODY; | 242 io_state_ = STATE_SENDING_BODY; |
| 241 result = OK; | 243 result = OK; |
| 242 } else { | 244 } else { |
| 243 io_state_ = STATE_REQUEST_SENT; | 245 io_state_ = STATE_REQUEST_SENT; |
| 244 } | 246 } |
| 245 return result; | 247 return result; |
| 246 } | 248 } |
| 247 | 249 |
| 248 int HttpStreamParser::DoSendBody(int result) { | 250 int HttpStreamParser::DoSendBody(int result) { |
| 249 if (result > 0) | 251 if (result > 0) |
| 250 request_body_->DidConsume(result); | 252 request_body_->DidConsume(result); |
| 251 | 253 |
| 252 if (!request_body_->eof()) { | 254 if (request_body_->waiting_for_data()) { |
| 255 // More POST data is to come, stay in the same state and wait for the |
| 256 // callback. |
| 257 request_body_->set_data_callback(&io_callback_); |
| 258 result = ERR_IO_PENDING; |
| 259 } else if (!request_body_->eof()) { |
| 253 int buf_len = static_cast<int>(request_body_->buf_len()); | 260 int buf_len = static_cast<int>(request_body_->buf_len()); |
| 254 result = connection_->socket()->Write(request_body_->buf(), buf_len, | 261 result = connection_->socket()->Write(request_body_->buf(), buf_len, |
| 255 &io_callback_); | 262 &io_callback_); |
| 256 } else { | 263 } else { |
| 257 io_state_ = STATE_REQUEST_SENT; | 264 io_state_ = STATE_REQUEST_SENT; |
| 258 } | 265 } |
| 259 return result; | 266 return result; |
| 260 } | 267 } |
| 261 | 268 |
| 262 int HttpStreamParser::DoReadHeaders() { | 269 int HttpStreamParser::DoReadHeaders() { |
| (...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 630 void HttpStreamParser::GetSSLCertRequestInfo( | 637 void HttpStreamParser::GetSSLCertRequestInfo( |
| 631 SSLCertRequestInfo* cert_request_info) { | 638 SSLCertRequestInfo* cert_request_info) { |
| 632 if (request_->url.SchemeIs("https") && connection_->socket()) { | 639 if (request_->url.SchemeIs("https") && connection_->socket()) { |
| 633 SSLClientSocket* ssl_socket = | 640 SSLClientSocket* ssl_socket = |
| 634 static_cast<SSLClientSocket*>(connection_->socket()); | 641 static_cast<SSLClientSocket*>(connection_->socket()); |
| 635 ssl_socket->GetSSLCertRequestInfo(cert_request_info); | 642 ssl_socket->GetSSLCertRequestInfo(cert_request_info); |
| 636 } | 643 } |
| 637 } | 644 } |
| 638 | 645 |
| 639 } // namespace net | 646 } // namespace net |
| OLD | NEW |