OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "net/http/http_pipelined_stream.h" |
| 6 |
| 7 #include "base/logging.h" |
| 8 #include "base/stringprintf.h" |
| 9 #include "net/base/net_errors.h" |
| 10 #include "net/http/http_pipelined_connection.h" |
| 11 #include "net/http/http_request_headers.h" |
| 12 #include "net/http/http_request_info.h" |
| 13 #include "net/http/http_util.h" |
| 14 |
| 15 namespace net { |
| 16 |
| 17 HttpPipelinedStream::HttpPipelinedStream(HttpPipelinedConnection* pipeline) |
| 18 : pipeline_(pipeline), |
| 19 pipeline_id_(0), |
| 20 request_info_(NULL) { |
| 21 pipeline_id_ = pipeline_->AddStream(); |
| 22 } |
| 23 |
| 24 HttpPipelinedStream::~HttpPipelinedStream() { |
| 25 pipeline_->RemoveStream(pipeline_id_); |
| 26 } |
| 27 |
| 28 int HttpPipelinedStream::InitializeStream(const HttpRequestInfo* request_info, |
| 29 const BoundNetLog& net_log, |
| 30 CompletionCallback* callback) { |
| 31 request_info_ = request_info; |
| 32 pipeline_->InitializeParser(pipeline_id_, request_info, net_log); |
| 33 return OK; |
| 34 } |
| 35 |
| 36 |
| 37 int HttpPipelinedStream::SendRequest(const HttpRequestHeaders& headers, |
| 38 UploadDataStream* request_body, |
| 39 HttpResponseInfo* response, |
| 40 CompletionCallback* callback) { |
| 41 DCHECK(pipeline_id_); |
| 42 DCHECK(request_info_); |
| 43 // TODO(simonjam): Proxy support will be needed here. |
| 44 const std::string path = HttpUtil::PathForRequest(request_info_->url); |
| 45 std::string request_line_ = base::StringPrintf("%s %s HTTP/1.1\r\n", |
| 46 request_info_->method.c_str(), |
| 47 path.c_str()); |
| 48 return pipeline_->SendRequest(pipeline_id_, request_line_, headers, |
| 49 request_body, response, callback); |
| 50 } |
| 51 |
| 52 uint64 HttpPipelinedStream::GetUploadProgress() const { |
| 53 return pipeline_->GetUploadProgress(pipeline_id_); |
| 54 } |
| 55 |
| 56 int HttpPipelinedStream::ReadResponseHeaders(CompletionCallback* callback) { |
| 57 return pipeline_->ReadResponseHeaders(pipeline_id_, callback); |
| 58 } |
| 59 |
| 60 const HttpResponseInfo* HttpPipelinedStream::GetResponseInfo() const { |
| 61 return pipeline_->GetResponseInfo(pipeline_id_); |
| 62 } |
| 63 |
| 64 int HttpPipelinedStream::ReadResponseBody(IOBuffer* buf, int buf_len, |
| 65 CompletionCallback* callback) { |
| 66 return pipeline_->ReadResponseBody(pipeline_id_, buf, buf_len, callback); |
| 67 } |
| 68 |
| 69 void HttpPipelinedStream::Close(bool not_reusable) { |
| 70 pipeline_->Close(pipeline_id_, not_reusable); |
| 71 } |
| 72 |
| 73 HttpStream* HttpPipelinedStream::RenewStreamForAuth() { |
| 74 // FIXME: What does this mean on a pipeline? Is it for proxies? |
| 75 return new HttpPipelinedStream(pipeline_); |
| 76 } |
| 77 |
| 78 bool HttpPipelinedStream::IsResponseBodyComplete() const { |
| 79 return pipeline_->IsResponseBodyComplete(pipeline_id_); |
| 80 } |
| 81 |
| 82 bool HttpPipelinedStream::CanFindEndOfResponse() const { |
| 83 return pipeline_->CanFindEndOfResponse(pipeline_id_); |
| 84 } |
| 85 |
| 86 bool HttpPipelinedStream::IsMoreDataBuffered() const { |
| 87 return pipeline_->IsMoreDataBuffered(pipeline_id_); |
| 88 } |
| 89 |
| 90 bool HttpPipelinedStream::IsConnectionReused() const { |
| 91 return pipeline_->IsConnectionReused(pipeline_id_); |
| 92 } |
| 93 |
| 94 void HttpPipelinedStream::SetConnectionReused() { |
| 95 pipeline_->SetConnectionReused(pipeline_id_); |
| 96 } |
| 97 |
| 98 bool HttpPipelinedStream::IsConnectionReusable() const { |
| 99 return pipeline_->usable(); |
| 100 } |
| 101 |
| 102 void HttpPipelinedStream::GetSSLInfo(SSLInfo* ssl_info) { |
| 103 pipeline_->GetSSLInfo(pipeline_id_, ssl_info); |
| 104 } |
| 105 |
| 106 void HttpPipelinedStream::GetSSLCertRequestInfo( |
| 107 SSLCertRequestInfo* cert_request_info) { |
| 108 pipeline_->GetSSLCertRequestInfo(pipeline_id_, cert_request_info); |
| 109 } |
| 110 |
| 111 bool HttpPipelinedStream::IsSpdyHttpStream() const { |
| 112 return false; |
| 113 } |
| 114 |
| 115 void HttpPipelinedStream::LogNumRttVsBytesMetrics() const { |
| 116 // TODO(simonjam): I don't want to copy & paste this from http_basic_stream. |
| 117 } |
| 118 |
| 119 } // namespace net |
OLD | NEW |