OLD | NEW |
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 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_basic_stream.h" | 5 #include "net/http/http_basic_stream.h" |
6 | 6 |
7 #include "base/stringprintf.h" | 7 #include "base/stringprintf.h" |
8 #include "net/base/io_buffer.h" | 8 #include "net/base/io_buffer.h" |
9 #include "net/base/net_errors.h" | 9 #include "net/base/net_errors.h" |
10 #include "net/http/http_request_headers.h" | 10 #include "net/http/http_request_headers.h" |
11 #include "net/http/http_request_info.h" | 11 #include "net/http/http_request_info.h" |
12 #include "net/http/http_stream_parser.h" | 12 #include "net/http/http_stream_parser.h" |
13 #include "net/http/http_util.h" | 13 #include "net/http/http_util.h" |
14 #include "net/socket/client_socket_handle.h" | 14 #include "net/socket/client_socket_handle.h" |
15 | 15 |
16 namespace net { | 16 namespace net { |
17 | 17 |
18 HttpBasicStream::HttpBasicStream(ClientSocketHandle* connection, | 18 HttpBasicStream::HttpBasicStream(ClientSocketHandle* connection, |
19 bool using_proxy) | 19 bool using_proxy) |
20 : read_buf_(new GrowableIOBuffer()), | 20 : read_buf_(new GrowableIOBuffer()), |
21 connection_(connection), | 21 connection_(connection), |
22 using_proxy_(using_proxy), | 22 using_proxy_(using_proxy), |
23 request_info_(NULL) { | 23 request_info_(NULL) { |
24 } | 24 } |
25 | 25 |
| 26 HttpBasicStream::HttpBasicStream(HttpStreamParser* parser, |
| 27 ClientSocketHandle* connection) |
| 28 : parser_(parser), |
| 29 connection_(connection), |
| 30 using_proxy_(false), |
| 31 request_info_(NULL) { |
| 32 } |
| 33 |
26 int HttpBasicStream::InitializeStream(const HttpRequestInfo* request_info, | 34 int HttpBasicStream::InitializeStream(const HttpRequestInfo* request_info, |
27 const BoundNetLog& net_log, | 35 const BoundNetLog& net_log, |
28 CompletionCallback* callback) { | 36 CompletionCallback* callback) { |
| 37 DCHECK(!parser_.get()); |
29 request_info_ = request_info; | 38 request_info_ = request_info; |
30 parser_.reset(new HttpStreamParser(connection_.get(), request_info, | 39 parser_.reset(new HttpStreamParser(connection_.get(), request_info, |
31 read_buf_, net_log)); | 40 read_buf_, net_log)); |
32 return OK; | 41 return OK; |
33 } | 42 } |
34 | 43 |
35 | 44 |
36 int HttpBasicStream::SendRequest(const HttpRequestHeaders& headers, | 45 int HttpBasicStream::SendRequest(const HttpRequestHeaders& headers, |
37 UploadDataStream* request_body, | 46 UploadDataStream* request_body, |
38 HttpResponseInfo* response, | 47 HttpResponseInfo* response, |
39 CompletionCallback* callback) { | 48 CompletionCallback* callback) { |
40 DCHECK(parser_.get()); | 49 DCHECK(parser_.get()); |
| 50 DCHECK(request_info_); |
41 const std::string path = using_proxy_ ? | 51 const std::string path = using_proxy_ ? |
42 HttpUtil::SpecForRequest(request_info_->url) : | 52 HttpUtil::SpecForRequest(request_info_->url) : |
43 HttpUtil::PathForRequest(request_info_->url); | 53 HttpUtil::PathForRequest(request_info_->url); |
44 request_line_ = base::StringPrintf("%s %s HTTP/1.1\r\n", | 54 request_line_ = base::StringPrintf("%s %s HTTP/1.1\r\n", |
45 request_info_->method.c_str(), | 55 request_info_->method.c_str(), |
46 path.c_str()); | 56 path.c_str()); |
47 return parser_->SendRequest(request_line_, headers, request_body, response, | 57 return parser_->SendRequest(request_line_, headers, request_body, response, |
48 callback); | 58 callback); |
49 } | 59 } |
50 | 60 |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 void HttpBasicStream::GetSSLInfo(SSLInfo* ssl_info) { | 111 void HttpBasicStream::GetSSLInfo(SSLInfo* ssl_info) { |
102 parser_->GetSSLInfo(ssl_info); | 112 parser_->GetSSLInfo(ssl_info); |
103 } | 113 } |
104 | 114 |
105 void HttpBasicStream::GetSSLCertRequestInfo( | 115 void HttpBasicStream::GetSSLCertRequestInfo( |
106 SSLCertRequestInfo* cert_request_info) { | 116 SSLCertRequestInfo* cert_request_info) { |
107 parser_->GetSSLCertRequestInfo(cert_request_info); | 117 parser_->GetSSLCertRequestInfo(cert_request_info); |
108 } | 118 } |
109 | 119 |
110 } // namespace net | 120 } // namespace net |
OLD | NEW |