• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 // 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 #pragma once
12 
13 #include <string>
14 
15 #include "base/basictypes.h"
16 #include "base/memory/scoped_ptr.h"
17 #include "net/http/http_stream.h"
18 
19 namespace net {
20 
21 class BoundNetLog;
22 class ClientSocketHandle;
23 class GrowableIOBuffer;
24 class HttpResponseInfo;
25 struct HttpRequestInfo;
26 class HttpRequestHeaders;
27 class HttpStreamParser;
28 class IOBuffer;
29 class UploadDataStream;
30 
31 class HttpBasicStream : public HttpStream {
32  public:
33   // 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);
40   virtual ~HttpBasicStream();
41 
42   // HttpStream methods:
43   virtual int InitializeStream(const HttpRequestInfo* request_info,
44                                const BoundNetLog& net_log,
45                                CompletionCallback* callback) OVERRIDE;
46 
47   virtual int SendRequest(const HttpRequestHeaders& headers,
48                           UploadDataStream* request_body,
49                           HttpResponseInfo* response,
50                           CompletionCallback* callback) OVERRIDE;
51 
52   virtual uint64 GetUploadProgress() const OVERRIDE;
53 
54   virtual int ReadResponseHeaders(CompletionCallback* callback) OVERRIDE;
55 
56   virtual const HttpResponseInfo* GetResponseInfo() const OVERRIDE;
57 
58   virtual int ReadResponseBody(IOBuffer* buf, int buf_len,
59                                CompletionCallback* callback) OVERRIDE;
60 
61   virtual void Close(bool not_reusable) OVERRIDE;
62 
63   virtual HttpStream* RenewStreamForAuth() OVERRIDE;
64 
65   virtual bool IsResponseBodyComplete() const OVERRIDE;
66 
67   virtual bool CanFindEndOfResponse() const OVERRIDE;
68 
69   virtual bool IsMoreDataBuffered() const OVERRIDE;
70 
71   virtual bool IsConnectionReused() const OVERRIDE;
72 
73   virtual void SetConnectionReused() OVERRIDE;
74 
75   virtual bool IsConnectionReusable() const OVERRIDE;
76 
77   virtual void GetSSLInfo(SSLInfo* ssl_info) OVERRIDE;
78 
79   virtual void GetSSLCertRequestInfo(
80       SSLCertRequestInfo* cert_request_info) OVERRIDE;
81 
82   virtual bool IsSpdyHttpStream() const OVERRIDE;
83 
84  private:
85   scoped_refptr<GrowableIOBuffer> read_buf_;
86 
87   scoped_ptr<HttpStreamParser> parser_;
88 
89   scoped_ptr<ClientSocketHandle> connection_;
90 
91   bool using_proxy_;
92 
93   std::string request_line_;
94 
95   const HttpRequestInfo* request_info_;
96 
97   DISALLOW_COPY_AND_ASSIGN(HttpBasicStream);
98 };
99 
100 }  // namespace net
101 
102 #endif  // NET_HTTP_HTTP_BASIC_STREAM_H_
103