blob: c6c760310a8bad6d5767bddb61b4210f20f8ce24 [file] [log] [blame]
[email protected]5f9205f2012-06-14 19:55:231// Copyright (c) 2012 The Chromium Authors. All rights reserved.
[email protected]8d5a34e2009-06-11 21:21:362// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4//
5// HttpBasicStream is a simple implementation of HttpStream. It assumes it is
6// not sharing a sharing with any other HttpStreams, therefore it just reads and
7// writes directly to the Http Stream.
8
9#ifndef NET_HTTP_HTTP_BASIC_STREAM_H_
10#define NET_HTTP_HTTP_BASIC_STREAM_H_
[email protected]32b76ef2010-07-26 23:08:2411#pragma once
[email protected]8d5a34e2009-06-11 21:21:3612
[email protected]0877e3d2009-10-17 22:29:5713#include <string>
14
[email protected]8d5a34e2009-06-11 21:21:3615#include "base/basictypes.h"
[email protected]8d5a34e2009-06-11 21:21:3616#include "net/http/http_stream.h"
[email protected]8d5a34e2009-06-11 21:21:3617
18namespace net {
19
[email protected]9e743cd2010-03-16 07:03:5320class BoundNetLog;
[email protected]0877e3d2009-10-17 22:29:5721class ClientSocketHandle;
[email protected]277d5942010-08-11 21:02:3522class GrowableIOBuffer;
[email protected]0877e3d2009-10-17 22:29:5723class HttpResponseInfo;
[email protected]277d5942010-08-11 21:02:3524struct HttpRequestInfo;
[email protected]b94f92d2010-10-27 16:45:2025class HttpRequestHeaders;
[email protected]277d5942010-08-11 21:02:3526class HttpStreamParser;
27class IOBuffer;
[email protected]0877e3d2009-10-17 22:29:5728class UploadDataStream;
29
[email protected]8d5a34e2009-06-11 21:21:3630class HttpBasicStream : public HttpStream {
31 public:
[email protected]511f6f52010-12-17 03:58:2932 // Constructs a new HttpBasicStream. If |parser| is NULL, then
33 // InitializeStream should be called to initialize it correctly. If
34 // |parser| is non-null, then InitializeStream should not be called,
35 // as the stream is already initialized.
36 HttpBasicStream(ClientSocketHandle* connection,
37 HttpStreamParser* parser,
38 bool using_proxy);
[email protected]6d22a972010-07-21 15:47:1939 virtual ~HttpBasicStream();
[email protected]8d5a34e2009-06-11 21:21:3640
41 // HttpStream methods:
[email protected]c638a85a2010-07-29 18:41:4042 virtual int InitializeStream(const HttpRequestInfo* request_info,
43 const BoundNetLog& net_log,
[email protected]49639fa2011-12-20 23:22:4144 const CompletionCallback& callback) OVERRIDE;
[email protected]c638a85a2010-07-29 18:41:4045
[email protected]b94f92d2010-10-27 16:45:2046 virtual int SendRequest(const HttpRequestHeaders& headers,
[email protected]5f9205f2012-06-14 19:55:2347 scoped_ptr<UploadDataStream> request_body,
[email protected]a7e41312009-12-16 23:18:1448 HttpResponseInfo* response,
[email protected]49639fa2011-12-20 23:22:4149 const CompletionCallback& callback) OVERRIDE;
[email protected]8d5a34e2009-06-11 21:21:3650
[email protected]2d0a4f92011-05-05 16:38:4651 virtual uint64 GetUploadProgress() const OVERRIDE;
[email protected]0877e3d2009-10-17 22:29:5752
[email protected]49639fa2011-12-20 23:22:4153 virtual int ReadResponseHeaders(const CompletionCallback& callback) OVERRIDE;
[email protected]0877e3d2009-10-17 22:29:5754
[email protected]2d0a4f92011-05-05 16:38:4655 virtual const HttpResponseInfo* GetResponseInfo() const OVERRIDE;
[email protected]0877e3d2009-10-17 22:29:5756
57 virtual int ReadResponseBody(IOBuffer* buf, int buf_len,
[email protected]49639fa2011-12-20 23:22:4158 const CompletionCallback& callback) OVERRIDE;
[email protected]0877e3d2009-10-17 22:29:5759
[email protected]2d0a4f92011-05-05 16:38:4660 virtual void Close(bool not_reusable) OVERRIDE;
[email protected]8e6441ca2010-08-19 05:56:3861
[email protected]2d0a4f92011-05-05 16:38:4662 virtual HttpStream* RenewStreamForAuth() OVERRIDE;
[email protected]697ef4c2010-10-14 16:38:5863
[email protected]2d0a4f92011-05-05 16:38:4664 virtual bool IsResponseBodyComplete() const OVERRIDE;
[email protected]0877e3d2009-10-17 22:29:5765
[email protected]2d0a4f92011-05-05 16:38:4666 virtual bool CanFindEndOfResponse() const OVERRIDE;
[email protected]0877e3d2009-10-17 22:29:5767
[email protected]2d0a4f92011-05-05 16:38:4668 virtual bool IsMoreDataBuffered() const OVERRIDE;
[email protected]8d5a34e2009-06-11 21:21:3669
[email protected]2d0a4f92011-05-05 16:38:4670 virtual bool IsConnectionReused() const OVERRIDE;
[email protected]8e6441ca2010-08-19 05:56:3871
[email protected]2d0a4f92011-05-05 16:38:4672 virtual void SetConnectionReused() OVERRIDE;
[email protected]8e6441ca2010-08-19 05:56:3873
[email protected]2d0a4f92011-05-05 16:38:4674 virtual bool IsConnectionReusable() const OVERRIDE;
[email protected]8e6441ca2010-08-19 05:56:3875
[email protected]2d0a4f92011-05-05 16:38:4676 virtual void GetSSLInfo(SSLInfo* ssl_info) OVERRIDE;
[email protected]8e6441ca2010-08-19 05:56:3877
[email protected]2d0a4f92011-05-05 16:38:4678 virtual void GetSSLCertRequestInfo(
79 SSLCertRequestInfo* cert_request_info) OVERRIDE;
80
81 virtual bool IsSpdyHttpStream() const OVERRIDE;
[email protected]3a8d6852011-03-11 23:43:4482
[email protected]5e6efa52011-06-27 17:26:4183 virtual void LogNumRttVsBytesMetrics() const OVERRIDE;
84
[email protected]5a60c8b2011-10-19 20:14:2985 virtual void Drain(HttpNetworkSession* session) OVERRIDE;
86
[email protected]8d5a34e2009-06-11 21:21:3687 private:
[email protected]0877e3d2009-10-17 22:29:5788 scoped_refptr<GrowableIOBuffer> read_buf_;
89
90 scoped_ptr<HttpStreamParser> parser_;
[email protected]8d5a34e2009-06-11 21:21:3691
[email protected]4d4a5162010-09-21 22:44:0492 scoped_ptr<ClientSocketHandle> connection_;
[email protected]c638a85a2010-07-29 18:41:4093
[email protected]b94f92d2010-10-27 16:45:2094 bool using_proxy_;
95
96 std::string request_line_;
97
98 const HttpRequestInfo* request_info_;
99
[email protected]5e6efa52011-06-27 17:26:41100 const HttpResponseInfo* response_;
101
102 int64 bytes_read_offset_;
103
[email protected]8d5a34e2009-06-11 21:21:36104 DISALLOW_COPY_AND_ASSIGN(HttpBasicStream);
105};
106
107} // namespace net
108
109#endif // NET_HTTP_HTTP_BASIC_STREAM_H_