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 #include "net/http/test_upload_data_stream_not_allow_http1.h" 6 7 #include "net/base/io_buffer.h" 8 #include "net/base/net_errors.h" 9 10 namespace net { 11 AllowHTTP1() const12bool UploadDataStreamNotAllowHTTP1::AllowHTTP1() const { 13 return false; 14 } 15 InitInternal(const NetLogWithSource &)16int UploadDataStreamNotAllowHTTP1::InitInternal(const NetLogWithSource&) { 17 return net::OK; 18 } 19 ReadInternal(IOBuffer * buf,int buf_len)20int UploadDataStreamNotAllowHTTP1::ReadInternal(IOBuffer* buf, int buf_len) { 21 const size_t bytes_to_read = 22 std::min(content_.length(), static_cast<size_t>(buf_len)); 23 memcpy(buf->data(), content_.c_str(), bytes_to_read); 24 content_ = content_.substr(bytes_to_read); 25 if (!content_.length()) 26 SetIsFinalChunk(); 27 return bytes_to_read; 28 } 29 ResetInternal()30void UploadDataStreamNotAllowHTTP1::ResetInternal() {} 31 32 } // namespace net