| 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/address_list.h" |
| 9 #include "net/base/auth.h" | 10 #include "net/base/auth.h" |
| 10 #include "net/base/io_buffer.h" | 11 #include "net/base/io_buffer.h" |
| 11 #include "net/base/ssl_cert_request_info.h" | 12 #include "net/base/ssl_cert_request_info.h" |
| 12 #include "net/http/http_net_log_params.h" | 13 #include "net/http/http_net_log_params.h" |
| 13 #include "net/http/http_request_headers.h" | 14 #include "net/http/http_request_headers.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" |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 DCHECK(callback); | 59 DCHECK(callback); |
| 59 DCHECK(response); | 60 DCHECK(response); |
| 60 | 61 |
| 61 if (net_log_.IsLoggingAllEvents()) { | 62 if (net_log_.IsLoggingAllEvents()) { |
| 62 net_log_.AddEvent( | 63 net_log_.AddEvent( |
| 63 NetLog::TYPE_HTTP_TRANSACTION_SEND_REQUEST_HEADERS, | 64 NetLog::TYPE_HTTP_TRANSACTION_SEND_REQUEST_HEADERS, |
| 64 make_scoped_refptr(new NetLogHttpRequestParameter( | 65 make_scoped_refptr(new NetLogHttpRequestParameter( |
| 65 request_line, headers))); | 66 request_line, headers))); |
| 66 } | 67 } |
| 67 response_ = response; | 68 response_ = response; |
| 69 |
| 70 // Put the peer's IP address and port into the response. |
| 71 AddressList address; |
| 72 int result = connection_->socket()->GetPeerAddress(&address); |
| 73 if (result != OK) |
| 74 return result; |
| 75 response_->socket_address = HostPortPair::FromAddrInfo(address.head()); |
| 76 |
| 68 std::string request = request_line + headers.ToString(); | 77 std::string request = request_line + headers.ToString(); |
| 69 scoped_refptr<StringIOBuffer> headers_io_buf(new StringIOBuffer(request)); | 78 scoped_refptr<StringIOBuffer> headers_io_buf(new StringIOBuffer(request)); |
| 70 request_headers_ = new DrainableIOBuffer(headers_io_buf, | 79 request_headers_ = new DrainableIOBuffer(headers_io_buf, |
| 71 headers_io_buf->size()); | 80 headers_io_buf->size()); |
| 72 request_body_.reset(request_body); | 81 request_body_.reset(request_body); |
| 73 if (request_body_ != NULL && request_body_->is_chunked()) | 82 if (request_body_ != NULL && request_body_->is_chunked()) |
| 74 request_body_->set_chunk_callback(this); | 83 request_body_->set_chunk_callback(this); |
| 75 | 84 |
| 76 io_state_ = STATE_SENDING_HEADERS; | 85 io_state_ = STATE_SENDING_HEADERS; |
| 77 int result = DoLoop(OK); | 86 result = DoLoop(OK); |
| 78 if (result == ERR_IO_PENDING) | 87 if (result == ERR_IO_PENDING) |
| 79 user_callback_ = callback; | 88 user_callback_ = callback; |
| 80 | 89 |
| 81 return result > 0 ? OK : result; | 90 return result > 0 ? OK : result; |
| 82 } | 91 } |
| 83 | 92 |
| 84 int HttpStreamParser::ReadResponseHeaders(CompletionCallback* callback) { | 93 int HttpStreamParser::ReadResponseHeaders(CompletionCallback* callback) { |
| 85 DCHECK(io_state_ == STATE_REQUEST_SENT || io_state_ == STATE_DONE); | 94 DCHECK(io_state_ == STATE_REQUEST_SENT || io_state_ == STATE_DONE); |
| 86 DCHECK(!user_callback_); | 95 DCHECK(!user_callback_); |
| 87 DCHECK(callback); | 96 DCHECK(callback); |
| (...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 655 void HttpStreamParser::GetSSLCertRequestInfo( | 664 void HttpStreamParser::GetSSLCertRequestInfo( |
| 656 SSLCertRequestInfo* cert_request_info) { | 665 SSLCertRequestInfo* cert_request_info) { |
| 657 if (request_->url.SchemeIs("https") && connection_->socket()) { | 666 if (request_->url.SchemeIs("https") && connection_->socket()) { |
| 658 SSLClientSocket* ssl_socket = | 667 SSLClientSocket* ssl_socket = |
| 659 static_cast<SSLClientSocket*>(connection_->socket()); | 668 static_cast<SSLClientSocket*>(connection_->socket()); |
| 660 ssl_socket->GetSSLCertRequestInfo(cert_request_info); | 669 ssl_socket->GetSSLCertRequestInfo(cert_request_info); |
| 661 } | 670 } |
| 662 } | 671 } |
| 663 | 672 |
| 664 } // namespace net | 673 } // namespace net |
| OLD | NEW |