| OLD | NEW |
| 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 | 9 |
| 10 #ifndef NET_HTTP_HTTP_STREAM_H_ | 10 #ifndef NET_HTTP_HTTP_STREAM_H_ |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 // Reads from the underlying socket until the response headers have been | 43 // Reads from the underlying socket until the response headers have been |
| 44 // completely received. ERR_IO_PENDING is returned if the operation could | 44 // completely received. ERR_IO_PENDING is returned if the operation could |
| 45 // not be completed synchronously, in which case the result will be passed | 45 // not be completed synchronously, in which case the result will be passed |
| 46 // to the callback when available. Returns OK on success. The response | 46 // to the callback when available. Returns OK on success. The response |
| 47 // headers are available in the HttpResponseInfo returned by GetResponseInfo | 47 // headers are available in the HttpResponseInfo returned by GetResponseInfo |
| 48 virtual int ReadResponseHeaders(CompletionCallback* callback) = 0; | 48 virtual int ReadResponseHeaders(CompletionCallback* callback) = 0; |
| 49 | 49 |
| 50 // Provides access to HttpResponseInfo (owned by HttpStream). | 50 // Provides access to HttpResponseInfo (owned by HttpStream). |
| 51 virtual HttpResponseInfo* GetResponseInfo() const = 0; | 51 virtual HttpResponseInfo* GetResponseInfo() const = 0; |
| 52 | 52 |
| 53 // Reads response body data, up to |buf_len| bytes. The number of bytes read | 53 // Reads response body data, up to |buf_len| bytes. |buf_len| should be a |
| 54 // is returned, or an error is returned upon failure. ERR_CONNECTION_CLOSED | 54 // reasonable size (<256KB). The number of bytes read is returned, or an |
| 55 // is returned to indicate end-of-connection. ERR_IO_PENDING is returned if | 55 // error is returned upon failure. ERR_CONNECTION_CLOSED is returned to |
| 56 // the operation could not be completed synchronously, in which case the | 56 // indicate end-of-connection. ERR_IO_PENDING is returned if the operation |
| 57 // result will be passed to the callback when available. If the operation is | 57 // could not be completed synchronously, in which case the result will be |
| 58 // not completed immediately, the socket acquires a reference to the provided | 58 // passed to the callback when available. If the operation is not completed |
| 59 // buffer until the callback is invoked or the socket is destroyed. | 59 // immediately, the socket acquires a reference to the provided buffer until |
| 60 // the callback is invoked or the socket is destroyed. |
| 60 virtual int ReadResponseBody(IOBuffer* buf, int buf_len, | 61 virtual int ReadResponseBody(IOBuffer* buf, int buf_len, |
| 61 CompletionCallback* callback) = 0; | 62 CompletionCallback* callback) = 0; |
| 62 | 63 |
| 63 // Indicates if the response body has been completely read. | 64 // Indicates if the response body has been completely read. |
| 64 virtual bool IsResponseBodyComplete() const = 0; | 65 virtual bool IsResponseBodyComplete() const = 0; |
| 65 | 66 |
| 66 // Indicates that the end of the response is detectable. This means that | 67 // Indicates that the end of the response is detectable. This means that |
| 67 // the response headers indicate either chunked encoding or content length. | 68 // 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 // If neither is sent, the server must close the connection for us to detect |
| 69 // the end of the response. | 70 // the end of the response. |
| 70 virtual bool CanFindEndOfResponse() const = 0; | 71 virtual bool CanFindEndOfResponse() const = 0; |
| 71 | 72 |
| 72 // After the response headers have been read and after the response body | 73 // 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 // 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 // as part of the next pipelined response) has been read from the socket. |
| 75 virtual bool IsMoreDataBuffered() const = 0; | 76 virtual bool IsMoreDataBuffered() const = 0; |
| 76 | 77 |
| 77 private: | 78 private: |
| 78 DISALLOW_COPY_AND_ASSIGN(HttpStream); | 79 DISALLOW_COPY_AND_ASSIGN(HttpStream); |
| 79 }; | 80 }; |
| 80 | 81 |
| 81 } // namespace net | 82 } // namespace net |
| 82 | 83 |
| 83 #endif // NET_HTTP_HTTP_STREAM_H_ | 84 #endif // NET_HTTP_HTTP_STREAM_H_ |
| OLD | NEW |