summaryrefslogtreecommitdiffstats
path: root/net/http/http_stream.h
diff options
context:
space:
mode:
authorvandebo@chromium.org <vandebo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-17 22:29:57 +0000
committervandebo@chromium.org <vandebo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-17 22:29:57 +0000
commit0877e3db672aa26d89549f545e6e6c64904fec4c (patch)
tree127ce4a310fd137427c1963dc6eb02410bcb235d /net/http/http_stream.h
parentb71e79d427311fdd9ec36ac5a122fc987bdb2020 (diff)
downloadchromium_src-0877e3db672aa26d89549f545e6e6c64904fec4c.zip
chromium_src-0877e3db672aa26d89549f545e6e6c64904fec4c.tar.gz
chromium_src-0877e3db672aa26d89549f545e6e6c64904fec4c.tar.bz2
Refactor HttpNetworkTransaction so that HttpStream is responsible for parsing the Http traffic. HttpBasicStream delegates parsing to HttpStreamParser in preparation for HttpPipelinedStream.
Original review: http://codereview.chromium.org/249031 BUG=13289 TEST=unittests Review URL: http://codereview.chromium.org/283022 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@29379 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/http/http_stream.h')
-rw-r--r--net/http/http_stream.h81
1 files changed, 52 insertions, 29 deletions
diff --git a/net/http/http_stream.h b/net/http/http_stream.h
index 361edb0..d0b9dc9 100644
--- a/net/http/http_stream.h
+++ b/net/http/http_stream.h
@@ -6,50 +6,73 @@
// keeps the client agnostic of the actual underlying transport layer. This
// provides an abstraction for both a basic http stream as well as http
// pipelining implementations.
-//
-// NOTE(willchan): This interface is a work in progress. It will most likely
-// change, since for a pipelining implementation, the stream needs to contain
-// the http parsing code. For symmetry, the writing methods will probably
-// contain the code for constructing http requests.
#ifndef NET_HTTP_HTTP_STREAM_H_
#define NET_HTTP_HTTP_STREAM_H_
+#include <string>
+
#include "base/basictypes.h"
-#include "net/base/completion_callback.h"
+#include "net/socket/client_socket_handle.h"
namespace net {
+class HttpRequestInfo;
+class HttpResponseInfo;
class IOBuffer;
+class UploadDataStream;
class HttpStream {
public:
HttpStream() {}
virtual ~HttpStream() {}
- // Reads data, up to buf_len bytes, from the socket. The number of bytes
- // read is returned, or an error is returned upon failure. Zero is returned
- // to indicate end-of-file. ERR_IO_PENDING is returned if the operation
- // could not be completed synchronously, in which case the result will be
- // passed to the callback when available. If the operation is not completed
- // immediately, the socket acquires a reference to the provided buffer until
- // the callback is invoked or the socket is destroyed.
- virtual int Read(IOBuffer* buf,
- int buf_len,
- CompletionCallback* callback) = 0;
-
- // Writes data, up to buf_len bytes, to the socket. Note: only part of the
- // data may be written! The number of bytes written is returned, or an error
- // is returned upon failure. ERR_IO_PENDING is returned if the operation
- // could not be completed synchronously, in which case the result will be
- // passed to the callback when available. If the operation is not completed
- // immediately, the socket acquires a reference to the provided buffer until
- // the callback is invoked or the socket is destroyed.
- // Implementations of this method should not modify the contents of the actual
- // buffer that is written to the socket.
- virtual int Write(IOBuffer* buf,
- int buf_len,
- CompletionCallback* callback) = 0;
+ // Writes the headers and uploads body data to the underlying socket.
+ // ERR_IO_PENDING is returned if the operation could not be completed
+ // synchronously, in which case the result will be passed to the callback
+ // when available. Returns OK on success. The HttpStream takes ownership
+ // of the request_body.
+ virtual int SendRequest(const HttpRequestInfo* request,
+ const std::string& request_headers,
+ UploadDataStream* request_body,
+ CompletionCallback* callback) = 0;
+
+ // Queries the UploadDataStream for its progress (bytes sent).
+ virtual uint64 GetUploadProgress() const = 0;
+
+ // Reads from the underlying socket until the response headers have been
+ // completely received. ERR_IO_PENDING is returned if the operation could
+ // not be completed synchronously, in which case the result will be passed
+ // to the callback when available. Returns OK on success. The response
+ // headers are available in the HttpResponseInfo returned by GetResponseInfo
+ virtual int ReadResponseHeaders(CompletionCallback* callback) = 0;
+
+ // Provides access to HttpResponseInfo (owned by HttpStream).
+ virtual HttpResponseInfo* GetResponseInfo() const = 0;
+
+ // Reads response body data, up to |buf_len| bytes. The number of bytes read
+ // is returned, or an error is returned upon failure. ERR_CONNECTION_CLOSED
+ // is returned to indicate end-of-connection. ERR_IO_PENDING is returned if
+ // the operation could not be completed synchronously, in which case the
+ // result will be passed to the callback when available. If the operation is
+ // not completed immediately, the socket acquires a reference to the provided
+ // buffer until the callback is invoked or the socket is destroyed.
+ virtual int ReadResponseBody(IOBuffer* buf, int buf_len,
+ CompletionCallback* callback) = 0;
+
+ // Indicates if the response body has been completely read.
+ virtual bool IsResponseBodyComplete() const = 0;
+
+ // Indicates that the end of the response is detectable. This means that
+ // the response headers indicate either chunked encoding or content length.
+ // If neither is sent, the server must close the connection for us to detect
+ // the end of the response.
+ virtual bool CanFindEndOfResponse() const = 0;
+
+ // After the response headers have been read and after the response body
+ // is complete, this function indicates if more data (either erroneous or
+ // as part of the next pipelined response) has been read from the socket.
+ virtual bool IsMoreDataBuffered() const = 0;
private:
DISALLOW_COPY_AND_ASSIGN(HttpStream);