Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(519)

Side by Side Diff: net/http/http_stream.h

Issue 249031: Refactor HttpNetworkTransaction: Parse stream in HttpStream (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/http/http_network_transaction_unittest.cc ('k') | net/http/http_stream_parser.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 // 4 //
5 // HttpStream is an interface for reading and writing data to an HttpStream that 5 // HttpStream is an interface for reading and writing data to an HttpStream that
6 // keeps the client agnostic of the actual underlying transport layer. This 6 // keeps the client agnostic of the actual underlying transport layer. This
7 // provides an abstraction for both a basic http stream as well as http 7 // provides an abstraction for both a basic http stream as well as http
8 // pipelining implementations. 8 // pipelining implementations.
9 //
10 // NOTE(willchan): This interface is a work in progress. It will most likely
11 // change, since for a pipelining implementation, the stream needs to contain
12 // the http parsing code. For symmetry, the writing methods will probably
13 // contain the code for constructing http requests.
14 9
15 #ifndef NET_HTTP_HTTP_STREAM_H_ 10 #ifndef NET_HTTP_HTTP_STREAM_H_
16 #define NET_HTTP_HTTP_STREAM_H_ 11 #define NET_HTTP_HTTP_STREAM_H_
17 12
13 #include <string>
14
18 #include "base/basictypes.h" 15 #include "base/basictypes.h"
19 #include "net/base/completion_callback.h" 16 #include "net/socket/client_socket_handle.h"
20 17
21 namespace net { 18 namespace net {
22 19
20 class HttpRequestInfo;
21 class HttpResponseInfo;
23 class IOBuffer; 22 class IOBuffer;
23 class UploadDataStream;
24 24
25 class HttpStream { 25 class HttpStream {
26 public: 26 public:
27 HttpStream() {} 27 HttpStream() {}
28 virtual ~HttpStream() {} 28 virtual ~HttpStream() {}
29 29
30 // Reads data, up to buf_len bytes, from the socket. The number of bytes 30 // Writes the headers and uploads body data to the underlying socket.
31 // read is returned, or an error is returned upon failure. Zero is returned 31 // ERR_IO_PENDING is returned if the operation could not be completed
32 // to indicate end-of-file. ERR_IO_PENDING is returned if the operation 32 // synchronously, in which case the result will be passed to the callback
33 // could not be completed synchronously, in which case the result will be 33 // when available. Returns OK on success. The HttpStream takes ownership
34 // passed to the callback when available. If the operation is not completed 34 // of the request_body.
35 // immediately, the socket acquires a reference to the provided buffer until 35 virtual int SendRequest(const HttpRequestInfo* request,
36 // the callback is invoked or the socket is destroyed. 36 const std::string& request_headers,
37 virtual int Read(IOBuffer* buf, 37 UploadDataStream* request_body,
38 int buf_len, 38 CompletionCallback* callback) = 0;
39 CompletionCallback* callback) = 0;
40 39
41 // Writes data, up to buf_len bytes, to the socket. Note: only part of the 40 // Queries the UploadDataStream for its progress (bytes sent).
42 // data may be written! The number of bytes written is returned, or an error 41 virtual uint64 GetUploadProgress() const = 0;
43 // is returned upon failure. ERR_IO_PENDING is returned if the operation 42
44 // could not be completed synchronously, in which case the result will be 43 // Reads from the underlying socket until the response headers have been
45 // passed to the callback when available. If the operation is not completed 44 // completely received. ERR_IO_PENDING is returned if the operation could
46 // immediately, the socket acquires a reference to the provided buffer until 45 // not be completed synchronously, in which case the result will be passed
47 // the callback is invoked or the socket is destroyed. 46 // to the callback when available. Returns OK on success. The response
48 // Implementations of this method should not modify the contents of the actual 47 // headers are available in the HttpResponseInfo returned by GetResponseInfo
49 // buffer that is written to the socket. 48 virtual int ReadResponseHeaders(CompletionCallback* callback) = 0;
50 virtual int Write(IOBuffer* buf, 49
51 int buf_len, 50 // Provides access to HttpResponseInfo (owned by HttpStream).
52 CompletionCallback* callback) = 0; 51 virtual HttpResponseInfo* GetResponseInfo() const = 0;
52
53 // Reads response body data, up to |buf_len| bytes. The number of bytes read
54 // is returned, or an error is returned upon failure. ERR_CONNECTION_CLOSED
55 // is returned to indicate end-of-connection. ERR_IO_PENDING is returned if
56 // the operation could not be completed synchronously, in which case the
57 // result will be passed to the callback when available. If the operation is
58 // not completed immediately, the socket acquires a reference to the provided
59 // buffer until the callback is invoked or the socket is destroyed.
60 virtual int ReadResponseBody(IOBuffer* buf, int buf_len,
61 CompletionCallback* callback) = 0;
62
63 // Indicates if the response body has been completely read.
64 virtual bool IsResponseBodyComplete() const = 0;
65
66 // Indicates that the end of the response is detectable. This means that
67 // the response headers indicate either chunked encoding or content length.
68 // If neither is sent, the server must close the connection for us to detect
69 // the end of the response.
70 virtual bool CanFindEndOfResponse() const = 0;
71
72 // After the response headers have been read and after the response body
73 // is complete, this function indicates if more data (either erroneous or
74 // as part of the next pipelined response) has been read from the socket.
75 virtual bool IsMoreDataBuffered() const = 0;
53 76
54 private: 77 private:
55 DISALLOW_COPY_AND_ASSIGN(HttpStream); 78 DISALLOW_COPY_AND_ASSIGN(HttpStream);
56 }; 79 };
57 80
58 } // namespace net 81 } // namespace net
59 82
60 #endif // NET_HTTP_HTTP_STREAM_H_ 83 #endif // NET_HTTP_HTTP_STREAM_H_
OLDNEW
« no previous file with comments | « net/http/http_network_transaction_unittest.cc ('k') | net/http/http_stream_parser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698