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 7533 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7544 | 7544 |
7545 TEST_F(HttpNetworkTransactionSpdy2Test, UploadFileSmallerThanLength) { | 7545 TEST_F(HttpNetworkTransactionSpdy2Test, UploadFileSmallerThanLength) { |
7546 base::FilePath temp_file_path; | 7546 base::FilePath temp_file_path; |
7547 ASSERT_TRUE(file_util::CreateTemporaryFile(&temp_file_path)); | 7547 ASSERT_TRUE(file_util::CreateTemporaryFile(&temp_file_path)); |
7548 const uint64 kFakeSize = 100000; // file is actually blank | 7548 const uint64 kFakeSize = 100000; // file is actually blank |
7549 UploadFileElementReader::ScopedOverridingContentLengthForTests | 7549 UploadFileElementReader::ScopedOverridingContentLengthForTests |
7550 overriding_content_length(kFakeSize); | 7550 overriding_content_length(kFakeSize); |
7551 | 7551 |
7552 ScopedVector<UploadElementReader> element_readers; | 7552 ScopedVector<UploadElementReader> element_readers; |
7553 element_readers.push_back( | 7553 element_readers.push_back( |
7554 new UploadFileElementReader(base::MessageLoopProxy::current(), | 7554 new UploadFileElementReader(base::MessageLoopProxy::current().get(), |
7555 temp_file_path, 0, kuint64max, base::Time())); | 7555 temp_file_path, |
| 7556 0, |
| 7557 kuint64max, |
| 7558 base::Time())); |
7556 UploadDataStream upload_data_stream(&element_readers, 0); | 7559 UploadDataStream upload_data_stream(&element_readers, 0); |
7557 | 7560 |
7558 HttpRequestInfo request; | 7561 HttpRequestInfo request; |
7559 request.method = "POST"; | 7562 request.method = "POST"; |
7560 request.url = GURL("http://www.google.com/upload"); | 7563 request.url = GURL("http://www.google.com/upload"); |
7561 request.upload_data_stream = &upload_data_stream; | 7564 request.upload_data_stream = &upload_data_stream; |
7562 request.load_flags = 0; | 7565 request.load_flags = 0; |
7563 | 7566 |
7564 scoped_ptr<HttpTransaction> trans( | 7567 scoped_ptr<HttpTransaction> trans( |
7565 new HttpNetworkTransaction(DEFAULT_PRIORITY, | 7568 new HttpNetworkTransaction(DEFAULT_PRIORITY, |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7598 TEST_F(HttpNetworkTransactionSpdy2Test, UploadUnreadableFile) { | 7601 TEST_F(HttpNetworkTransactionSpdy2Test, UploadUnreadableFile) { |
7599 base::FilePath temp_file; | 7602 base::FilePath temp_file; |
7600 ASSERT_TRUE(file_util::CreateTemporaryFile(&temp_file)); | 7603 ASSERT_TRUE(file_util::CreateTemporaryFile(&temp_file)); |
7601 std::string temp_file_content("Unreadable file."); | 7604 std::string temp_file_content("Unreadable file."); |
7602 ASSERT_TRUE(file_util::WriteFile(temp_file, temp_file_content.c_str(), | 7605 ASSERT_TRUE(file_util::WriteFile(temp_file, temp_file_content.c_str(), |
7603 temp_file_content.length())); | 7606 temp_file_content.length())); |
7604 ASSERT_TRUE(file_util::MakeFileUnreadable(temp_file)); | 7607 ASSERT_TRUE(file_util::MakeFileUnreadable(temp_file)); |
7605 | 7608 |
7606 ScopedVector<UploadElementReader> element_readers; | 7609 ScopedVector<UploadElementReader> element_readers; |
7607 element_readers.push_back( | 7610 element_readers.push_back( |
7608 new UploadFileElementReader(base::MessageLoopProxy::current(), | 7611 new UploadFileElementReader(base::MessageLoopProxy::current().get(), |
7609 temp_file, 0, kuint64max, base::Time())); | 7612 temp_file, |
| 7613 0, |
| 7614 kuint64max, |
| 7615 base::Time())); |
7610 UploadDataStream upload_data_stream(&element_readers, 0); | 7616 UploadDataStream upload_data_stream(&element_readers, 0); |
7611 | 7617 |
7612 HttpRequestInfo request; | 7618 HttpRequestInfo request; |
7613 request.method = "POST"; | 7619 request.method = "POST"; |
7614 request.url = GURL("http://www.google.com/upload"); | 7620 request.url = GURL("http://www.google.com/upload"); |
7615 request.upload_data_stream = &upload_data_stream; | 7621 request.upload_data_stream = &upload_data_stream; |
7616 request.load_flags = 0; | 7622 request.load_flags = 0; |
7617 | 7623 |
7618 // If we try to upload an unreadable file, the network stack should report | 7624 // If we try to upload an unreadable file, the network stack should report |
7619 // the file size as zero and upload zero bytes for that file. | 7625 // 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... |
7655 TEST_F(HttpNetworkTransactionSpdy2Test, UnreadableUploadFileAfterAuthRestart) { | 7661 TEST_F(HttpNetworkTransactionSpdy2Test, UnreadableUploadFileAfterAuthRestart) { |
7656 base::FilePath temp_file; | 7662 base::FilePath temp_file; |
7657 ASSERT_TRUE(file_util::CreateTemporaryFile(&temp_file)); | 7663 ASSERT_TRUE(file_util::CreateTemporaryFile(&temp_file)); |
7658 std::string temp_file_contents("Unreadable file."); | 7664 std::string temp_file_contents("Unreadable file."); |
7659 std::string unreadable_contents(temp_file_contents.length(), '\0'); | 7665 std::string unreadable_contents(temp_file_contents.length(), '\0'); |
7660 ASSERT_TRUE(file_util::WriteFile(temp_file, temp_file_contents.c_str(), | 7666 ASSERT_TRUE(file_util::WriteFile(temp_file, temp_file_contents.c_str(), |
7661 temp_file_contents.length())); | 7667 temp_file_contents.length())); |
7662 | 7668 |
7663 ScopedVector<UploadElementReader> element_readers; | 7669 ScopedVector<UploadElementReader> element_readers; |
7664 element_readers.push_back( | 7670 element_readers.push_back( |
7665 new UploadFileElementReader(base::MessageLoopProxy::current(), | 7671 new UploadFileElementReader(base::MessageLoopProxy::current().get(), |
7666 temp_file, 0, kuint64max, base::Time())); | 7672 temp_file, |
| 7673 0, |
| 7674 kuint64max, |
| 7675 base::Time())); |
7667 UploadDataStream upload_data_stream(&element_readers, 0); | 7676 UploadDataStream upload_data_stream(&element_readers, 0); |
7668 | 7677 |
7669 HttpRequestInfo request; | 7678 HttpRequestInfo request; |
7670 request.method = "POST"; | 7679 request.method = "POST"; |
7671 request.url = GURL("http://www.google.com/upload"); | 7680 request.url = GURL("http://www.google.com/upload"); |
7672 request.upload_data_stream = &upload_data_stream; | 7681 request.upload_data_stream = &upload_data_stream; |
7673 request.load_flags = 0; | 7682 request.load_flags = 0; |
7674 | 7683 |
7675 scoped_ptr<HttpTransaction> trans( | 7684 scoped_ptr<HttpTransaction> trans( |
7676 new HttpNetworkTransaction(DEFAULT_PRIORITY, | 7685 new HttpNetworkTransaction(DEFAULT_PRIORITY, |
(...skipping 3715 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11392 EXPECT_EQ("hello!", response_data); | 11401 EXPECT_EQ("hello!", response_data); |
11393 EXPECT_FALSE( | 11402 EXPECT_FALSE( |
11394 session->spdy_session_pool()->HasSession(spdy_session_key_a)); | 11403 session->spdy_session_pool()->HasSession(spdy_session_key_a)); |
11395 EXPECT_FALSE( | 11404 EXPECT_FALSE( |
11396 session->spdy_session_pool()->HasSession(spdy_session_key_b)); | 11405 session->spdy_session_pool()->HasSession(spdy_session_key_b)); |
11397 | 11406 |
11398 HttpStreamFactory::SetNextProtos(std::vector<std::string>()); | 11407 HttpStreamFactory::SetNextProtos(std::vector<std::string>()); |
11399 } | 11408 } |
11400 | 11409 |
11401 } // namespace net | 11410 } // namespace net |
OLD | NEW |