blob: 80245768069076cb990f22a9a3a719791cbd6331 [file] [log] [blame]
[email protected]3b63f8f42011-03-28 01:54:151// Copyright (c) 2011 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]3b63f8f42011-03-28 01:54:1516#include "base/memory/scoped_ptr.h"
[email protected]8d5a34e2009-06-11 21:21:3617#include "net/http/http_stream.h"
[email protected]8d5a34e2009-06-11 21:21:3618
19namespace net {
20
[email protected]9e743cd2010-03-16 07:03:5321class BoundNetLog;
[email protected]0877e3d2009-10-17 22:29:5722class ClientSocketHandle;
[email protected]277d5942010-08-11 21:02:3523class GrowableIOBuffer;
[email protected]0877e3d2009-10-17 22:29:5724class HttpResponseInfo;
[email protected]277d5942010-08-11 21:02:3525struct HttpRequestInfo;
[email protected]b94f92d2010-10-27 16:45:2026class HttpRequestHeaders;
[email protected]277d5942010-08-11 21:02:3527class HttpStreamParser;
28class IOBuffer;
[email protected]0877e3d2009-10-17 22:29:5729class UploadDataStream;
30
[email protected]8d5a34e2009-06-11 21:21:3631class HttpBasicStream : public HttpStream {
32 public:
[email protected]511f6f52010-12-17 03:58:2933 // Constructs a new HttpBasicStream. If |parser| is NULL, then
34 // InitializeStream should be called to initialize it correctly. If
35 // |parser| is non-null, then InitializeStream should not be called,
36 // as the stream is already initialized.
37 HttpBasicStream(ClientSocketHandle* connection,
38 HttpStreamParser* parser,
39 bool using_proxy);
[email protected]6d22a972010-07-21 15:47:1940 virtual ~HttpBasicStream();
[email protected]8d5a34e2009-06-11 21:21:3641
42 // HttpStream methods:
[email protected]c638a85a2010-07-29 18:41:4043 virtual int InitializeStream(const HttpRequestInfo* request_info,
44 const BoundNetLog& net_log,
[email protected]f1f3f0f82011-10-01 20:38:1045 OldCompletionCallback* callback) OVERRIDE;
[email protected]c638a85a2010-07-29 18:41:4046
[email protected]b94f92d2010-10-27 16:45:2047 virtual int SendRequest(const HttpRequestHeaders& headers,
[email protected]0877e3d2009-10-17 22:29:5748 UploadDataStream* request_body,
[email protected]a7e41312009-12-16 23:18:1449 HttpResponseInfo* response,
[email protected]f1f3f0f82011-10-01 20:38:1050 OldCompletionCallback* callback) OVERRIDE;
[email protected]8d5a34e2009-06-11 21:21:3651
[email protected]2d0a4f92011-05-05 16:38:4652 virtual uint64 GetUploadProgress() const OVERRIDE;
[email protected]0877e3d2009-10-17 22:29:5753
[email protected]f1f3f0f82011-10-01 20:38:1054 virtual int ReadResponseHeaders(OldCompletionCallback* callback) OVERRIDE;
[email protected]0877e3d2009-10-17 22:29:5755
[email protected]2d0a4f92011-05-05 16:38:4656 virtual const HttpResponseInfo* GetResponseInfo() const OVERRIDE;
[email protected]0877e3d2009-10-17 22:29:5757
58 virtual int ReadResponseBody(IOBuffer* buf, int buf_len,
[email protected]f1f3f0f82011-10-01 20:38:1059 OldCompletionCallback* callback) OVERRIDE;
[email protected]0877e3d2009-10-17 22:29:5760
[email protected]2d0a4f92011-05-05 16:38:4661 virtual void Close(bool not_reusable) OVERRIDE;
[email protected]8e6441ca2010-08-19 05:56:3862
[email protected]2d0a4f92011-05-05 16:38:4663 virtual HttpStream* RenewStreamForAuth() OVERRIDE;
[email protected]697ef4c2010-10-14 16:38:5864
[email protected]2d0a4f92011-05-05 16:38:4665 virtual bool IsResponseBodyComplete() const OVERRIDE;
[email protected]0877e3d2009-10-17 22:29:5766
[email protected]2d0a4f92011-05-05 16:38:4667 virtual bool CanFindEndOfResponse() const OVERRIDE;
[email protected]0877e3d2009-10-17 22:29:5768
[email protected]2d0a4f92011-05-05 16:38:4669 virtual bool IsMoreDataBuffered() const OVERRIDE;
[email protected]8d5a34e2009-06-11 21:21:3670
[email protected]2d0a4f92011-05-05 16:38:4671 virtual bool IsConnectionReused() const OVERRIDE;
[email protected]8e6441ca2010-08-19 05:56:3872
[email protected]2d0a4f92011-05-05 16:38:4673 virtual void SetConnectionReused() OVERRIDE;
[email protected]8e6441ca2010-08-19 05:56:3874
[email protected]2d0a4f92011-05-05 16:38:4675 virtual bool IsConnectionReusable() const OVERRIDE;
[email protected]8e6441ca2010-08-19 05:56:3876
[email protected]2d0a4f92011-05-05 16:38:4677 virtual void GetSSLInfo(SSLInfo* ssl_info) OVERRIDE;
[email protected]8e6441ca2010-08-19 05:56:3878
[email protected]2d0a4f92011-05-05 16:38:4679 virtual void GetSSLCertRequestInfo(
80 SSLCertRequestInfo* cert_request_info) OVERRIDE;
81
82 virtual bool IsSpdyHttpStream() const OVERRIDE;
[email protected]3a8d6852011-03-11 23:43:4483
[email protected]5e6efa52011-06-27 17:26:4184 virtual void LogNumRttVsBytesMetrics() const OVERRIDE;
85
[email protected]5a60c8b2011-10-19 20:14:2986 virtual void Drain(HttpNetworkSession* session) OVERRIDE;
87
[email protected]8d5a34e2009-06-11 21:21:3688 private:
[email protected]0877e3d2009-10-17 22:29:5789 scoped_refptr<GrowableIOBuffer> read_buf_;
90
91 scoped_ptr<HttpStreamParser> parser_;
[email protected]8d5a34e2009-06-11 21:21:3692
[email protected]4d4a5162010-09-21 22:44:0493 scoped_ptr<ClientSocketHandle> connection_;
[email protected]c638a85a2010-07-29 18:41:4094
[email protected]b94f92d2010-10-27 16:45:2095 bool using_proxy_;
96
97 std::string request_line_;
98
99 const HttpRequestInfo* request_info_;
100
[email protected]5e6efa52011-06-27 17:26:41101 const HttpResponseInfo* response_;
102
103 int64 bytes_read_offset_;
104
[email protected]8d5a34e2009-06-11 21:21:36105 DISALLOW_COPY_AND_ASSIGN(HttpBasicStream);
106};
107
108} // namespace net
109
110#endif // NET_HTTP_HTTP_BASIC_STREAM_H_