| 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 7519 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7530 | 7530 |
| 7531 TEST_F(HttpNetworkTransactionSpdy3Test, UploadFileSmallerThanLength) { | 7531 TEST_F(HttpNetworkTransactionSpdy3Test, UploadFileSmallerThanLength) { |
| 7532 base::FilePath temp_file_path; | 7532 base::FilePath temp_file_path; |
| 7533 ASSERT_TRUE(file_util::CreateTemporaryFile(&temp_file_path)); | 7533 ASSERT_TRUE(file_util::CreateTemporaryFile(&temp_file_path)); |
| 7534 const uint64 kFakeSize = 100000; // file is actually blank | 7534 const uint64 kFakeSize = 100000; // file is actually blank |
| 7535 UploadFileElementReader::ScopedOverridingContentLengthForTests | 7535 UploadFileElementReader::ScopedOverridingContentLengthForTests |
| 7536 overriding_content_length(kFakeSize); | 7536 overriding_content_length(kFakeSize); |
| 7537 | 7537 |
| 7538 ScopedVector<UploadElementReader> element_readers; | 7538 ScopedVector<UploadElementReader> element_readers; |
| 7539 element_readers.push_back( | 7539 element_readers.push_back( |
| 7540 new UploadFileElementReader(base::MessageLoopProxy::current(), | 7540 new UploadFileElementReader(base::MessageLoopProxy::current().get(), |
| 7541 temp_file_path, 0, kuint64max, base::Time())); | 7541 temp_file_path, |
| 7542 0, |
| 7543 kuint64max, |
| 7544 base::Time())); |
| 7542 UploadDataStream upload_data_stream(&element_readers, 0); | 7545 UploadDataStream upload_data_stream(&element_readers, 0); |
| 7543 | 7546 |
| 7544 HttpRequestInfo request; | 7547 HttpRequestInfo request; |
| 7545 request.method = "POST"; | 7548 request.method = "POST"; |
| 7546 request.url = GURL("http://www.google.com/upload"); | 7549 request.url = GURL("http://www.google.com/upload"); |
| 7547 request.upload_data_stream = &upload_data_stream; | 7550 request.upload_data_stream = &upload_data_stream; |
| 7548 request.load_flags = 0; | 7551 request.load_flags = 0; |
| 7549 | 7552 |
| 7550 scoped_ptr<HttpTransaction> trans( | 7553 scoped_ptr<HttpTransaction> trans( |
| 7551 new HttpNetworkTransaction(DEFAULT_PRIORITY, | 7554 new HttpNetworkTransaction(DEFAULT_PRIORITY, |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7584 TEST_F(HttpNetworkTransactionSpdy3Test, UploadUnreadableFile) { | 7587 TEST_F(HttpNetworkTransactionSpdy3Test, UploadUnreadableFile) { |
| 7585 base::FilePath temp_file; | 7588 base::FilePath temp_file; |
| 7586 ASSERT_TRUE(file_util::CreateTemporaryFile(&temp_file)); | 7589 ASSERT_TRUE(file_util::CreateTemporaryFile(&temp_file)); |
| 7587 std::string temp_file_content("Unreadable file."); | 7590 std::string temp_file_content("Unreadable file."); |
| 7588 ASSERT_TRUE(file_util::WriteFile(temp_file, temp_file_content.c_str(), | 7591 ASSERT_TRUE(file_util::WriteFile(temp_file, temp_file_content.c_str(), |
| 7589 temp_file_content.length())); | 7592 temp_file_content.length())); |
| 7590 ASSERT_TRUE(file_util::MakeFileUnreadable(temp_file)); | 7593 ASSERT_TRUE(file_util::MakeFileUnreadable(temp_file)); |
| 7591 | 7594 |
| 7592 ScopedVector<UploadElementReader> element_readers; | 7595 ScopedVector<UploadElementReader> element_readers; |
| 7593 element_readers.push_back( | 7596 element_readers.push_back( |
| 7594 new UploadFileElementReader(base::MessageLoopProxy::current(), | 7597 new UploadFileElementReader(base::MessageLoopProxy::current().get(), |
| 7595 temp_file, 0, kuint64max, base::Time())); | 7598 temp_file, |
| 7599 0, |
| 7600 kuint64max, |
| 7601 base::Time())); |
| 7596 UploadDataStream upload_data_stream(&element_readers, 0); | 7602 UploadDataStream upload_data_stream(&element_readers, 0); |
| 7597 | 7603 |
| 7598 HttpRequestInfo request; | 7604 HttpRequestInfo request; |
| 7599 request.method = "POST"; | 7605 request.method = "POST"; |
| 7600 request.url = GURL("http://www.google.com/upload"); | 7606 request.url = GURL("http://www.google.com/upload"); |
| 7601 request.upload_data_stream = &upload_data_stream; | 7607 request.upload_data_stream = &upload_data_stream; |
| 7602 request.load_flags = 0; | 7608 request.load_flags = 0; |
| 7603 | 7609 |
| 7604 // If we try to upload an unreadable file, the network stack should report | 7610 // If we try to upload an unreadable file, the network stack should report |
| 7605 // the file size as zero and upload zero bytes for that file. | 7611 // 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... |
| 7641 TEST_F(HttpNetworkTransactionSpdy3Test, UnreadableUploadFileAfterAuthRestart) { | 7647 TEST_F(HttpNetworkTransactionSpdy3Test, UnreadableUploadFileAfterAuthRestart) { |
| 7642 base::FilePath temp_file; | 7648 base::FilePath temp_file; |
| 7643 ASSERT_TRUE(file_util::CreateTemporaryFile(&temp_file)); | 7649 ASSERT_TRUE(file_util::CreateTemporaryFile(&temp_file)); |
| 7644 std::string temp_file_contents("Unreadable file."); | 7650 std::string temp_file_contents("Unreadable file."); |
| 7645 std::string unreadable_contents(temp_file_contents.length(), '\0'); | 7651 std::string unreadable_contents(temp_file_contents.length(), '\0'); |
| 7646 ASSERT_TRUE(file_util::WriteFile(temp_file, temp_file_contents.c_str(), | 7652 ASSERT_TRUE(file_util::WriteFile(temp_file, temp_file_contents.c_str(), |
| 7647 temp_file_contents.length())); | 7653 temp_file_contents.length())); |
| 7648 | 7654 |
| 7649 ScopedVector<UploadElementReader> element_readers; | 7655 ScopedVector<UploadElementReader> element_readers; |
| 7650 element_readers.push_back( | 7656 element_readers.push_back( |
| 7651 new UploadFileElementReader(base::MessageLoopProxy::current(), | 7657 new UploadFileElementReader(base::MessageLoopProxy::current().get(), |
| 7652 temp_file, 0, kuint64max, base::Time())); | 7658 temp_file, |
| 7659 0, |
| 7660 kuint64max, |
| 7661 base::Time())); |
| 7653 UploadDataStream upload_data_stream(&element_readers, 0); | 7662 UploadDataStream upload_data_stream(&element_readers, 0); |
| 7654 | 7663 |
| 7655 HttpRequestInfo request; | 7664 HttpRequestInfo request; |
| 7656 request.method = "POST"; | 7665 request.method = "POST"; |
| 7657 request.url = GURL("http://www.google.com/upload"); | 7666 request.url = GURL("http://www.google.com/upload"); |
| 7658 request.upload_data_stream = &upload_data_stream; | 7667 request.upload_data_stream = &upload_data_stream; |
| 7659 request.load_flags = 0; | 7668 request.load_flags = 0; |
| 7660 | 7669 |
| 7661 scoped_ptr<HttpTransaction> trans( | 7670 scoped_ptr<HttpTransaction> trans( |
| 7662 new HttpNetworkTransaction(DEFAULT_PRIORITY, | 7671 new HttpNetworkTransaction(DEFAULT_PRIORITY, |
| (...skipping 3682 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11345 EXPECT_EQ("hello!", response_data); | 11354 EXPECT_EQ("hello!", response_data); |
| 11346 EXPECT_FALSE( | 11355 EXPECT_FALSE( |
| 11347 session->spdy_session_pool()->HasSession(spdy_session_key_a)); | 11356 session->spdy_session_pool()->HasSession(spdy_session_key_a)); |
| 11348 EXPECT_FALSE( | 11357 EXPECT_FALSE( |
| 11349 session->spdy_session_pool()->HasSession(spdy_session_key_b)); | 11358 session->spdy_session_pool()->HasSession(spdy_session_key_b)); |
| 11350 | 11359 |
| 11351 HttpStreamFactory::SetNextProtos(std::vector<std::string>()); | 11360 HttpStreamFactory::SetNextProtos(std::vector<std::string>()); |
| 11352 } | 11361 } |
| 11353 | 11362 |
| 11354 } // namespace net | 11363 } // namespace net |
| OLD | NEW |