| 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 HttpStreamParser* parser, | 19 HttpStreamParser* parser, |
| 20 bool using_proxy) | 20 bool using_proxy) |
| 21 : read_buf_(new GrowableIOBuffer()), | 21 : read_buf_(new GrowableIOBuffer()), |
| 22 parser_(parser), | 22 parser_(parser), |
| 23 connection_(connection), | 23 connection_(connection), |
| 24 using_proxy_(using_proxy), | 24 using_proxy_(using_proxy), |
| 25 request_info_(NULL) { | 25 request_info_(NULL) { |
| 26 } | 26 } |
| 27 | 27 |
| 28 HttpBasicStream::~HttpBasicStream() {} |
| 29 |
| 28 int HttpBasicStream::InitializeStream(const HttpRequestInfo* request_info, | 30 int HttpBasicStream::InitializeStream(const HttpRequestInfo* request_info, |
| 29 const BoundNetLog& net_log, | 31 const BoundNetLog& net_log, |
| 30 CompletionCallback* callback) { | 32 CompletionCallback* callback) { |
| 31 DCHECK(!parser_.get()); | 33 DCHECK(!parser_.get()); |
| 32 request_info_ = request_info; | 34 request_info_ = request_info; |
| 33 parser_.reset(new HttpStreamParser(connection_.get(), request_info, | 35 parser_.reset(new HttpStreamParser(connection_.get(), request_info, |
| 34 read_buf_, net_log)); | 36 read_buf_, net_log)); |
| 35 return OK; | 37 return OK; |
| 36 } | 38 } |
| 37 | 39 |
| 38 | 40 |
| 39 int HttpBasicStream::SendRequest(const HttpRequestHeaders& headers, | 41 int HttpBasicStream::SendRequest(const HttpRequestHeaders& headers, |
| 40 UploadDataStream* request_body, | 42 UploadDataStream* request_body, |
| 41 HttpResponseInfo* response, | 43 HttpResponseInfo* response, |
| 42 CompletionCallback* callback) { | 44 CompletionCallback* callback) { |
| 43 DCHECK(parser_.get()); | 45 DCHECK(parser_.get()); |
| 44 DCHECK(request_info_); | 46 DCHECK(request_info_); |
| 45 const std::string path = using_proxy_ ? | 47 const std::string path = using_proxy_ ? |
| 46 HttpUtil::SpecForRequest(request_info_->url) : | 48 HttpUtil::SpecForRequest(request_info_->url) : |
| 47 HttpUtil::PathForRequest(request_info_->url); | 49 HttpUtil::PathForRequest(request_info_->url); |
| 48 request_line_ = base::StringPrintf("%s %s HTTP/1.1\r\n", | 50 request_line_ = base::StringPrintf("%s %s HTTP/1.1\r\n", |
| 49 request_info_->method.c_str(), | 51 request_info_->method.c_str(), |
| 50 path.c_str()); | 52 path.c_str()); |
| 51 return parser_->SendRequest(request_line_, headers, request_body, response, | 53 return parser_->SendRequest(request_line_, headers, request_body, response, |
| 52 callback); | 54 callback); |
| 53 } | 55 } |
| 54 | 56 |
| 55 HttpBasicStream::~HttpBasicStream() {} | |
| 56 | |
| 57 uint64 HttpBasicStream::GetUploadProgress() const { | 57 uint64 HttpBasicStream::GetUploadProgress() const { |
| 58 return parser_->GetUploadProgress(); | 58 return parser_->GetUploadProgress(); |
| 59 } | 59 } |
| 60 | 60 |
| 61 int HttpBasicStream::ReadResponseHeaders(CompletionCallback* callback) { | 61 int HttpBasicStream::ReadResponseHeaders(CompletionCallback* callback) { |
| 62 return parser_->ReadResponseHeaders(callback); | 62 return parser_->ReadResponseHeaders(callback); |
| 63 } | 63 } |
| 64 | 64 |
| 65 const HttpResponseInfo* HttpBasicStream::GetResponseInfo() const { | 65 const HttpResponseInfo* HttpBasicStream::GetResponseInfo() const { |
| 66 return parser_->GetResponseInfo(); | 66 return parser_->GetResponseInfo(); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 void HttpBasicStream::GetSSLInfo(SSLInfo* ssl_info) { | 105 void HttpBasicStream::GetSSLInfo(SSLInfo* ssl_info) { |
| 106 parser_->GetSSLInfo(ssl_info); | 106 parser_->GetSSLInfo(ssl_info); |
| 107 } | 107 } |
| 108 | 108 |
| 109 void HttpBasicStream::GetSSLCertRequestInfo( | 109 void HttpBasicStream::GetSSLCertRequestInfo( |
| 110 SSLCertRequestInfo* cert_request_info) { | 110 SSLCertRequestInfo* cert_request_info) { |
| 111 parser_->GetSSLCertRequestInfo(cert_request_info); | 111 parser_->GetSSLCertRequestInfo(cert_request_info); |
| 112 } | 112 } |
| 113 | 113 |
| 114 } // namespace net | 114 } // namespace net |
| OLD | NEW |