| 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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 72  public: | 72  public: | 
| 73   enum class FailureMode { SYNC, ASYNC }; | 73   enum class FailureMode { SYNC, ASYNC }; | 
| 74 | 74 | 
| 75   explicit ReadErrorUploadDataStream(FailureMode mode) | 75   explicit ReadErrorUploadDataStream(FailureMode mode) | 
| 76       : UploadDataStream(true, 0), async_(mode), weak_factory_(this) {} | 76       : UploadDataStream(true, 0), async_(mode), weak_factory_(this) {} | 
| 77 | 77 | 
| 78  private: | 78  private: | 
| 79   void CompleteRead() { UploadDataStream::OnReadCompleted(ERR_FAILED); } | 79   void CompleteRead() { UploadDataStream::OnReadCompleted(ERR_FAILED); } | 
| 80 | 80 | 
| 81   // UploadDataStream implementation: | 81   // UploadDataStream implementation: | 
| 82   int InitInternal(const BoundNetLog& net_log) override { return OK; } | 82   int InitInternal(const NetLogWithSource& net_log) override { return OK; } | 
| 83 | 83 | 
| 84   int ReadInternal(IOBuffer* buf, int buf_len) override { | 84   int ReadInternal(IOBuffer* buf, int buf_len) override { | 
| 85     if (async_ == FailureMode::ASYNC) { | 85     if (async_ == FailureMode::ASYNC) { | 
| 86       base::ThreadTaskRunnerHandle::Get()->PostTask( | 86       base::ThreadTaskRunnerHandle::Get()->PostTask( | 
| 87           FROM_HERE, base::Bind(&ReadErrorUploadDataStream::CompleteRead, | 87           FROM_HERE, base::Bind(&ReadErrorUploadDataStream::CompleteRead, | 
| 88                                 weak_factory_.GetWeakPtr())); | 88                                 weak_factory_.GetWeakPtr())); | 
| 89       return ERR_IO_PENDING; | 89       return ERR_IO_PENDING; | 
| 90     } | 90     } | 
| 91     return ERR_FAILED; | 91     return ERR_FAILED; | 
| 92   } | 92   } | 
| (...skipping 19 matching lines...) Expand all  Loading... | 
| 112 | 112 | 
| 113   ReadErrorUploadDataStream upload_data_stream( | 113   ReadErrorUploadDataStream upload_data_stream( | 
| 114       ReadErrorUploadDataStream::FailureMode::SYNC); | 114       ReadErrorUploadDataStream::FailureMode::SYNC); | 
| 115 | 115 | 
| 116   // Test upload progress before init. | 116   // Test upload progress before init. | 
| 117   UploadProgress progress = upload_data_stream.GetUploadProgress(); | 117   UploadProgress progress = upload_data_stream.GetUploadProgress(); | 
| 118   EXPECT_EQ(0u, progress.size()); | 118   EXPECT_EQ(0u, progress.size()); | 
| 119   EXPECT_EQ(0u, progress.position()); | 119   EXPECT_EQ(0u, progress.position()); | 
| 120 | 120 | 
| 121   ASSERT_THAT(upload_data_stream.Init(TestCompletionCallback().callback(), | 121   ASSERT_THAT(upload_data_stream.Init(TestCompletionCallback().callback(), | 
| 122                                       BoundNetLog()), | 122                                       NetLogWithSource()), | 
| 123               IsOk()); | 123               IsOk()); | 
| 124 | 124 | 
| 125   // Test upload progress after init. | 125   // Test upload progress after init. | 
| 126   progress = upload_data_stream.GetUploadProgress(); | 126   progress = upload_data_stream.GetUploadProgress(); | 
| 127   EXPECT_EQ(0u, progress.size()); | 127   EXPECT_EQ(0u, progress.size()); | 
| 128   EXPECT_EQ(0u, progress.position()); | 128   EXPECT_EQ(0u, progress.position()); | 
| 129 | 129 | 
| 130   HttpRequestInfo request; | 130   HttpRequestInfo request; | 
| 131   request.method = "POST"; | 131   request.method = "POST"; | 
| 132   request.url = GURL("http://localhost"); | 132   request.url = GURL("http://localhost"); | 
| 133   request.upload_data_stream = &upload_data_stream; | 133   request.upload_data_stream = &upload_data_stream; | 
| 134 | 134 | 
| 135   scoped_refptr<GrowableIOBuffer> read_buffer(new GrowableIOBuffer); | 135   scoped_refptr<GrowableIOBuffer> read_buffer(new GrowableIOBuffer); | 
| 136   HttpStreamParser parser(socket_handle.get(), &request, read_buffer.get(), | 136   HttpStreamParser parser(socket_handle.get(), &request, read_buffer.get(), | 
| 137                           BoundNetLog()); | 137                           NetLogWithSource()); | 
| 138 | 138 | 
| 139   HttpRequestHeaders headers; | 139   HttpRequestHeaders headers; | 
| 140   headers.SetHeader("Content-Length", "12"); | 140   headers.SetHeader("Content-Length", "12"); | 
| 141 | 141 | 
| 142   HttpResponseInfo response; | 142   HttpResponseInfo response; | 
| 143   TestCompletionCallback callback; | 143   TestCompletionCallback callback; | 
| 144   int result = parser.SendRequest("POST / HTTP/1.1\r\n", headers, &response, | 144   int result = parser.SendRequest("POST / HTTP/1.1\r\n", headers, &response, | 
| 145                                   callback.callback()); | 145                                   callback.callback()); | 
| 146   EXPECT_THAT(callback.GetResult(result), IsError(ERR_FAILED)); | 146   EXPECT_THAT(callback.GetResult(result), IsError(ERR_FAILED)); | 
| 147 | 147 | 
| (...skipping 10 matching lines...) Expand all  Loading... | 
| 158       MockWrite(ASYNC, 1, "Content-Length: 12\r\n\r\n"), | 158       MockWrite(ASYNC, 1, "Content-Length: 12\r\n\r\n"), | 
| 159   }; | 159   }; | 
| 160 | 160 | 
| 161   SequencedSocketData data(nullptr, 0, writes, arraysize(writes)); | 161   SequencedSocketData data(nullptr, 0, writes, arraysize(writes)); | 
| 162   std::unique_ptr<ClientSocketHandle> socket_handle = | 162   std::unique_ptr<ClientSocketHandle> socket_handle = | 
| 163       CreateConnectedSocketHandle(&data); | 163       CreateConnectedSocketHandle(&data); | 
| 164 | 164 | 
| 165   ReadErrorUploadDataStream upload_data_stream( | 165   ReadErrorUploadDataStream upload_data_stream( | 
| 166       ReadErrorUploadDataStream::FailureMode::ASYNC); | 166       ReadErrorUploadDataStream::FailureMode::ASYNC); | 
| 167   ASSERT_THAT(upload_data_stream.Init(TestCompletionCallback().callback(), | 167   ASSERT_THAT(upload_data_stream.Init(TestCompletionCallback().callback(), | 
| 168                                       BoundNetLog()), | 168                                       NetLogWithSource()), | 
| 169               IsOk()); | 169               IsOk()); | 
| 170 | 170 | 
| 171   HttpRequestInfo request; | 171   HttpRequestInfo request; | 
| 172   request.method = "POST"; | 172   request.method = "POST"; | 
| 173   request.url = GURL("http://localhost"); | 173   request.url = GURL("http://localhost"); | 
| 174   request.upload_data_stream = &upload_data_stream; | 174   request.upload_data_stream = &upload_data_stream; | 
| 175 | 175 | 
| 176   scoped_refptr<GrowableIOBuffer> read_buffer(new GrowableIOBuffer); | 176   scoped_refptr<GrowableIOBuffer> read_buffer(new GrowableIOBuffer); | 
| 177   HttpStreamParser parser(socket_handle.get(), &request, read_buffer.get(), | 177   HttpStreamParser parser(socket_handle.get(), &request, read_buffer.get(), | 
| 178                           BoundNetLog()); | 178                           NetLogWithSource()); | 
| 179 | 179 | 
| 180   HttpRequestHeaders headers; | 180   HttpRequestHeaders headers; | 
| 181   headers.SetHeader("Content-Length", "12"); | 181   headers.SetHeader("Content-Length", "12"); | 
| 182 | 182 | 
| 183   HttpResponseInfo response; | 183   HttpResponseInfo response; | 
| 184   TestCompletionCallback callback; | 184   TestCompletionCallback callback; | 
| 185   int result = parser.SendRequest("POST / HTTP/1.1\r\n", headers, &response, | 185   int result = parser.SendRequest("POST / HTTP/1.1\r\n", headers, &response, | 
| 186                                   callback.callback()); | 186                                   callback.callback()); | 
| 187   EXPECT_THAT(result, IsError(ERR_IO_PENDING)); | 187   EXPECT_THAT(result, IsError(ERR_IO_PENDING)); | 
| 188 | 188 | 
| 189   UploadProgress progress = upload_data_stream.GetUploadProgress(); | 189   UploadProgress progress = upload_data_stream.GetUploadProgress(); | 
| 190   EXPECT_EQ(0u, progress.size()); | 190   EXPECT_EQ(0u, progress.size()); | 
| 191   EXPECT_EQ(0u, progress.position()); | 191   EXPECT_EQ(0u, progress.position()); | 
| 192 | 192 | 
| 193   EXPECT_THAT(callback.GetResult(result), IsError(ERR_FAILED)); | 193   EXPECT_THAT(callback.GetResult(result), IsError(ERR_FAILED)); | 
| 194 | 194 | 
| 195   EXPECT_EQ(CountWriteBytes(writes, arraysize(writes)), parser.sent_bytes()); | 195   EXPECT_EQ(CountWriteBytes(writes, arraysize(writes)), parser.sent_bytes()); | 
| 196 } | 196 } | 
| 197 | 197 | 
| 198 class InitAsyncUploadDataStream : public ChunkedUploadDataStream { | 198 class InitAsyncUploadDataStream : public ChunkedUploadDataStream { | 
| 199  public: | 199  public: | 
| 200   explicit InitAsyncUploadDataStream(int64_t identifier) | 200   explicit InitAsyncUploadDataStream(int64_t identifier) | 
| 201       : ChunkedUploadDataStream(identifier), weak_factory_(this) {} | 201       : ChunkedUploadDataStream(identifier), weak_factory_(this) {} | 
| 202 | 202 | 
| 203  private: | 203  private: | 
| 204   void CompleteInit() { UploadDataStream::OnInitCompleted(OK); } | 204   void CompleteInit() { UploadDataStream::OnInitCompleted(OK); } | 
| 205 | 205 | 
| 206   int InitInternal(const BoundNetLog& net_log) override { | 206   int InitInternal(const NetLogWithSource& net_log) override { | 
| 207     base::ThreadTaskRunnerHandle::Get()->PostTask( | 207     base::ThreadTaskRunnerHandle::Get()->PostTask( | 
| 208         FROM_HERE, base::Bind(&InitAsyncUploadDataStream::CompleteInit, | 208         FROM_HERE, base::Bind(&InitAsyncUploadDataStream::CompleteInit, | 
| 209                               weak_factory_.GetWeakPtr())); | 209                               weak_factory_.GetWeakPtr())); | 
| 210     return ERR_IO_PENDING; | 210     return ERR_IO_PENDING; | 
| 211   } | 211   } | 
| 212 | 212 | 
| 213   base::WeakPtrFactory<InitAsyncUploadDataStream> weak_factory_; | 213   base::WeakPtrFactory<InitAsyncUploadDataStream> weak_factory_; | 
| 214 | 214 | 
| 215   DISALLOW_COPY_AND_ASSIGN(InitAsyncUploadDataStream); | 215   DISALLOW_COPY_AND_ASSIGN(InitAsyncUploadDataStream); | 
| 216 }; | 216 }; | 
| 217 | 217 | 
| 218 TEST(HttpStreamParser, InitAsynchronousUploadDataStream) { | 218 TEST(HttpStreamParser, InitAsynchronousUploadDataStream) { | 
| 219   InitAsyncUploadDataStream upload_data_stream(0); | 219   InitAsyncUploadDataStream upload_data_stream(0); | 
| 220 | 220 | 
| 221   TestCompletionCallback callback; | 221   TestCompletionCallback callback; | 
| 222   int result = upload_data_stream.Init(callback.callback(), BoundNetLog()); | 222   int result = upload_data_stream.Init(callback.callback(), NetLogWithSource()); | 
| 223   ASSERT_THAT(result, IsError(ERR_IO_PENDING)); | 223   ASSERT_THAT(result, IsError(ERR_IO_PENDING)); | 
| 224 | 224 | 
| 225   // Should be empty progress while initialization is in progress. | 225   // Should be empty progress while initialization is in progress. | 
| 226   UploadProgress progress = upload_data_stream.GetUploadProgress(); | 226   UploadProgress progress = upload_data_stream.GetUploadProgress(); | 
| 227   EXPECT_EQ(0u, progress.size()); | 227   EXPECT_EQ(0u, progress.size()); | 
| 228   EXPECT_EQ(0u, progress.position()); | 228   EXPECT_EQ(0u, progress.position()); | 
| 229   EXPECT_THAT(callback.GetResult(result), IsOk()); | 229   EXPECT_THAT(callback.GetResult(result), IsOk()); | 
| 230 | 230 | 
| 231   // Initialization complete. | 231   // Initialization complete. | 
| 232   progress = upload_data_stream.GetUploadProgress(); | 232   progress = upload_data_stream.GetUploadProgress(); | 
| (...skipping 11 matching lines...) Expand all  Loading... | 
| 244       MockWrite(ASYNC, 1, "Transfer-Encoding: chunked\r\n\r\n"), | 244       MockWrite(ASYNC, 1, "Transfer-Encoding: chunked\r\n\r\n"), | 
| 245       MockWrite(ASYNC, 2, "7\r\nChunk 1\r\n"), | 245       MockWrite(ASYNC, 2, "7\r\nChunk 1\r\n"), | 
| 246   }; | 246   }; | 
| 247 | 247 | 
| 248   SequencedSocketData data(nullptr, 0, writes, arraysize(writes)); | 248   SequencedSocketData data(nullptr, 0, writes, arraysize(writes)); | 
| 249   std::unique_ptr<ClientSocketHandle> socket_handle = | 249   std::unique_ptr<ClientSocketHandle> socket_handle = | 
| 250       CreateConnectedSocketHandle(&data); | 250       CreateConnectedSocketHandle(&data); | 
| 251 | 251 | 
| 252   scoped_refptr<GrowableIOBuffer> read_buffer(new GrowableIOBuffer); | 252   scoped_refptr<GrowableIOBuffer> read_buffer(new GrowableIOBuffer); | 
| 253   HttpStreamParser parser(socket_handle.get(), &request, read_buffer.get(), | 253   HttpStreamParser parser(socket_handle.get(), &request, read_buffer.get(), | 
| 254                           BoundNetLog()); | 254                           NetLogWithSource()); | 
| 255 | 255 | 
| 256   HttpRequestHeaders headers; | 256   HttpRequestHeaders headers; | 
| 257   headers.SetHeader("Transfer-Encoding", "chunked"); | 257   headers.SetHeader("Transfer-Encoding", "chunked"); | 
| 258 | 258 | 
| 259   HttpResponseInfo response; | 259   HttpResponseInfo response; | 
| 260   TestCompletionCallback callback1; | 260   TestCompletionCallback callback1; | 
| 261   int result1 = parser.SendRequest("POST / HTTP/1.1\r\n", headers, &response, | 261   int result1 = parser.SendRequest("POST / HTTP/1.1\r\n", headers, &response, | 
| 262                                    callback1.callback()); | 262                                    callback1.callback()); | 
| 263   EXPECT_EQ(ERR_IO_PENDING, result1); | 263   EXPECT_EQ(ERR_IO_PENDING, result1); | 
| 264   base::RunLoop().RunUntilIdle(); | 264   base::RunLoop().RunUntilIdle(); | 
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 338   // Shouldn't be merged if upload data is non-existent. | 338   // Shouldn't be merged if upload data is non-existent. | 
| 339   ASSERT_FALSE(HttpStreamParser::ShouldMergeRequestHeadersAndBody( | 339   ASSERT_FALSE(HttpStreamParser::ShouldMergeRequestHeadersAndBody( | 
| 340       "some header", NULL)); | 340       "some header", NULL)); | 
| 341 } | 341 } | 
| 342 | 342 | 
| 343 TEST(HttpStreamParser, ShouldMergeRequestHeadersAndBody_EmptyBody) { | 343 TEST(HttpStreamParser, ShouldMergeRequestHeadersAndBody_EmptyBody) { | 
| 344   std::vector<std::unique_ptr<UploadElementReader>> element_readers; | 344   std::vector<std::unique_ptr<UploadElementReader>> element_readers; | 
| 345   std::unique_ptr<UploadDataStream> body( | 345   std::unique_ptr<UploadDataStream> body( | 
| 346       base::MakeUnique<ElementsUploadDataStream>(std::move(element_readers), | 346       base::MakeUnique<ElementsUploadDataStream>(std::move(element_readers), | 
| 347                                                  0)); | 347                                                  0)); | 
| 348   ASSERT_THAT(body->Init(CompletionCallback(), BoundNetLog()), IsOk()); | 348   ASSERT_THAT(body->Init(CompletionCallback(), NetLogWithSource()), IsOk()); | 
| 349   // Shouldn't be merged if upload data is empty. | 349   // Shouldn't be merged if upload data is empty. | 
| 350   ASSERT_FALSE(HttpStreamParser::ShouldMergeRequestHeadersAndBody( | 350   ASSERT_FALSE(HttpStreamParser::ShouldMergeRequestHeadersAndBody( | 
| 351       "some header", body.get())); | 351       "some header", body.get())); | 
| 352 } | 352 } | 
| 353 | 353 | 
| 354 TEST(HttpStreamParser, ShouldMergeRequestHeadersAndBody_ChunkedBody) { | 354 TEST(HttpStreamParser, ShouldMergeRequestHeadersAndBody_ChunkedBody) { | 
| 355   const std::string payload = "123"; | 355   const std::string payload = "123"; | 
| 356   std::unique_ptr<ChunkedUploadDataStream> body(new ChunkedUploadDataStream(0)); | 356   std::unique_ptr<ChunkedUploadDataStream> body(new ChunkedUploadDataStream(0)); | 
| 357   body->AppendData(payload.data(), payload.size(), true); | 357   body->AppendData(payload.data(), payload.size(), true); | 
| 358   ASSERT_THAT(body->Init(TestCompletionCallback().callback(), BoundNetLog()), | 358   ASSERT_THAT( | 
| 359               IsOk()); | 359       body->Init(TestCompletionCallback().callback(), NetLogWithSource()), | 
|  | 360       IsOk()); | 
| 360   // Shouldn't be merged if upload data carries chunked data. | 361   // Shouldn't be merged if upload data carries chunked data. | 
| 361   ASSERT_FALSE(HttpStreamParser::ShouldMergeRequestHeadersAndBody( | 362   ASSERT_FALSE(HttpStreamParser::ShouldMergeRequestHeadersAndBody( | 
| 362       "some header", body.get())); | 363       "some header", body.get())); | 
| 363 } | 364 } | 
| 364 | 365 | 
| 365 TEST(HttpStreamParser, ShouldMergeRequestHeadersAndBody_FileBody) { | 366 TEST(HttpStreamParser, ShouldMergeRequestHeadersAndBody_FileBody) { | 
| 366   // Create an empty temporary file. | 367   // Create an empty temporary file. | 
| 367   base::ScopedTempDir temp_dir; | 368   base::ScopedTempDir temp_dir; | 
| 368   ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); | 369   ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); | 
| 369   base::FilePath temp_file_path; | 370   base::FilePath temp_file_path; | 
| 370   ASSERT_TRUE( | 371   ASSERT_TRUE( | 
| 371       base::CreateTemporaryFileInDir(temp_dir.GetPath(), &temp_file_path)); | 372       base::CreateTemporaryFileInDir(temp_dir.GetPath(), &temp_file_path)); | 
| 372 | 373 | 
| 373   { | 374   { | 
| 374     std::vector<std::unique_ptr<UploadElementReader>> element_readers; | 375     std::vector<std::unique_ptr<UploadElementReader>> element_readers; | 
| 375 | 376 | 
| 376     element_readers.push_back(base::MakeUnique<UploadFileElementReader>( | 377     element_readers.push_back(base::MakeUnique<UploadFileElementReader>( | 
| 377         base::ThreadTaskRunnerHandle::Get().get(), temp_file_path, 0, 0, | 378         base::ThreadTaskRunnerHandle::Get().get(), temp_file_path, 0, 0, | 
| 378         base::Time())); | 379         base::Time())); | 
| 379 | 380 | 
| 380     std::unique_ptr<UploadDataStream> body( | 381     std::unique_ptr<UploadDataStream> body( | 
| 381         new ElementsUploadDataStream(std::move(element_readers), 0)); | 382         new ElementsUploadDataStream(std::move(element_readers), 0)); | 
| 382     TestCompletionCallback callback; | 383     TestCompletionCallback callback; | 
| 383     ASSERT_THAT(body->Init(callback.callback(), BoundNetLog()), | 384     ASSERT_THAT(body->Init(callback.callback(), NetLogWithSource()), | 
| 384                 IsError(ERR_IO_PENDING)); | 385                 IsError(ERR_IO_PENDING)); | 
| 385     ASSERT_THAT(callback.WaitForResult(), IsOk()); | 386     ASSERT_THAT(callback.WaitForResult(), IsOk()); | 
| 386     // Shouldn't be merged if upload data carries a file, as it's not in-memory. | 387     // Shouldn't be merged if upload data carries a file, as it's not in-memory. | 
| 387     ASSERT_FALSE(HttpStreamParser::ShouldMergeRequestHeadersAndBody( | 388     ASSERT_FALSE(HttpStreamParser::ShouldMergeRequestHeadersAndBody( | 
| 388         "some header", body.get())); | 389         "some header", body.get())); | 
| 389   } | 390   } | 
| 390 | 391 | 
| 391   // UploadFileElementReaders may post clean-up tasks on destruction. | 392   // UploadFileElementReaders may post clean-up tasks on destruction. | 
| 392   base::RunLoop().RunUntilIdle(); | 393   base::RunLoop().RunUntilIdle(); | 
| 393 } | 394 } | 
| 394 | 395 | 
| 395 TEST(HttpStreamParser, ShouldMergeRequestHeadersAndBody_SmallBodyInMemory) { | 396 TEST(HttpStreamParser, ShouldMergeRequestHeadersAndBody_SmallBodyInMemory) { | 
| 396   std::vector<std::unique_ptr<UploadElementReader>> element_readers; | 397   std::vector<std::unique_ptr<UploadElementReader>> element_readers; | 
| 397   const std::string payload = "123"; | 398   const std::string payload = "123"; | 
| 398   element_readers.push_back(base::MakeUnique<UploadBytesElementReader>( | 399   element_readers.push_back(base::MakeUnique<UploadBytesElementReader>( | 
| 399       payload.data(), payload.size())); | 400       payload.data(), payload.size())); | 
| 400 | 401 | 
| 401   std::unique_ptr<UploadDataStream> body( | 402   std::unique_ptr<UploadDataStream> body( | 
| 402       new ElementsUploadDataStream(std::move(element_readers), 0)); | 403       new ElementsUploadDataStream(std::move(element_readers), 0)); | 
| 403   ASSERT_THAT(body->Init(CompletionCallback(), BoundNetLog()), IsOk()); | 404   ASSERT_THAT(body->Init(CompletionCallback(), NetLogWithSource()), IsOk()); | 
| 404   // Yes, should be merged if the in-memory body is small here. | 405   // Yes, should be merged if the in-memory body is small here. | 
| 405   ASSERT_TRUE(HttpStreamParser::ShouldMergeRequestHeadersAndBody( | 406   ASSERT_TRUE(HttpStreamParser::ShouldMergeRequestHeadersAndBody( | 
| 406       "some header", body.get())); | 407       "some header", body.get())); | 
| 407 } | 408 } | 
| 408 | 409 | 
| 409 TEST(HttpStreamParser, ShouldMergeRequestHeadersAndBody_LargeBodyInMemory) { | 410 TEST(HttpStreamParser, ShouldMergeRequestHeadersAndBody_LargeBodyInMemory) { | 
| 410   std::vector<std::unique_ptr<UploadElementReader>> element_readers; | 411   std::vector<std::unique_ptr<UploadElementReader>> element_readers; | 
| 411   const std::string payload(10000, 'a');  // 'a' x 10000. | 412   const std::string payload(10000, 'a');  // 'a' x 10000. | 
| 412   element_readers.push_back(base::MakeUnique<UploadBytesElementReader>( | 413   element_readers.push_back(base::MakeUnique<UploadBytesElementReader>( | 
| 413       payload.data(), payload.size())); | 414       payload.data(), payload.size())); | 
| 414 | 415 | 
| 415   std::unique_ptr<UploadDataStream> body( | 416   std::unique_ptr<UploadDataStream> body( | 
| 416       new ElementsUploadDataStream(std::move(element_readers), 0)); | 417       new ElementsUploadDataStream(std::move(element_readers), 0)); | 
| 417   ASSERT_THAT(body->Init(CompletionCallback(), BoundNetLog()), IsOk()); | 418   ASSERT_THAT(body->Init(CompletionCallback(), NetLogWithSource()), IsOk()); | 
| 418   // Shouldn't be merged if the in-memory body is large here. | 419   // Shouldn't be merged if the in-memory body is large here. | 
| 419   ASSERT_FALSE(HttpStreamParser::ShouldMergeRequestHeadersAndBody( | 420   ASSERT_FALSE(HttpStreamParser::ShouldMergeRequestHeadersAndBody( | 
| 420       "some header", body.get())); | 421       "some header", body.get())); | 
| 421 } | 422 } | 
| 422 | 423 | 
| 423 TEST(HttpStreamParser, SentBytesNoHeaders) { | 424 TEST(HttpStreamParser, SentBytesNoHeaders) { | 
| 424   MockWrite writes[] = { | 425   MockWrite writes[] = { | 
| 425       MockWrite(SYNCHRONOUS, 0, "GET / HTTP/1.1\r\n\r\n"), | 426       MockWrite(SYNCHRONOUS, 0, "GET / HTTP/1.1\r\n\r\n"), | 
| 426   }; | 427   }; | 
| 427 | 428 | 
| 428   SequencedSocketData data(nullptr, 0, writes, arraysize(writes)); | 429   SequencedSocketData data(nullptr, 0, writes, arraysize(writes)); | 
| 429   std::unique_ptr<ClientSocketHandle> socket_handle = | 430   std::unique_ptr<ClientSocketHandle> socket_handle = | 
| 430       CreateConnectedSocketHandle(&data); | 431       CreateConnectedSocketHandle(&data); | 
| 431 | 432 | 
| 432   HttpRequestInfo request; | 433   HttpRequestInfo request; | 
| 433   request.method = "GET"; | 434   request.method = "GET"; | 
| 434   request.url = GURL("http://localhost"); | 435   request.url = GURL("http://localhost"); | 
| 435 | 436 | 
| 436   scoped_refptr<GrowableIOBuffer> read_buffer(new GrowableIOBuffer); | 437   scoped_refptr<GrowableIOBuffer> read_buffer(new GrowableIOBuffer); | 
| 437   HttpStreamParser parser(socket_handle.get(), &request, read_buffer.get(), | 438   HttpStreamParser parser(socket_handle.get(), &request, read_buffer.get(), | 
| 438                           BoundNetLog()); | 439                           NetLogWithSource()); | 
| 439 | 440 | 
| 440   HttpResponseInfo response; | 441   HttpResponseInfo response; | 
| 441   TestCompletionCallback callback; | 442   TestCompletionCallback callback; | 
| 442   EXPECT_EQ(OK, parser.SendRequest("GET / HTTP/1.1\r\n", HttpRequestHeaders(), | 443   EXPECT_EQ(OK, parser.SendRequest("GET / HTTP/1.1\r\n", HttpRequestHeaders(), | 
| 443                                    &response, callback.callback())); | 444                                    &response, callback.callback())); | 
| 444 | 445 | 
| 445   EXPECT_EQ(CountWriteBytes(writes, arraysize(writes)), parser.sent_bytes()); | 446   EXPECT_EQ(CountWriteBytes(writes, arraysize(writes)), parser.sent_bytes()); | 
| 446 } | 447 } | 
| 447 | 448 | 
| 448 TEST(HttpStreamParser, SentBytesWithHeaders) { | 449 TEST(HttpStreamParser, SentBytesWithHeaders) { | 
| 449   MockWrite writes[] = { | 450   MockWrite writes[] = { | 
| 450       MockWrite(SYNCHRONOUS, 0, | 451       MockWrite(SYNCHRONOUS, 0, | 
| 451                 "GET / HTTP/1.1\r\n" | 452                 "GET / HTTP/1.1\r\n" | 
| 452                 "Host: localhost\r\n" | 453                 "Host: localhost\r\n" | 
| 453                 "Connection: Keep-Alive\r\n\r\n"), | 454                 "Connection: Keep-Alive\r\n\r\n"), | 
| 454   }; | 455   }; | 
| 455 | 456 | 
| 456   SequencedSocketData data(nullptr, 0, writes, arraysize(writes)); | 457   SequencedSocketData data(nullptr, 0, writes, arraysize(writes)); | 
| 457   std::unique_ptr<ClientSocketHandle> socket_handle = | 458   std::unique_ptr<ClientSocketHandle> socket_handle = | 
| 458       CreateConnectedSocketHandle(&data); | 459       CreateConnectedSocketHandle(&data); | 
| 459 | 460 | 
| 460   HttpRequestInfo request; | 461   HttpRequestInfo request; | 
| 461   request.method = "GET"; | 462   request.method = "GET"; | 
| 462   request.url = GURL("http://localhost"); | 463   request.url = GURL("http://localhost"); | 
| 463 | 464 | 
| 464   scoped_refptr<GrowableIOBuffer> read_buffer(new GrowableIOBuffer); | 465   scoped_refptr<GrowableIOBuffer> read_buffer(new GrowableIOBuffer); | 
| 465   HttpStreamParser parser(socket_handle.get(), &request, read_buffer.get(), | 466   HttpStreamParser parser(socket_handle.get(), &request, read_buffer.get(), | 
| 466                           BoundNetLog()); | 467                           NetLogWithSource()); | 
| 467 | 468 | 
| 468   HttpRequestHeaders headers; | 469   HttpRequestHeaders headers; | 
| 469   headers.SetHeader("Host", "localhost"); | 470   headers.SetHeader("Host", "localhost"); | 
| 470   headers.SetHeader("Connection", "Keep-Alive"); | 471   headers.SetHeader("Connection", "Keep-Alive"); | 
| 471 | 472 | 
| 472   HttpResponseInfo response; | 473   HttpResponseInfo response; | 
| 473   TestCompletionCallback callback; | 474   TestCompletionCallback callback; | 
| 474   EXPECT_EQ(OK, parser.SendRequest("GET / HTTP/1.1\r\n", headers, &response, | 475   EXPECT_EQ(OK, parser.SendRequest("GET / HTTP/1.1\r\n", headers, &response, | 
| 475                                    callback.callback())); | 476                                    callback.callback())); | 
| 476 | 477 | 
| (...skipping 10 matching lines...) Expand all  Loading... | 
| 487   SequencedSocketData data(nullptr, 0, writes, arraysize(writes)); | 488   SequencedSocketData data(nullptr, 0, writes, arraysize(writes)); | 
| 488   std::unique_ptr<ClientSocketHandle> socket_handle = | 489   std::unique_ptr<ClientSocketHandle> socket_handle = | 
| 489       CreateConnectedSocketHandle(&data); | 490       CreateConnectedSocketHandle(&data); | 
| 490 | 491 | 
| 491   HttpRequestInfo request; | 492   HttpRequestInfo request; | 
| 492   request.method = "GET"; | 493   request.method = "GET"; | 
| 493   request.url = GURL("http://localhost"); | 494   request.url = GURL("http://localhost"); | 
| 494 | 495 | 
| 495   scoped_refptr<GrowableIOBuffer> read_buffer(new GrowableIOBuffer); | 496   scoped_refptr<GrowableIOBuffer> read_buffer(new GrowableIOBuffer); | 
| 496   HttpStreamParser parser(socket_handle.get(), &request, read_buffer.get(), | 497   HttpStreamParser parser(socket_handle.get(), &request, read_buffer.get(), | 
| 497                           BoundNetLog()); | 498                           NetLogWithSource()); | 
| 498 | 499 | 
| 499   HttpRequestHeaders headers; | 500   HttpRequestHeaders headers; | 
| 500   headers.SetHeader("Host", "localhost"); | 501   headers.SetHeader("Host", "localhost"); | 
| 501   headers.SetHeader("Connection", "Keep-Alive"); | 502   headers.SetHeader("Connection", "Keep-Alive"); | 
| 502 | 503 | 
| 503   HttpResponseInfo response; | 504   HttpResponseInfo response; | 
| 504   TestCompletionCallback callback; | 505   TestCompletionCallback callback; | 
| 505 | 506 | 
| 506   EXPECT_EQ(OK, parser.SendRequest("GET / HTTP/1.1\r\n", headers, &response, | 507   EXPECT_EQ(OK, parser.SendRequest("GET / HTTP/1.1\r\n", headers, &response, | 
| 507                                    callback.callback())); | 508                                    callback.callback())); | 
| (...skipping 11 matching lines...) Expand all  Loading... | 
| 519   SequencedSocketData data(nullptr, 0, writes, arraysize(writes)); | 520   SequencedSocketData data(nullptr, 0, writes, arraysize(writes)); | 
| 520   std::unique_ptr<ClientSocketHandle> socket_handle = | 521   std::unique_ptr<ClientSocketHandle> socket_handle = | 
| 521       CreateConnectedSocketHandle(&data); | 522       CreateConnectedSocketHandle(&data); | 
| 522 | 523 | 
| 523   HttpRequestInfo request; | 524   HttpRequestInfo request; | 
| 524   request.method = "GET"; | 525   request.method = "GET"; | 
| 525   request.url = GURL("http://localhost"); | 526   request.url = GURL("http://localhost"); | 
| 526 | 527 | 
| 527   scoped_refptr<GrowableIOBuffer> read_buffer(new GrowableIOBuffer); | 528   scoped_refptr<GrowableIOBuffer> read_buffer(new GrowableIOBuffer); | 
| 528   HttpStreamParser parser(socket_handle.get(), &request, read_buffer.get(), | 529   HttpStreamParser parser(socket_handle.get(), &request, read_buffer.get(), | 
| 529                           BoundNetLog()); | 530                           NetLogWithSource()); | 
| 530 | 531 | 
| 531   HttpRequestHeaders headers; | 532   HttpRequestHeaders headers; | 
| 532   headers.SetHeader("Host", "localhost"); | 533   headers.SetHeader("Host", "localhost"); | 
| 533   headers.SetHeader("Connection", "Keep-Alive"); | 534   headers.SetHeader("Connection", "Keep-Alive"); | 
| 534 | 535 | 
| 535   HttpResponseInfo response; | 536   HttpResponseInfo response; | 
| 536   TestCompletionCallback callback; | 537   TestCompletionCallback callback; | 
| 537   EXPECT_EQ(ERR_CONNECTION_RESET, | 538   EXPECT_EQ(ERR_CONNECTION_RESET, | 
| 538             parser.SendRequest("GET / HTTP/1.1\r\n", headers, &response, | 539             parser.SendRequest("GET / HTTP/1.1\r\n", headers, &response, | 
| 539                                callback.callback())); | 540                                callback.callback())); | 
| (...skipping 10 matching lines...) Expand all  Loading... | 
| 550 | 551 | 
| 551   SequencedSocketData data(nullptr, 0, writes, arraysize(writes)); | 552   SequencedSocketData data(nullptr, 0, writes, arraysize(writes)); | 
| 552   std::unique_ptr<ClientSocketHandle> socket_handle = | 553   std::unique_ptr<ClientSocketHandle> socket_handle = | 
| 553       CreateConnectedSocketHandle(&data); | 554       CreateConnectedSocketHandle(&data); | 
| 554 | 555 | 
| 555   std::vector<std::unique_ptr<UploadElementReader>> element_readers; | 556   std::vector<std::unique_ptr<UploadElementReader>> element_readers; | 
| 556   element_readers.push_back( | 557   element_readers.push_back( | 
| 557       base::MakeUnique<UploadBytesElementReader>("hello world!", 12)); | 558       base::MakeUnique<UploadBytesElementReader>("hello world!", 12)); | 
| 558   ElementsUploadDataStream upload_data_stream(std::move(element_readers), 0); | 559   ElementsUploadDataStream upload_data_stream(std::move(element_readers), 0); | 
| 559   ASSERT_THAT(upload_data_stream.Init(TestCompletionCallback().callback(), | 560   ASSERT_THAT(upload_data_stream.Init(TestCompletionCallback().callback(), | 
| 560                                       BoundNetLog()), | 561                                       NetLogWithSource()), | 
| 561               IsOk()); | 562               IsOk()); | 
| 562 | 563 | 
| 563   HttpRequestInfo request; | 564   HttpRequestInfo request; | 
| 564   request.method = "POST"; | 565   request.method = "POST"; | 
| 565   request.url = GURL("http://localhost"); | 566   request.url = GURL("http://localhost"); | 
| 566   request.upload_data_stream = &upload_data_stream; | 567   request.upload_data_stream = &upload_data_stream; | 
| 567 | 568 | 
| 568   scoped_refptr<GrowableIOBuffer> read_buffer(new GrowableIOBuffer); | 569   scoped_refptr<GrowableIOBuffer> read_buffer(new GrowableIOBuffer); | 
| 569   HttpStreamParser parser(socket_handle.get(), &request, read_buffer.get(), | 570   HttpStreamParser parser(socket_handle.get(), &request, read_buffer.get(), | 
| 570                           BoundNetLog()); | 571                           NetLogWithSource()); | 
| 571 | 572 | 
| 572   HttpRequestHeaders headers; | 573   HttpRequestHeaders headers; | 
| 573   headers.SetHeader("Content-Length", "12"); | 574   headers.SetHeader("Content-Length", "12"); | 
| 574 | 575 | 
| 575   HttpResponseInfo response; | 576   HttpResponseInfo response; | 
| 576   TestCompletionCallback callback; | 577   TestCompletionCallback callback; | 
| 577   EXPECT_EQ(OK, parser.SendRequest("POST / HTTP/1.1\r\n", headers, &response, | 578   EXPECT_EQ(OK, parser.SendRequest("POST / HTTP/1.1\r\n", headers, &response, | 
| 578                                    callback.callback())); | 579                                    callback.callback())); | 
| 579 | 580 | 
| 580   EXPECT_EQ(CountWriteBytes(writes, arraysize(writes)), parser.sent_bytes()); | 581   EXPECT_EQ(CountWriteBytes(writes, arraysize(writes)), parser.sent_bytes()); | 
| (...skipping 12 matching lines...) Expand all  Loading... | 
| 593       MockWrite(ASYNC, 2, "7\r\nChunk 1\r\n"), | 594       MockWrite(ASYNC, 2, "7\r\nChunk 1\r\n"), | 
| 594       MockWrite(SYNCHRONOUS, ERR_FAILED, 3), | 595       MockWrite(SYNCHRONOUS, ERR_FAILED, 3), | 
| 595   }; | 596   }; | 
| 596 | 597 | 
| 597   SequencedSocketData data(nullptr, 0, writes, arraysize(writes)); | 598   SequencedSocketData data(nullptr, 0, writes, arraysize(writes)); | 
| 598   std::unique_ptr<ClientSocketHandle> socket_handle = | 599   std::unique_ptr<ClientSocketHandle> socket_handle = | 
| 599       CreateConnectedSocketHandle(&data); | 600       CreateConnectedSocketHandle(&data); | 
| 600 | 601 | 
| 601   ChunkedUploadDataStream upload_data_stream(0); | 602   ChunkedUploadDataStream upload_data_stream(0); | 
| 602   ASSERT_THAT(upload_data_stream.Init(TestCompletionCallback().callback(), | 603   ASSERT_THAT(upload_data_stream.Init(TestCompletionCallback().callback(), | 
| 603                                       BoundNetLog()), | 604                                       NetLogWithSource()), | 
| 604               IsOk()); | 605               IsOk()); | 
| 605 | 606 | 
| 606   HttpRequestInfo request; | 607   HttpRequestInfo request; | 
| 607   request.method = "POST"; | 608   request.method = "POST"; | 
| 608   request.url = GURL("http://localhost"); | 609   request.url = GURL("http://localhost"); | 
| 609   request.upload_data_stream = &upload_data_stream; | 610   request.upload_data_stream = &upload_data_stream; | 
| 610 | 611 | 
| 611   scoped_refptr<GrowableIOBuffer> read_buffer(new GrowableIOBuffer); | 612   scoped_refptr<GrowableIOBuffer> read_buffer(new GrowableIOBuffer); | 
| 612   HttpStreamParser parser(socket_handle.get(), &request, read_buffer.get(), | 613   HttpStreamParser parser(socket_handle.get(), &request, read_buffer.get(), | 
| 613                           BoundNetLog()); | 614                           NetLogWithSource()); | 
| 614 | 615 | 
| 615   HttpRequestHeaders headers; | 616   HttpRequestHeaders headers; | 
| 616   headers.SetHeader("Transfer-Encoding", "chunked"); | 617   headers.SetHeader("Transfer-Encoding", "chunked"); | 
| 617 | 618 | 
| 618   HttpResponseInfo response; | 619   HttpResponseInfo response; | 
| 619   TestCompletionCallback callback; | 620   TestCompletionCallback callback; | 
| 620   EXPECT_EQ(ERR_IO_PENDING, parser.SendRequest("POST / HTTP/1.1\r\n", headers, | 621   EXPECT_EQ(ERR_IO_PENDING, parser.SendRequest("POST / HTTP/1.1\r\n", headers, | 
| 621                                                &response, callback.callback())); | 622                                                &response, callback.callback())); | 
| 622 | 623 | 
| 623   base::RunLoop().RunUntilIdle(); | 624   base::RunLoop().RunUntilIdle(); | 
| (...skipping 30 matching lines...) Expand all  Loading... | 
| 654   static const int kBodySize = 8; | 655   static const int kBodySize = 8; | 
| 655 | 656 | 
| 656   MockRead reads[] = { | 657   MockRead reads[] = { | 
| 657       MockRead(ASYNC, 3, "HTTP/1.1 200 OK\r\n"), | 658       MockRead(ASYNC, 3, "HTTP/1.1 200 OK\r\n"), | 
| 658       MockRead(ASYNC, 4, "Content-Length: 8\r\n\r\n"), | 659       MockRead(ASYNC, 4, "Content-Length: 8\r\n\r\n"), | 
| 659       MockRead(ASYNC, 5, "one.html"), | 660       MockRead(ASYNC, 5, "one.html"), | 
| 660       MockRead(SYNCHRONOUS, 0, 6),  // EOF | 661       MockRead(SYNCHRONOUS, 0, 6),  // EOF | 
| 661   }; | 662   }; | 
| 662 | 663 | 
| 663   ChunkedUploadDataStream upload_stream(0); | 664   ChunkedUploadDataStream upload_stream(0); | 
| 664   ASSERT_THAT( | 665   ASSERT_THAT(upload_stream.Init(TestCompletionCallback().callback(), | 
| 665       upload_stream.Init(TestCompletionCallback().callback(), BoundNetLog()), | 666                                  NetLogWithSource()), | 
| 666       IsOk()); | 667               IsOk()); | 
| 667 | 668 | 
| 668   SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); | 669   SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); | 
| 669   std::unique_ptr<ClientSocketHandle> socket_handle = | 670   std::unique_ptr<ClientSocketHandle> socket_handle = | 
| 670       CreateConnectedSocketHandle(&data); | 671       CreateConnectedSocketHandle(&data); | 
| 671 | 672 | 
| 672   HttpRequestInfo request_info; | 673   HttpRequestInfo request_info; | 
| 673   request_info.method = "GET"; | 674   request_info.method = "GET"; | 
| 674   request_info.url = GURL("http://localhost"); | 675   request_info.url = GURL("http://localhost"); | 
| 675   request_info.upload_data_stream = &upload_stream; | 676   request_info.upload_data_stream = &upload_stream; | 
| 676 | 677 | 
| 677   scoped_refptr<GrowableIOBuffer> read_buffer(new GrowableIOBuffer); | 678   scoped_refptr<GrowableIOBuffer> read_buffer(new GrowableIOBuffer); | 
| 678   HttpStreamParser parser(socket_handle.get(), &request_info, read_buffer.get(), | 679   HttpStreamParser parser(socket_handle.get(), &request_info, read_buffer.get(), | 
| 679                           BoundNetLog()); | 680                           NetLogWithSource()); | 
| 680 | 681 | 
| 681   HttpRequestHeaders request_headers; | 682   HttpRequestHeaders request_headers; | 
| 682   request_headers.SetHeader("Transfer-Encoding", "chunked"); | 683   request_headers.SetHeader("Transfer-Encoding", "chunked"); | 
| 683 | 684 | 
| 684   HttpResponseInfo response_info; | 685   HttpResponseInfo response_info; | 
| 685   TestCompletionCallback callback; | 686   TestCompletionCallback callback; | 
| 686   // This will attempt to Write() the initial request and headers, which will | 687   // This will attempt to Write() the initial request and headers, which will | 
| 687   // complete asynchronously. | 688   // complete asynchronously. | 
| 688   ASSERT_EQ(ERR_IO_PENDING, | 689   ASSERT_EQ(ERR_IO_PENDING, | 
| 689             parser.SendRequest("GET /one.html HTTP/1.1\r\n", request_headers, | 690             parser.SendRequest("GET /one.html HTTP/1.1\r\n", request_headers, | 
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 732   static const int kBodySize = 8; | 733   static const int kBodySize = 8; | 
| 733 | 734 | 
| 734   MockRead reads[] = { | 735   MockRead reads[] = { | 
| 735       MockRead(ASYNC, 3, "HTTP/1.1 200 OK\r\n"), | 736       MockRead(ASYNC, 3, "HTTP/1.1 200 OK\r\n"), | 
| 736       MockRead(ASYNC, 4, "Content-Length: 8\r\n\r\n"), | 737       MockRead(ASYNC, 4, "Content-Length: 8\r\n\r\n"), | 
| 737       MockRead(ASYNC, 5, "one.html"), | 738       MockRead(ASYNC, 5, "one.html"), | 
| 738       MockRead(SYNCHRONOUS, 0, 6),  // EOF | 739       MockRead(SYNCHRONOUS, 0, 6),  // EOF | 
| 739   }; | 740   }; | 
| 740 | 741 | 
| 741   ChunkedUploadDataStream upload_stream(0); | 742   ChunkedUploadDataStream upload_stream(0); | 
| 742   ASSERT_THAT( | 743   ASSERT_THAT(upload_stream.Init(TestCompletionCallback().callback(), | 
| 743       upload_stream.Init(TestCompletionCallback().callback(), BoundNetLog()), | 744                                  NetLogWithSource()), | 
| 744       IsOk()); | 745               IsOk()); | 
| 745   // Append the only chunk. | 746   // Append the only chunk. | 
| 746   upload_stream.AppendData(kChunk, arraysize(kChunk) - 1, true); | 747   upload_stream.AppendData(kChunk, arraysize(kChunk) - 1, true); | 
| 747 | 748 | 
| 748   SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); | 749   SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); | 
| 749   std::unique_ptr<ClientSocketHandle> socket_handle = | 750   std::unique_ptr<ClientSocketHandle> socket_handle = | 
| 750       CreateConnectedSocketHandle(&data); | 751       CreateConnectedSocketHandle(&data); | 
| 751 | 752 | 
| 752   HttpRequestInfo request_info; | 753   HttpRequestInfo request_info; | 
| 753   request_info.method = "GET"; | 754   request_info.method = "GET"; | 
| 754   request_info.url = GURL("http://localhost"); | 755   request_info.url = GURL("http://localhost"); | 
| 755   request_info.upload_data_stream = &upload_stream; | 756   request_info.upload_data_stream = &upload_stream; | 
| 756 | 757 | 
| 757   scoped_refptr<GrowableIOBuffer> read_buffer(new GrowableIOBuffer); | 758   scoped_refptr<GrowableIOBuffer> read_buffer(new GrowableIOBuffer); | 
| 758   HttpStreamParser parser(socket_handle.get(), &request_info, read_buffer.get(), | 759   HttpStreamParser parser(socket_handle.get(), &request_info, read_buffer.get(), | 
| 759                           BoundNetLog()); | 760                           NetLogWithSource()); | 
| 760 | 761 | 
| 761   HttpRequestHeaders request_headers; | 762   HttpRequestHeaders request_headers; | 
| 762   request_headers.SetHeader("Transfer-Encoding", "chunked"); | 763   request_headers.SetHeader("Transfer-Encoding", "chunked"); | 
| 763 | 764 | 
| 764   HttpResponseInfo response_info; | 765   HttpResponseInfo response_info; | 
| 765   TestCompletionCallback callback; | 766   TestCompletionCallback callback; | 
| 766   // This will attempt to Write() the initial request and headers, which will | 767   // This will attempt to Write() the initial request and headers, which will | 
| 767   // complete asynchronously. | 768   // complete asynchronously. | 
| 768   ASSERT_EQ(ERR_IO_PENDING, | 769   ASSERT_EQ(ERR_IO_PENDING, | 
| 769             parser.SendRequest("GET /one.html HTTP/1.1\r\n", request_headers, | 770             parser.SendRequest("GET /one.html HTTP/1.1\r\n", request_headers, | 
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 814 | 815 | 
| 815   MockRead reads[] = { | 816   MockRead reads[] = { | 
| 816     MockRead(ASYNC, 5, "HTTP/1.1 200 OK\r\n"), | 817     MockRead(ASYNC, 5, "HTTP/1.1 200 OK\r\n"), | 
| 817     MockRead(ASYNC, 6, "Content-Length: 8\r\n\r\n"), | 818     MockRead(ASYNC, 6, "Content-Length: 8\r\n\r\n"), | 
| 818     MockRead(ASYNC, 7, "one.html"), | 819     MockRead(ASYNC, 7, "one.html"), | 
| 819     MockRead(SYNCHRONOUS, 0, 8),  // EOF | 820     MockRead(SYNCHRONOUS, 0, 8),  // EOF | 
| 820   }; | 821   }; | 
| 821 | 822 | 
| 822   ChunkedUploadDataStream upload_stream(0); | 823   ChunkedUploadDataStream upload_stream(0); | 
| 823   upload_stream.AppendData(kChunk1, arraysize(kChunk1) - 1, false); | 824   upload_stream.AppendData(kChunk1, arraysize(kChunk1) - 1, false); | 
| 824   ASSERT_THAT( | 825   ASSERT_THAT(upload_stream.Init(TestCompletionCallback().callback(), | 
| 825       upload_stream.Init(TestCompletionCallback().callback(), BoundNetLog()), | 826                                  NetLogWithSource()), | 
| 826       IsOk()); | 827               IsOk()); | 
| 827 | 828 | 
| 828   SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); | 829   SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); | 
| 829   std::unique_ptr<ClientSocketHandle> socket_handle = | 830   std::unique_ptr<ClientSocketHandle> socket_handle = | 
| 830       CreateConnectedSocketHandle(&data); | 831       CreateConnectedSocketHandle(&data); | 
| 831 | 832 | 
| 832   HttpRequestInfo request_info; | 833   HttpRequestInfo request_info; | 
| 833   request_info.method = "GET"; | 834   request_info.method = "GET"; | 
| 834   request_info.url = GURL("http://localhost"); | 835   request_info.url = GURL("http://localhost"); | 
| 835   request_info.upload_data_stream = &upload_stream; | 836   request_info.upload_data_stream = &upload_stream; | 
| 836 | 837 | 
| 837   scoped_refptr<GrowableIOBuffer> read_buffer(new GrowableIOBuffer); | 838   scoped_refptr<GrowableIOBuffer> read_buffer(new GrowableIOBuffer); | 
| 838   HttpStreamParser parser( | 839   HttpStreamParser parser(socket_handle.get(), &request_info, read_buffer.get(), | 
| 839       socket_handle.get(), &request_info, read_buffer.get(), BoundNetLog()); | 840                           NetLogWithSource()); | 
| 840 | 841 | 
| 841   HttpRequestHeaders request_headers; | 842   HttpRequestHeaders request_headers; | 
| 842   request_headers.SetHeader("Transfer-Encoding", "chunked"); | 843   request_headers.SetHeader("Transfer-Encoding", "chunked"); | 
| 843 | 844 | 
| 844   HttpResponseInfo response_info; | 845   HttpResponseInfo response_info; | 
| 845   TestCompletionCallback callback; | 846   TestCompletionCallback callback; | 
| 846   // This will attempt to Write() the initial request and headers, which will | 847   // This will attempt to Write() the initial request and headers, which will | 
| 847   // complete asynchronously. | 848   // complete asynchronously. | 
| 848   ASSERT_EQ(ERR_IO_PENDING, | 849   ASSERT_EQ(ERR_IO_PENDING, | 
| 849             parser.SendRequest("GET /one.html HTTP/1.1\r\n", request_headers, | 850             parser.SendRequest("GET /one.html HTTP/1.1\r\n", request_headers, | 
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 898   const int kBodySize = 8; | 899   const int kBodySize = 8; | 
| 899 | 900 | 
| 900   MockRead reads[] = { | 901   MockRead reads[] = { | 
| 901       MockRead(ASYNC, 2, "HTTP/1.1 200 OK\r\n"), | 902       MockRead(ASYNC, 2, "HTTP/1.1 200 OK\r\n"), | 
| 902       MockRead(ASYNC, 3, "Content-Length: 8\r\n\r\n"), | 903       MockRead(ASYNC, 3, "Content-Length: 8\r\n\r\n"), | 
| 903       MockRead(ASYNC, 4, "one.html"), | 904       MockRead(ASYNC, 4, "one.html"), | 
| 904       MockRead(SYNCHRONOUS, 0, 5),  // EOF | 905       MockRead(SYNCHRONOUS, 0, 5),  // EOF | 
| 905   }; | 906   }; | 
| 906 | 907 | 
| 907   ChunkedUploadDataStream upload_stream(0); | 908   ChunkedUploadDataStream upload_stream(0); | 
| 908   ASSERT_THAT( | 909   ASSERT_THAT(upload_stream.Init(TestCompletionCallback().callback(), | 
| 909       upload_stream.Init(TestCompletionCallback().callback(), BoundNetLog()), | 910                                  NetLogWithSource()), | 
| 910       IsOk()); | 911               IsOk()); | 
| 911 | 912 | 
| 912   SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); | 913   SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); | 
| 913   std::unique_ptr<ClientSocketHandle> socket_handle = | 914   std::unique_ptr<ClientSocketHandle> socket_handle = | 
| 914       CreateConnectedSocketHandle(&data); | 915       CreateConnectedSocketHandle(&data); | 
| 915 | 916 | 
| 916   HttpRequestInfo request_info; | 917   HttpRequestInfo request_info; | 
| 917   request_info.method = "GET"; | 918   request_info.method = "GET"; | 
| 918   request_info.url = GURL("http://localhost"); | 919   request_info.url = GURL("http://localhost"); | 
| 919   request_info.upload_data_stream = &upload_stream; | 920   request_info.upload_data_stream = &upload_stream; | 
| 920 | 921 | 
| 921   scoped_refptr<GrowableIOBuffer> read_buffer(new GrowableIOBuffer); | 922   scoped_refptr<GrowableIOBuffer> read_buffer(new GrowableIOBuffer); | 
| 922   HttpStreamParser parser(socket_handle.get(), &request_info, read_buffer.get(), | 923   HttpStreamParser parser(socket_handle.get(), &request_info, read_buffer.get(), | 
| 923                           BoundNetLog()); | 924                           NetLogWithSource()); | 
| 924 | 925 | 
| 925   HttpRequestHeaders request_headers; | 926   HttpRequestHeaders request_headers; | 
| 926   request_headers.SetHeader("Transfer-Encoding", "chunked"); | 927   request_headers.SetHeader("Transfer-Encoding", "chunked"); | 
| 927 | 928 | 
| 928   HttpResponseInfo response_info; | 929   HttpResponseInfo response_info; | 
| 929   TestCompletionCallback callback; | 930   TestCompletionCallback callback; | 
| 930   // This will attempt to Write() the initial request and headers, which will | 931   // This will attempt to Write() the initial request and headers, which will | 
| 931   // complete asynchronously. | 932   // complete asynchronously. | 
| 932   ASSERT_EQ(ERR_IO_PENDING, | 933   ASSERT_EQ(ERR_IO_PENDING, | 
| 933             parser.SendRequest("GET /one.html HTTP/1.1\r\n", request_headers, | 934             parser.SendRequest("GET /one.html HTTP/1.1\r\n", request_headers, | 
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 971   const int kBodySize = 8; | 972   const int kBodySize = 8; | 
| 972 | 973 | 
| 973   MockRead reads[] = { | 974   MockRead reads[] = { | 
| 974       MockRead(ASYNC, 2, "HTTP/1.1 200 OK\r\n"), | 975       MockRead(ASYNC, 2, "HTTP/1.1 200 OK\r\n"), | 
| 975       MockRead(ASYNC, 3, "Content-Length: 8\r\n\r\n"), | 976       MockRead(ASYNC, 3, "Content-Length: 8\r\n\r\n"), | 
| 976       MockRead(ASYNC, 4, "one.html"), | 977       MockRead(ASYNC, 4, "one.html"), | 
| 977       MockRead(SYNCHRONOUS, 0, 5),  // EOF | 978       MockRead(SYNCHRONOUS, 0, 5),  // EOF | 
| 978   }; | 979   }; | 
| 979 | 980 | 
| 980   ChunkedUploadDataStream upload_stream(0); | 981   ChunkedUploadDataStream upload_stream(0); | 
| 981   ASSERT_THAT( | 982   ASSERT_THAT(upload_stream.Init(TestCompletionCallback().callback(), | 
| 982       upload_stream.Init(TestCompletionCallback().callback(), BoundNetLog()), | 983                                  NetLogWithSource()), | 
| 983       IsOk()); | 984               IsOk()); | 
| 984   // Append final empty chunk. | 985   // Append final empty chunk. | 
| 985   upload_stream.AppendData(nullptr, 0, true); | 986   upload_stream.AppendData(nullptr, 0, true); | 
| 986 | 987 | 
| 987   SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); | 988   SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); | 
| 988   std::unique_ptr<ClientSocketHandle> socket_handle = | 989   std::unique_ptr<ClientSocketHandle> socket_handle = | 
| 989       CreateConnectedSocketHandle(&data); | 990       CreateConnectedSocketHandle(&data); | 
| 990 | 991 | 
| 991   HttpRequestInfo request_info; | 992   HttpRequestInfo request_info; | 
| 992   request_info.method = "GET"; | 993   request_info.method = "GET"; | 
| 993   request_info.url = GURL("http://localhost"); | 994   request_info.url = GURL("http://localhost"); | 
| 994   request_info.upload_data_stream = &upload_stream; | 995   request_info.upload_data_stream = &upload_stream; | 
| 995 | 996 | 
| 996   scoped_refptr<GrowableIOBuffer> read_buffer(new GrowableIOBuffer); | 997   scoped_refptr<GrowableIOBuffer> read_buffer(new GrowableIOBuffer); | 
| 997   HttpStreamParser parser(socket_handle.get(), &request_info, read_buffer.get(), | 998   HttpStreamParser parser(socket_handle.get(), &request_info, read_buffer.get(), | 
| 998                           BoundNetLog()); | 999                           NetLogWithSource()); | 
| 999 | 1000 | 
| 1000   HttpRequestHeaders request_headers; | 1001   HttpRequestHeaders request_headers; | 
| 1001   request_headers.SetHeader("Transfer-Encoding", "chunked"); | 1002   request_headers.SetHeader("Transfer-Encoding", "chunked"); | 
| 1002 | 1003 | 
| 1003   HttpResponseInfo response_info; | 1004   HttpResponseInfo response_info; | 
| 1004   TestCompletionCallback callback; | 1005   TestCompletionCallback callback; | 
| 1005   // This will attempt to Write() the initial request and headers, which will | 1006   // This will attempt to Write() the initial request and headers, which will | 
| 1006   // complete asynchronously. | 1007   // complete asynchronously. | 
| 1007   ASSERT_EQ(ERR_IO_PENDING, | 1008   ASSERT_EQ(ERR_IO_PENDING, | 
| 1008             parser.SendRequest("GET /one.html HTTP/1.1\r\n", request_headers, | 1009             parser.SendRequest("GET /one.html HTTP/1.1\r\n", request_headers, | 
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1089       HttpRequestInfo request_info; | 1090       HttpRequestInfo request_info; | 
| 1090       request_info.method = "GET"; | 1091       request_info.method = "GET"; | 
| 1091       if (protocol == HTTP) { | 1092       if (protocol == HTTP) { | 
| 1092         request_info.url = GURL("http://localhost"); | 1093         request_info.url = GURL("http://localhost"); | 
| 1093       } else { | 1094       } else { | 
| 1094         request_info.url = GURL("https://localhost"); | 1095         request_info.url = GURL("https://localhost"); | 
| 1095       } | 1096       } | 
| 1096       request_info.load_flags = LOAD_NORMAL; | 1097       request_info.load_flags = LOAD_NORMAL; | 
| 1097 | 1098 | 
| 1098       scoped_refptr<GrowableIOBuffer> read_buffer(new GrowableIOBuffer); | 1099       scoped_refptr<GrowableIOBuffer> read_buffer(new GrowableIOBuffer); | 
| 1099       HttpStreamParser parser( | 1100       HttpStreamParser parser(socket_handle.get(), &request_info, | 
| 1100           socket_handle.get(), &request_info, read_buffer.get(), BoundNetLog()); | 1101                               read_buffer.get(), NetLogWithSource()); | 
| 1101 | 1102 | 
| 1102       HttpRequestHeaders request_headers; | 1103       HttpRequestHeaders request_headers; | 
| 1103       HttpResponseInfo response_info; | 1104       HttpResponseInfo response_info; | 
| 1104       TestCompletionCallback callback; | 1105       TestCompletionCallback callback; | 
| 1105       ASSERT_EQ(OK, parser.SendRequest("GET / HTTP/1.1\r\n", request_headers, | 1106       ASSERT_EQ(OK, parser.SendRequest("GET / HTTP/1.1\r\n", request_headers, | 
| 1106                                        &response_info, callback.callback())); | 1107                                        &response_info, callback.callback())); | 
| 1107 | 1108 | 
| 1108       int rv = parser.ReadResponseHeaders(callback.callback()); | 1109       int rv = parser.ReadResponseHeaders(callback.callback()); | 
| 1109       EXPECT_EQ(CountWriteBytes(writes, arraysize(writes)), | 1110       EXPECT_EQ(CountWriteBytes(writes, arraysize(writes)), | 
| 1110                 parser.sent_bytes()); | 1111                 parser.sent_bytes()); | 
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1146   SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); | 1147   SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); | 
| 1147   std::unique_ptr<ClientSocketHandle> socket_handle = | 1148   std::unique_ptr<ClientSocketHandle> socket_handle = | 
| 1148       CreateConnectedSocketHandle(&data); | 1149       CreateConnectedSocketHandle(&data); | 
| 1149 | 1150 | 
| 1150   HttpRequestInfo request_info; | 1151   HttpRequestInfo request_info; | 
| 1151   request_info.method = "GET"; | 1152   request_info.method = "GET"; | 
| 1152   request_info.url = GURL("http://localhost"); | 1153   request_info.url = GURL("http://localhost"); | 
| 1153   request_info.load_flags = LOAD_NORMAL; | 1154   request_info.load_flags = LOAD_NORMAL; | 
| 1154 | 1155 | 
| 1155   scoped_refptr<GrowableIOBuffer> read_buffer(new GrowableIOBuffer); | 1156   scoped_refptr<GrowableIOBuffer> read_buffer(new GrowableIOBuffer); | 
| 1156   HttpStreamParser parser( | 1157   HttpStreamParser parser(socket_handle.get(), &request_info, read_buffer.get(), | 
| 1157       socket_handle.get(), &request_info, read_buffer.get(), BoundNetLog()); | 1158                           NetLogWithSource()); | 
| 1158 | 1159 | 
| 1159   HttpRequestHeaders request_headers; | 1160   HttpRequestHeaders request_headers; | 
| 1160   HttpResponseInfo response_info; | 1161   HttpResponseInfo response_info; | 
| 1161   TestCompletionCallback callback; | 1162   TestCompletionCallback callback; | 
| 1162   ASSERT_EQ(OK, parser.SendRequest("GET / HTTP/1.1\r\n", request_headers, | 1163   ASSERT_EQ(OK, parser.SendRequest("GET / HTTP/1.1\r\n", request_headers, | 
| 1163                                    &response_info, callback.callback())); | 1164                                    &response_info, callback.callback())); | 
| 1164 | 1165 | 
| 1165   EXPECT_THAT(parser.ReadResponseHeaders(callback.callback()), IsOk()); | 1166   EXPECT_THAT(parser.ReadResponseHeaders(callback.callback()), IsOk()); | 
| 1166   ASSERT_TRUE(response_info.headers.get()); | 1167   ASSERT_TRUE(response_info.headers.get()); | 
| 1167   EXPECT_EQ(101, response_info.headers->response_code()); | 1168   EXPECT_EQ(101, response_info.headers->response_code()); | 
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1217     reads_.push_back(MockRead(SYNCHRONOUS, 0, sequence_number_++));  // EOF | 1218     reads_.push_back(MockRead(SYNCHRONOUS, 0, sequence_number_++));  // EOF | 
| 1218 | 1219 | 
| 1219     data_.reset(new SequencedSocketData(&reads_.front(), reads_.size(), | 1220     data_.reset(new SequencedSocketData(&reads_.front(), reads_.size(), | 
| 1220                                         &writes_.front(), writes_.size())); | 1221                                         &writes_.front(), writes_.size())); | 
| 1221     socket_handle_ = CreateConnectedSocketHandle(data_.get()); | 1222     socket_handle_ = CreateConnectedSocketHandle(data_.get()); | 
| 1222 | 1223 | 
| 1223     request_info_.method = "GET"; | 1224     request_info_.method = "GET"; | 
| 1224     request_info_.url = url_; | 1225     request_info_.url = url_; | 
| 1225     request_info_.load_flags = LOAD_NORMAL; | 1226     request_info_.load_flags = LOAD_NORMAL; | 
| 1226 | 1227 | 
| 1227     parser_.reset(new HttpStreamParser( | 1228     parser_.reset(new HttpStreamParser(socket_handle_.get(), &request_info_, | 
| 1228         socket_handle_.get(), &request_info_, read_buffer(), BoundNetLog())); | 1229                                        read_buffer(), NetLogWithSource())); | 
| 1229 | 1230 | 
| 1230     parser_->set_http_09_on_non_default_ports_enabled( | 1231     parser_->set_http_09_on_non_default_ports_enabled( | 
| 1231         http_09_on_non_default_ports_enabled_); | 1232         http_09_on_non_default_ports_enabled_); | 
| 1232 | 1233 | 
| 1233     TestCompletionCallback callback; | 1234     TestCompletionCallback callback; | 
| 1234     ASSERT_EQ(OK, parser_->SendRequest("GET / HTTP/1.1\r\n", request_headers_, | 1235     ASSERT_EQ(OK, parser_->SendRequest("GET / HTTP/1.1\r\n", request_headers_, | 
| 1235                                        &response_info_, callback.callback())); | 1236                                        &response_info_, callback.callback())); | 
| 1236   } | 1237   } | 
| 1237 | 1238 | 
| 1238   void ReadHeadersExpectingError(Error error) { | 1239   void ReadHeadersExpectingError(Error error) { | 
| (...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1590   SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); | 1591   SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); | 
| 1591   std::unique_ptr<ClientSocketHandle> socket_handle = | 1592   std::unique_ptr<ClientSocketHandle> socket_handle = | 
| 1592       CreateConnectedSocketHandle(&data); | 1593       CreateConnectedSocketHandle(&data); | 
| 1593 | 1594 | 
| 1594   std::unique_ptr<HttpRequestInfo> request_info(new HttpRequestInfo()); | 1595   std::unique_ptr<HttpRequestInfo> request_info(new HttpRequestInfo()); | 
| 1595   request_info->method = "GET"; | 1596   request_info->method = "GET"; | 
| 1596   request_info->url = GURL("http://somewhere/foo.html"); | 1597   request_info->url = GURL("http://somewhere/foo.html"); | 
| 1597 | 1598 | 
| 1598   scoped_refptr<GrowableIOBuffer> read_buffer(new GrowableIOBuffer); | 1599   scoped_refptr<GrowableIOBuffer> read_buffer(new GrowableIOBuffer); | 
| 1599   HttpStreamParser parser(socket_handle.get(), request_info.get(), | 1600   HttpStreamParser parser(socket_handle.get(), request_info.get(), | 
| 1600                           read_buffer.get(), BoundNetLog()); | 1601                           read_buffer.get(), NetLogWithSource()); | 
| 1601 | 1602 | 
| 1602   std::unique_ptr<HttpRequestHeaders> request_headers(new HttpRequestHeaders()); | 1603   std::unique_ptr<HttpRequestHeaders> request_headers(new HttpRequestHeaders()); | 
| 1603   std::unique_ptr<HttpResponseInfo> response_info(new HttpResponseInfo()); | 1604   std::unique_ptr<HttpResponseInfo> response_info(new HttpResponseInfo()); | 
| 1604   TestCompletionCallback callback; | 1605   TestCompletionCallback callback; | 
| 1605   ASSERT_EQ(OK, parser.SendRequest("GET /foo.html HTTP/1.1\r\n", | 1606   ASSERT_EQ(OK, parser.SendRequest("GET /foo.html HTTP/1.1\r\n", | 
| 1606             *request_headers, response_info.get(), callback.callback())); | 1607             *request_headers, response_info.get(), callback.callback())); | 
| 1607   ASSERT_THAT(parser.ReadResponseHeaders(callback.callback()), IsOk()); | 1608   ASSERT_THAT(parser.ReadResponseHeaders(callback.callback()), IsOk()); | 
| 1608 | 1609 | 
| 1609   // If the object that owns the HttpStreamParser is deleted, it takes the | 1610   // If the object that owns the HttpStreamParser is deleted, it takes the | 
| 1610   // objects passed to the HttpStreamParser with it. | 1611   // objects passed to the HttpStreamParser with it. | 
| 1611   request_info.reset(); | 1612   request_info.reset(); | 
| 1612   request_headers.reset(); | 1613   request_headers.reset(); | 
| 1613   response_info.reset(); | 1614   response_info.reset(); | 
| 1614 | 1615 | 
| 1615   scoped_refptr<IOBuffer> body_buffer(new IOBuffer(kBodySize)); | 1616   scoped_refptr<IOBuffer> body_buffer(new IOBuffer(kBodySize)); | 
| 1616   ASSERT_EQ(kBodySize, parser.ReadResponseBody( | 1617   ASSERT_EQ(kBodySize, parser.ReadResponseBody( | 
| 1617       body_buffer.get(), kBodySize, callback.callback())); | 1618       body_buffer.get(), kBodySize, callback.callback())); | 
| 1618 | 1619 | 
| 1619   EXPECT_EQ(CountWriteBytes(writes, arraysize(writes)), parser.sent_bytes()); | 1620   EXPECT_EQ(CountWriteBytes(writes, arraysize(writes)), parser.sent_bytes()); | 
| 1620   EXPECT_EQ(CountReadBytes(reads, arraysize(reads)), parser.received_bytes()); | 1621   EXPECT_EQ(CountReadBytes(reads, arraysize(reads)), parser.received_bytes()); | 
| 1621 } | 1622 } | 
| 1622 | 1623 | 
| 1623 }  // namespace | 1624 }  // namespace | 
| 1624 | 1625 | 
| 1625 }  // namespace net | 1626 }  // namespace net | 
| OLD | NEW | 
|---|