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_network_transaction.h" | 5 #include "net/http/http_network_transaction.h" |
6 | 6 |
7 #include <math.h> // ceil | 7 #include <math.h> // ceil |
8 #include <stdarg.h> | 8 #include <stdarg.h> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 15 matching lines...) Expand all Loading... |
26 #include "net/base/host_cache.h" | 26 #include "net/base/host_cache.h" |
27 #include "net/base/mock_cert_verifier.h" | 27 #include "net/base/mock_cert_verifier.h" |
28 #include "net/base/mock_host_resolver.h" | 28 #include "net/base/mock_host_resolver.h" |
29 #include "net/base/net_log.h" | 29 #include "net/base/net_log.h" |
30 #include "net/base/net_log_unittest.h" | 30 #include "net/base/net_log_unittest.h" |
31 #include "net/base/request_priority.h" | 31 #include "net/base/request_priority.h" |
32 #include "net/base/ssl_cert_request_info.h" | 32 #include "net/base/ssl_cert_request_info.h" |
33 #include "net/base/ssl_config_service_defaults.h" | 33 #include "net/base/ssl_config_service_defaults.h" |
34 #include "net/base/ssl_info.h" | 34 #include "net/base/ssl_info.h" |
35 #include "net/base/test_completion_callback.h" | 35 #include "net/base/test_completion_callback.h" |
36 #include "net/base/upload_data.h" | 36 #include "net/base/upload_file_element_reader.h" |
37 #include "net/http/http_auth_handler_digest.h" | 37 #include "net/http/http_auth_handler_digest.h" |
38 #include "net/http/http_auth_handler_mock.h" | 38 #include "net/http/http_auth_handler_mock.h" |
39 #include "net/http/http_auth_handler_ntlm.h" | 39 #include "net/http/http_auth_handler_ntlm.h" |
40 #include "net/http/http_basic_stream.h" | 40 #include "net/http/http_basic_stream.h" |
41 #include "net/http/http_network_session.h" | 41 #include "net/http/http_network_session.h" |
42 #include "net/http/http_network_session_peer.h" | 42 #include "net/http/http_network_session_peer.h" |
43 #include "net/http/http_server_properties_impl.h" | 43 #include "net/http/http_server_properties_impl.h" |
44 #include "net/http/http_stream.h" | 44 #include "net/http/http_stream.h" |
45 #include "net/http/http_stream_factory.h" | 45 #include "net/http/http_stream_factory.h" |
46 #include "net/http/http_transaction_unittest.h" | 46 #include "net/http/http_transaction_unittest.h" |
(...skipping 6442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6489 request.upload_data = new UploadData; | 6489 request.upload_data = new UploadData; |
6490 request.load_flags = 0; | 6490 request.load_flags = 0; |
6491 | 6491 |
6492 SessionDependencies session_deps; | 6492 SessionDependencies session_deps; |
6493 scoped_ptr<HttpTransaction> trans( | 6493 scoped_ptr<HttpTransaction> trans( |
6494 new HttpNetworkTransaction(CreateSession(&session_deps))); | 6494 new HttpNetworkTransaction(CreateSession(&session_deps))); |
6495 | 6495 |
6496 FilePath temp_file_path; | 6496 FilePath temp_file_path; |
6497 ASSERT_TRUE(file_util::CreateTemporaryFile(&temp_file_path)); | 6497 ASSERT_TRUE(file_util::CreateTemporaryFile(&temp_file_path)); |
6498 const uint64 kFakeSize = 100000; // file is actually blank | 6498 const uint64 kFakeSize = 100000; // file is actually blank |
| 6499 UploadFileElementReader::ScopedOverridingContentLengthForTests |
| 6500 overriding_content_length(kFakeSize); |
6499 | 6501 |
6500 std::vector<UploadElement> elements; | 6502 std::vector<UploadElement> elements; |
6501 UploadElement element; | 6503 UploadElement element; |
6502 element.SetToFilePath(temp_file_path); | 6504 element.SetToFilePath(temp_file_path); |
6503 element.SetContentLength(kFakeSize); | |
6504 elements.push_back(element); | 6505 elements.push_back(element); |
6505 request.upload_data->SetElements(elements); | 6506 request.upload_data->SetElements(elements); |
6506 | 6507 |
6507 MockRead data_reads[] = { | 6508 MockRead data_reads[] = { |
6508 MockRead("HTTP/1.0 200 OK\r\n\r\n"), | 6509 MockRead("HTTP/1.0 200 OK\r\n\r\n"), |
6509 MockRead("hello world"), | 6510 MockRead("hello world"), |
6510 MockRead(SYNCHRONOUS, OK), | 6511 MockRead(SYNCHRONOUS, OK), |
6511 }; | 6512 }; |
6512 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0); | 6513 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0); |
6513 session_deps.socket_factory.AddSocketDataProvider(&data); | 6514 session_deps.socket_factory.AddSocketDataProvider(&data); |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6627 MockWrite data_writes[] = { | 6628 MockWrite data_writes[] = { |
6628 MockWrite("POST /upload HTTP/1.1\r\n" | 6629 MockWrite("POST /upload HTTP/1.1\r\n" |
6629 "Host: www.google.com\r\n" | 6630 "Host: www.google.com\r\n" |
6630 "Connection: keep-alive\r\n" | 6631 "Connection: keep-alive\r\n" |
6631 "Content-Length: 16\r\n\r\n"), | 6632 "Content-Length: 16\r\n\r\n"), |
6632 MockWrite(SYNCHRONOUS, temp_file_contents.c_str()), | 6633 MockWrite(SYNCHRONOUS, temp_file_contents.c_str()), |
6633 | 6634 |
6634 MockWrite("POST /upload HTTP/1.1\r\n" | 6635 MockWrite("POST /upload HTTP/1.1\r\n" |
6635 "Host: www.google.com\r\n" | 6636 "Host: www.google.com\r\n" |
6636 "Connection: keep-alive\r\n" | 6637 "Connection: keep-alive\r\n" |
6637 "Content-Length: 16\r\n" | 6638 "Content-Length: 0\r\n" |
6638 "Authorization: Basic Zm9vOmJhcg==\r\n\r\n"), | 6639 "Authorization: Basic Zm9vOmJhcg==\r\n\r\n"), |
6639 MockWrite(SYNCHRONOUS, unreadable_contents.c_str(), | 6640 MockWrite(SYNCHRONOUS, unreadable_contents.c_str(), |
6640 temp_file_contents.length()), | 6641 temp_file_contents.length()), |
6641 MockWrite(SYNCHRONOUS, OK), | 6642 MockWrite(SYNCHRONOUS, OK), |
6642 }; | 6643 }; |
6643 StaticSocketDataProvider data(data_reads, arraysize(data_reads), data_writes, | 6644 StaticSocketDataProvider data(data_reads, arraysize(data_reads), data_writes, |
6644 arraysize(data_writes)); | 6645 arraysize(data_writes)); |
6645 session_deps.socket_factory.AddSocketDataProvider(&data); | 6646 session_deps.socket_factory.AddSocketDataProvider(&data); |
6646 | 6647 |
6647 TestCompletionCallback callback1; | 6648 TestCompletionCallback callback1; |
(...skipping 3481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10129 trans2.Start(&request2, callback2.callback(), BoundNetLog())); | 10130 trans2.Start(&request2, callback2.callback(), BoundNetLog())); |
10130 MessageLoop::current()->RunAllPending(); | 10131 MessageLoop::current()->RunAllPending(); |
10131 data2->RunFor(3); | 10132 data2->RunFor(3); |
10132 | 10133 |
10133 ASSERT_TRUE(callback2.have_result()); | 10134 ASSERT_TRUE(callback2.have_result()); |
10134 EXPECT_EQ(OK, callback2.WaitForResult()); | 10135 EXPECT_EQ(OK, callback2.WaitForResult()); |
10135 EXPECT_TRUE(trans2.GetResponseInfo()->was_fetched_via_spdy); | 10136 EXPECT_TRUE(trans2.GetResponseInfo()->was_fetched_via_spdy); |
10136 } | 10137 } |
10137 | 10138 |
10138 } // namespace net | 10139 } // namespace net |
OLD | NEW |