Kaido Kert | 25902c6 | 2024-06-17 17:10:28 -0700 | [diff] [blame^] | 1 | // Copyright 2020 The Chromium Authors |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef NET_HTTP_TEST_UPLOAD_DATA_STREAM_NOT_ALLOW_HTTP1_H_ |
| 6 | #define NET_HTTP_TEST_UPLOAD_DATA_STREAM_NOT_ALLOW_HTTP1_H_ |
| 7 | |
| 8 | #include "net/base/upload_data_stream.h" |
| 9 | |
| 10 | namespace net { |
| 11 | |
| 12 | // UploadDataStreamNotAllowHTTP1 simply disallows HTTP/1 and uploads content. |
| 13 | class UploadDataStreamNotAllowHTTP1 : public UploadDataStream { |
| 14 | public: |
| 15 | explicit UploadDataStreamNotAllowHTTP1(const std::string& content) |
| 16 | : UploadDataStream(true, 0), content_(content) {} |
| 17 | UploadDataStreamNotAllowHTTP1(const UploadDataStreamNotAllowHTTP1&) = delete; |
| 18 | UploadDataStreamNotAllowHTTP1& operator=( |
| 19 | const UploadDataStreamNotAllowHTTP1&) = delete; |
| 20 | |
| 21 | bool AllowHTTP1() const override; |
| 22 | |
| 23 | private: |
| 24 | int InitInternal(const NetLogWithSource& net_log) override; |
| 25 | int ReadInternal(IOBuffer* buf, int buf_len) override; |
| 26 | void ResetInternal() override; |
| 27 | |
| 28 | std::string content_; |
| 29 | }; |
| 30 | |
| 31 | } // namespace net |
| 32 | |
| 33 | #endif // NET_HTTP_TEST_UPLOAD_DATA_STREAM_NOT_ALLOW_HTTP1_H_ |