| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "net/http/http_stream_parser.h" | 5 #include "net/http/http_stream_parser.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 // Shouldn't be merged if upload data carries chunked data. | 258 // Shouldn't be merged if upload data carries chunked data. |
| 259 ASSERT_FALSE(HttpStreamParser::ShouldMergeRequestHeadersAndBody( | 259 ASSERT_FALSE(HttpStreamParser::ShouldMergeRequestHeadersAndBody( |
| 260 "some header", body.get())); | 260 "some header", body.get())); |
| 261 } | 261 } |
| 262 | 262 |
| 263 TEST(HttpStreamParser, ShouldMergeRequestHeadersAndBody_FileBody) { | 263 TEST(HttpStreamParser, ShouldMergeRequestHeadersAndBody_FileBody) { |
| 264 // Create an empty temporary file. | 264 // Create an empty temporary file. |
| 265 base::ScopedTempDir temp_dir; | 265 base::ScopedTempDir temp_dir; |
| 266 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); | 266 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); |
| 267 base::FilePath temp_file_path; | 267 base::FilePath temp_file_path; |
| 268 ASSERT_TRUE(base::CreateTemporaryFileInDir(temp_dir.path(), &temp_file_path)); | 268 ASSERT_TRUE( |
| 269 base::CreateTemporaryFileInDir(temp_dir.GetPath(), &temp_file_path)); |
| 269 | 270 |
| 270 { | 271 { |
| 271 std::vector<std::unique_ptr<UploadElementReader>> element_readers; | 272 std::vector<std::unique_ptr<UploadElementReader>> element_readers; |
| 272 | 273 |
| 273 element_readers.push_back(base::WrapUnique( | 274 element_readers.push_back(base::WrapUnique( |
| 274 new UploadFileElementReader(base::ThreadTaskRunnerHandle::Get().get(), | 275 new UploadFileElementReader(base::ThreadTaskRunnerHandle::Get().get(), |
| 275 temp_file_path, 0, 0, base::Time()))); | 276 temp_file_path, 0, 0, base::Time()))); |
| 276 | 277 |
| 277 std::unique_ptr<UploadDataStream> body( | 278 std::unique_ptr<UploadDataStream> body( |
| 278 new ElementsUploadDataStream(std::move(element_readers), 0)); | 279 new ElementsUploadDataStream(std::move(element_readers), 0)); |
| (...skipping 1226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1505 ASSERT_EQ(kBodySize, parser.ReadResponseBody( | 1506 ASSERT_EQ(kBodySize, parser.ReadResponseBody( |
| 1506 body_buffer.get(), kBodySize, callback.callback())); | 1507 body_buffer.get(), kBodySize, callback.callback())); |
| 1507 | 1508 |
| 1508 EXPECT_EQ(CountWriteBytes(writes, arraysize(writes)), parser.sent_bytes()); | 1509 EXPECT_EQ(CountWriteBytes(writes, arraysize(writes)), parser.sent_bytes()); |
| 1509 EXPECT_EQ(CountReadBytes(reads, arraysize(reads)), parser.received_bytes()); | 1510 EXPECT_EQ(CountReadBytes(reads, arraysize(reads)), parser.received_bytes()); |
| 1510 } | 1511 } |
| 1511 | 1512 |
| 1512 } // namespace | 1513 } // namespace |
| 1513 | 1514 |
| 1514 } // namespace net | 1515 } // namespace net |
| OLD | NEW |