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 6513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6524 | 6524 |
6525 TEST_F(HttpNetworkTransactionSpdy3Test, UploadFileSmallerThanLength) { | 6525 TEST_F(HttpNetworkTransactionSpdy3Test, UploadFileSmallerThanLength) { |
6526 FilePath temp_file_path; | 6526 FilePath temp_file_path; |
6527 ASSERT_TRUE(file_util::CreateTemporaryFile(&temp_file_path)); | 6527 ASSERT_TRUE(file_util::CreateTemporaryFile(&temp_file_path)); |
6528 const uint64 kFakeSize = 100000; // file is actually blank | 6528 const uint64 kFakeSize = 100000; // file is actually blank |
6529 UploadFileElementReader::ScopedOverridingContentLengthForTests | 6529 UploadFileElementReader::ScopedOverridingContentLengthForTests |
6530 overriding_content_length(kFakeSize); | 6530 overriding_content_length(kFakeSize); |
6531 | 6531 |
6532 ScopedVector<UploadElementReader> element_readers; | 6532 ScopedVector<UploadElementReader> element_readers; |
6533 element_readers.push_back( | 6533 element_readers.push_back( |
6534 new UploadFileElementReader(temp_file_path, 0, kuint64max, base::Time())); | 6534 new UploadFileElementReader(base::MessageLoopProxy::current(), |
| 6535 temp_file_path, 0, kuint64max, base::Time())); |
6535 UploadDataStream upload_data_stream(&element_readers, 0); | 6536 UploadDataStream upload_data_stream(&element_readers, 0); |
6536 | 6537 |
6537 HttpRequestInfo request; | 6538 HttpRequestInfo request; |
6538 request.method = "POST"; | 6539 request.method = "POST"; |
6539 request.url = GURL("http://www.google.com/upload"); | 6540 request.url = GURL("http://www.google.com/upload"); |
6540 request.upload_data_stream = &upload_data_stream; | 6541 request.upload_data_stream = &upload_data_stream; |
6541 request.load_flags = 0; | 6542 request.load_flags = 0; |
6542 | 6543 |
6543 SpdySessionDependencies session_deps; | 6544 SpdySessionDependencies session_deps; |
6544 scoped_ptr<HttpTransaction> trans( | 6545 scoped_ptr<HttpTransaction> trans( |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6577 TEST_F(HttpNetworkTransactionSpdy3Test, UploadUnreadableFile) { | 6578 TEST_F(HttpNetworkTransactionSpdy3Test, UploadUnreadableFile) { |
6578 FilePath temp_file; | 6579 FilePath temp_file; |
6579 ASSERT_TRUE(file_util::CreateTemporaryFile(&temp_file)); | 6580 ASSERT_TRUE(file_util::CreateTemporaryFile(&temp_file)); |
6580 std::string temp_file_content("Unreadable file."); | 6581 std::string temp_file_content("Unreadable file."); |
6581 ASSERT_TRUE(file_util::WriteFile(temp_file, temp_file_content.c_str(), | 6582 ASSERT_TRUE(file_util::WriteFile(temp_file, temp_file_content.c_str(), |
6582 temp_file_content.length())); | 6583 temp_file_content.length())); |
6583 ASSERT_TRUE(file_util::MakeFileUnreadable(temp_file)); | 6584 ASSERT_TRUE(file_util::MakeFileUnreadable(temp_file)); |
6584 | 6585 |
6585 ScopedVector<UploadElementReader> element_readers; | 6586 ScopedVector<UploadElementReader> element_readers; |
6586 element_readers.push_back( | 6587 element_readers.push_back( |
6587 new UploadFileElementReader(temp_file, 0, kuint64max, base::Time())); | 6588 new UploadFileElementReader(base::MessageLoopProxy::current(), |
| 6589 temp_file, 0, kuint64max, base::Time())); |
6588 UploadDataStream upload_data_stream(&element_readers, 0); | 6590 UploadDataStream upload_data_stream(&element_readers, 0); |
6589 | 6591 |
6590 HttpRequestInfo request; | 6592 HttpRequestInfo request; |
6591 request.method = "POST"; | 6593 request.method = "POST"; |
6592 request.url = GURL("http://www.google.com/upload"); | 6594 request.url = GURL("http://www.google.com/upload"); |
6593 request.upload_data_stream = &upload_data_stream; | 6595 request.upload_data_stream = &upload_data_stream; |
6594 request.load_flags = 0; | 6596 request.load_flags = 0; |
6595 | 6597 |
6596 // If we try to upload an unreadable file, the network stack should report | 6598 // If we try to upload an unreadable file, the network stack should report |
6597 // the file size as zero and upload zero bytes for that file. | 6599 // the file size as zero and upload zero bytes for that file. |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6633 TEST_F(HttpNetworkTransactionSpdy3Test, UnreadableUploadFileAfterAuthRestart) { | 6635 TEST_F(HttpNetworkTransactionSpdy3Test, UnreadableUploadFileAfterAuthRestart) { |
6634 FilePath temp_file; | 6636 FilePath temp_file; |
6635 ASSERT_TRUE(file_util::CreateTemporaryFile(&temp_file)); | 6637 ASSERT_TRUE(file_util::CreateTemporaryFile(&temp_file)); |
6636 std::string temp_file_contents("Unreadable file."); | 6638 std::string temp_file_contents("Unreadable file."); |
6637 std::string unreadable_contents(temp_file_contents.length(), '\0'); | 6639 std::string unreadable_contents(temp_file_contents.length(), '\0'); |
6638 ASSERT_TRUE(file_util::WriteFile(temp_file, temp_file_contents.c_str(), | 6640 ASSERT_TRUE(file_util::WriteFile(temp_file, temp_file_contents.c_str(), |
6639 temp_file_contents.length())); | 6641 temp_file_contents.length())); |
6640 | 6642 |
6641 ScopedVector<UploadElementReader> element_readers; | 6643 ScopedVector<UploadElementReader> element_readers; |
6642 element_readers.push_back( | 6644 element_readers.push_back( |
6643 new UploadFileElementReader(temp_file, 0, kuint64max, base::Time())); | 6645 new UploadFileElementReader(base::MessageLoopProxy::current(), |
| 6646 temp_file, 0, kuint64max, base::Time())); |
6644 UploadDataStream upload_data_stream(&element_readers, 0); | 6647 UploadDataStream upload_data_stream(&element_readers, 0); |
6645 | 6648 |
6646 HttpRequestInfo request; | 6649 HttpRequestInfo request; |
6647 request.method = "POST"; | 6650 request.method = "POST"; |
6648 request.url = GURL("http://www.google.com/upload"); | 6651 request.url = GURL("http://www.google.com/upload"); |
6649 request.upload_data_stream = &upload_data_stream; | 6652 request.upload_data_stream = &upload_data_stream; |
6650 request.load_flags = 0; | 6653 request.load_flags = 0; |
6651 | 6654 |
6652 SpdySessionDependencies session_deps; | 6655 SpdySessionDependencies session_deps; |
6653 scoped_ptr<HttpTransaction> trans( | 6656 scoped_ptr<HttpTransaction> trans( |
(...skipping 3488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10142 trans2.Start(&request2, callback2.callback(), BoundNetLog())); | 10145 trans2.Start(&request2, callback2.callback(), BoundNetLog())); |
10143 MessageLoop::current()->RunUntilIdle(); | 10146 MessageLoop::current()->RunUntilIdle(); |
10144 data2->RunFor(3); | 10147 data2->RunFor(3); |
10145 | 10148 |
10146 ASSERT_TRUE(callback2.have_result()); | 10149 ASSERT_TRUE(callback2.have_result()); |
10147 EXPECT_EQ(OK, callback2.WaitForResult()); | 10150 EXPECT_EQ(OK, callback2.WaitForResult()); |
10148 EXPECT_TRUE(trans2.GetResponseInfo()->was_fetched_via_spdy); | 10151 EXPECT_TRUE(trans2.GetResponseInfo()->was_fetched_via_spdy); |
10149 } | 10152 } |
10150 | 10153 |
10151 } // namespace net | 10154 } // namespace net |
OLD | NEW |