test_upload_data_stream_not_allow_http1.h 1.1 KB

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