[email protected] | 5f9205f | 2012-06-14 19:55:23 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
[email protected] | 8d5a34e | 2009-06-11 21:21:36 | [diff] [blame] | 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 | |
sclittle | be1ccf6 | 2015-09-02 19:40:36 | [diff] [blame] | 12 | #include <stdint.h> |
| 13 | |
[email protected] | 0877e3d | 2009-10-17 22:29:57 | [diff] [blame] | 14 | #include <string> |
| 15 | |
Avi Drissman | 13fc893 | 2015-12-20 04:40:46 | [diff] [blame] | 16 | #include "base/macros.h" |
[email protected] | f7c2173 | 2013-10-27 09:38:58 | [diff] [blame] | 17 | #include "net/http/http_basic_state.h" |
[email protected] | 8d5a34e | 2009-06-11 21:21:36 | [diff] [blame] | 18 | #include "net/http/http_stream.h" |
[email protected] | 8d5a34e | 2009-06-11 21:21:36 | [diff] [blame] | 19 | |
| 20 | namespace net { |
| 21 | |
[email protected] | 9e743cd | 2010-03-16 07:03:53 | [diff] [blame] | 22 | class BoundNetLog; |
[email protected] | 0877e3d | 2009-10-17 22:29:57 | [diff] [blame] | 23 | class ClientSocketHandle; |
[email protected] | 0877e3d | 2009-10-17 22:29:57 | [diff] [blame] | 24 | class HttpResponseInfo; |
[email protected] | 277d594 | 2010-08-11 21:02:35 | [diff] [blame] | 25 | struct HttpRequestInfo; |
[email protected] | b94f92d | 2010-10-27 16:45:20 | [diff] [blame] | 26 | class HttpRequestHeaders; |
[email protected] | 277d594 | 2010-08-11 21:02:35 | [diff] [blame] | 27 | class HttpStreamParser; |
| 28 | class IOBuffer; |
[email protected] | 0877e3d | 2009-10-17 22:29:57 | [diff] [blame] | 29 | |
[email protected] | 8d5a34e | 2009-06-11 21:21:36 | [diff] [blame] | 30 | class HttpBasicStream : public HttpStream { |
| 31 | public: |
[email protected] | ca14da5 | 2013-10-25 04:16:24 | [diff] [blame] | 32 | // Constructs a new HttpBasicStream. InitializeStream must be called to |
| 33 | // initialize it correctly. |
[email protected] | f7c2173 | 2013-10-27 09:38:58 | [diff] [blame] | 34 | HttpBasicStream(ClientSocketHandle* connection, bool using_proxy); |
dcheng | b03027d | 2014-10-21 12:00:20 | [diff] [blame] | 35 | ~HttpBasicStream() override; |
[email protected] | 8d5a34e | 2009-06-11 21:21:36 | [diff] [blame] | 36 | |
| 37 | // HttpStream methods: |
dcheng | b03027d | 2014-10-21 12:00:20 | [diff] [blame] | 38 | int InitializeStream(const HttpRequestInfo* request_info, |
| 39 | RequestPriority priority, |
| 40 | const BoundNetLog& net_log, |
| 41 | const CompletionCallback& callback) override; |
[email protected] | c638a85a | 2010-07-29 18:41:40 | [diff] [blame] | 42 | |
dcheng | b03027d | 2014-10-21 12:00:20 | [diff] [blame] | 43 | int SendRequest(const HttpRequestHeaders& headers, |
| 44 | HttpResponseInfo* response, |
| 45 | const CompletionCallback& callback) override; |
[email protected] | 8d5a34e | 2009-06-11 21:21:36 | [diff] [blame] | 46 | |
dcheng | b03027d | 2014-10-21 12:00:20 | [diff] [blame] | 47 | UploadProgress GetUploadProgress() const override; |
[email protected] | 0877e3d | 2009-10-17 22:29:57 | [diff] [blame] | 48 | |
dcheng | b03027d | 2014-10-21 12:00:20 | [diff] [blame] | 49 | int ReadResponseHeaders(const CompletionCallback& callback) override; |
[email protected] | 0877e3d | 2009-10-17 22:29:57 | [diff] [blame] | 50 | |
dcheng | b03027d | 2014-10-21 12:00:20 | [diff] [blame] | 51 | int ReadResponseBody(IOBuffer* buf, |
| 52 | int buf_len, |
| 53 | const CompletionCallback& callback) override; |
[email protected] | 0877e3d | 2009-10-17 22:29:57 | [diff] [blame] | 54 | |
dcheng | b03027d | 2014-10-21 12:00:20 | [diff] [blame] | 55 | void Close(bool not_reusable) override; |
[email protected] | 8e6441ca | 2010-08-19 05:56:38 | [diff] [blame] | 56 | |
dcheng | b03027d | 2014-10-21 12:00:20 | [diff] [blame] | 57 | HttpStream* RenewStreamForAuth() override; |
[email protected] | 697ef4c | 2010-10-14 16:38:58 | [diff] [blame] | 58 | |
dcheng | b03027d | 2014-10-21 12:00:20 | [diff] [blame] | 59 | bool IsResponseBodyComplete() const override; |
[email protected] | 0877e3d | 2009-10-17 22:29:57 | [diff] [blame] | 60 | |
dcheng | b03027d | 2014-10-21 12:00:20 | [diff] [blame] | 61 | bool IsConnectionReused() const override; |
[email protected] | 8e6441ca | 2010-08-19 05:56:38 | [diff] [blame] | 62 | |
dcheng | b03027d | 2014-10-21 12:00:20 | [diff] [blame] | 63 | void SetConnectionReused() override; |
[email protected] | 8e6441ca | 2010-08-19 05:56:38 | [diff] [blame] | 64 | |
mmenke | bd84c39 | 2015-09-02 14:12:34 | [diff] [blame] | 65 | bool CanReuseConnection() const override; |
[email protected] | 8e6441ca | 2010-08-19 05:56:38 | [diff] [blame] | 66 | |
sclittle | 4de1bab9 | 2015-09-22 21:28:24 | [diff] [blame] | 67 | int64_t GetTotalReceivedBytes() const override; |
[email protected] | bc92bc97 | 2013-12-13 08:32:59 | [diff] [blame] | 68 | |
sclittle | be1ccf6 | 2015-09-02 19:40:36 | [diff] [blame] | 69 | int64_t GetTotalSentBytes() const override; |
| 70 | |
dcheng | b03027d | 2014-10-21 12:00:20 | [diff] [blame] | 71 | bool GetLoadTimingInfo(LoadTimingInfo* load_timing_info) const override; |
[email protected] | b258e079 | 2013-01-12 07:11:59 | [diff] [blame] | 72 | |
dcheng | b03027d | 2014-10-21 12:00:20 | [diff] [blame] | 73 | void GetSSLInfo(SSLInfo* ssl_info) override; |
[email protected] | 8e6441ca | 2010-08-19 05:56:38 | [diff] [blame] | 74 | |
dcheng | b03027d | 2014-10-21 12:00:20 | [diff] [blame] | 75 | void GetSSLCertRequestInfo(SSLCertRequestInfo* cert_request_info) override; |
[email protected] | 2d0a4f9 | 2011-05-05 16:38:46 | [diff] [blame] | 76 | |
ttuttle | d9dbc65 | 2015-09-29 20:00:59 | [diff] [blame] | 77 | bool GetRemoteEndpoint(IPEndPoint* endpoint) override; |
| 78 | |
nharper | b7441ef | 2016-01-25 23:54:14 | [diff] [blame] | 79 | Error GetSignedEKMForTokenBinding(crypto::ECPrivateKey* key, |
| 80 | std::vector<uint8_t>* out) override; |
| 81 | |
dcheng | b03027d | 2014-10-21 12:00:20 | [diff] [blame] | 82 | void Drain(HttpNetworkSession* session) override; |
[email protected] | 5a60c8b | 2011-10-19 20:14:29 | [diff] [blame] | 83 | |
zhongyi | ca364fbb | 2015-12-12 03:39:12 | [diff] [blame] | 84 | void PopulateNetErrorDetails(NetErrorDetails* details) override; |
| 85 | |
dcheng | b03027d | 2014-10-21 12:00:20 | [diff] [blame] | 86 | void SetPriority(RequestPriority priority) override; |
[email protected] | e86839fd | 2013-08-14 18:29:03 | [diff] [blame] | 87 | |
[email protected] | 8d5a34e | 2009-06-11 21:21:36 | [diff] [blame] | 88 | private: |
[email protected] | f7c2173 | 2013-10-27 09:38:58 | [diff] [blame] | 89 | HttpStreamParser* parser() const { return state_.parser(); } |
[email protected] | 0877e3d | 2009-10-17 22:29:57 | [diff] [blame] | 90 | |
[email protected] | f7c2173 | 2013-10-27 09:38:58 | [diff] [blame] | 91 | HttpBasicState state_; |
[email protected] | b94f92d | 2010-10-27 16:45:20 | [diff] [blame] | 92 | |
[email protected] | 8d5a34e | 2009-06-11 21:21:36 | [diff] [blame] | 93 | DISALLOW_COPY_AND_ASSIGN(HttpBasicStream); |
| 94 | }; |
| 95 | |
| 96 | } // namespace net |
| 97 | |
| 98 | #endif // NET_HTTP_HTTP_BASIC_STREAM_H_ |