[email protected] | 8d5a34e | 2009-06-11 21:21:36 | [diff] [blame] | 1 | // Copyright (c) 2009 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 | // 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_ | ||||
11 | |||||
[email protected] | 0877e3d | 2009-10-17 22:29:57 | [diff] [blame] | 12 | #include <string> |
13 | |||||
[email protected] | 8d5a34e | 2009-06-11 21:21:36 | [diff] [blame] | 14 | #include "base/basictypes.h" |
[email protected] | 0877e3d | 2009-10-17 22:29:57 | [diff] [blame] | 15 | #include "net/base/io_buffer.h" |
[email protected] | 8d5a34e | 2009-06-11 21:21:36 | [diff] [blame] | 16 | #include "net/http/http_stream.h" |
[email protected] | 0877e3d | 2009-10-17 22:29:57 | [diff] [blame] | 17 | #include "net/http/http_stream_parser.h" |
[email protected] | 8d5a34e | 2009-06-11 21:21:36 | [diff] [blame] | 18 | |
19 | namespace net { | ||||
20 | |||||
[email protected] | 9e743cd | 2010-03-16 07:03:53 | [diff] [blame] | 21 | class BoundNetLog; |
[email protected] | 0877e3d | 2009-10-17 22:29:57 | [diff] [blame] | 22 | class ClientSocketHandle; |
[email protected] | 8c76ae2 | 2010-04-20 22:15:43 | [diff] [blame] | 23 | struct HttpRequestInfo; |
[email protected] | 0877e3d | 2009-10-17 22:29:57 | [diff] [blame] | 24 | class HttpResponseInfo; |
25 | class UploadDataStream; | ||||
26 | |||||
[email protected] | 8d5a34e | 2009-06-11 21:21:36 | [diff] [blame] | 27 | class HttpBasicStream : public HttpStream { |
28 | public: | ||||
[email protected] | 9e743cd | 2010-03-16 07:03:53 | [diff] [blame] | 29 | HttpBasicStream(ClientSocketHandle* handle, const BoundNetLog& net_log); |
[email protected] | 6d22a97 | 2010-07-21 15:47:19 | [diff] [blame^] | 30 | virtual ~HttpBasicStream(); |
[email protected] | 8d5a34e | 2009-06-11 21:21:36 | [diff] [blame] | 31 | |
32 | // HttpStream methods: | ||||
[email protected] | 0877e3d | 2009-10-17 22:29:57 | [diff] [blame] | 33 | virtual int SendRequest(const HttpRequestInfo* request, |
34 | const std::string& headers, | ||||
35 | UploadDataStream* request_body, | ||||
[email protected] | a7e4131 | 2009-12-16 23:18:14 | [diff] [blame] | 36 | HttpResponseInfo* response, |
[email protected] | 0877e3d | 2009-10-17 22:29:57 | [diff] [blame] | 37 | CompletionCallback* callback); |
[email protected] | 8d5a34e | 2009-06-11 21:21:36 | [diff] [blame] | 38 | |
[email protected] | 0877e3d | 2009-10-17 22:29:57 | [diff] [blame] | 39 | virtual uint64 GetUploadProgress() const; |
40 | |||||
41 | virtual int ReadResponseHeaders(CompletionCallback* callback); | ||||
42 | |||||
43 | virtual HttpResponseInfo* GetResponseInfo() const; | ||||
44 | |||||
45 | virtual int ReadResponseBody(IOBuffer* buf, int buf_len, | ||||
46 | CompletionCallback* callback); | ||||
47 | |||||
48 | virtual bool IsResponseBodyComplete() const; | ||||
49 | |||||
50 | virtual bool CanFindEndOfResponse() const; | ||||
51 | |||||
52 | virtual bool IsMoreDataBuffered() const; | ||||
[email protected] | 8d5a34e | 2009-06-11 21:21:36 | [diff] [blame] | 53 | |
54 | private: | ||||
[email protected] | 0877e3d | 2009-10-17 22:29:57 | [diff] [blame] | 55 | scoped_refptr<GrowableIOBuffer> read_buf_; |
56 | |||||
57 | scoped_ptr<HttpStreamParser> parser_; | ||||
[email protected] | 8d5a34e | 2009-06-11 21:21:36 | [diff] [blame] | 58 | |
59 | DISALLOW_COPY_AND_ASSIGN(HttpBasicStream); | ||||
60 | }; | ||||
61 | |||||
62 | } // namespace net | ||||
63 | |||||
64 | #endif // NET_HTTP_HTTP_BASIC_STREAM_H_ |