OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 7634 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7645 EXPECT_TRUE(response->headers.get() != NULL); | 7645 EXPECT_TRUE(response->headers.get() != NULL); |
7646 EXPECT_EQ("HTTP/1.0 200 OK", response->headers->GetStatusLine()); | 7646 EXPECT_EQ("HTTP/1.0 200 OK", response->headers->GetStatusLine()); |
7647 | 7647 |
7648 std::string response_data; | 7648 std::string response_data; |
7649 rv = ReadTransaction(trans.get(), &response_data); | 7649 rv = ReadTransaction(trans.get(), &response_data); |
7650 EXPECT_EQ(ERR_CONTENT_LENGTH_MISMATCH, rv); | 7650 EXPECT_EQ(ERR_CONTENT_LENGTH_MISMATCH, rv); |
7651 } | 7651 } |
7652 | 7652 |
7653 TEST_P(HttpNetworkTransactionTest, UploadFileSmallerThanLength) { | 7653 TEST_P(HttpNetworkTransactionTest, UploadFileSmallerThanLength) { |
7654 base::FilePath temp_file_path; | 7654 base::FilePath temp_file_path; |
7655 ASSERT_TRUE(file_util::CreateTemporaryFile(&temp_file_path)); | 7655 ASSERT_TRUE(base::CreateTemporaryFile(&temp_file_path)); |
7656 const uint64 kFakeSize = 100000; // file is actually blank | 7656 const uint64 kFakeSize = 100000; // file is actually blank |
7657 UploadFileElementReader::ScopedOverridingContentLengthForTests | 7657 UploadFileElementReader::ScopedOverridingContentLengthForTests |
7658 overriding_content_length(kFakeSize); | 7658 overriding_content_length(kFakeSize); |
7659 | 7659 |
7660 ScopedVector<UploadElementReader> element_readers; | 7660 ScopedVector<UploadElementReader> element_readers; |
7661 element_readers.push_back( | 7661 element_readers.push_back( |
7662 new UploadFileElementReader(base::MessageLoopProxy::current().get(), | 7662 new UploadFileElementReader(base::MessageLoopProxy::current().get(), |
7663 temp_file_path, | 7663 temp_file_path, |
7664 0, | 7664 0, |
7665 kuint64max, | 7665 kuint64max, |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7701 std::string response_data; | 7701 std::string response_data; |
7702 rv = ReadTransaction(trans.get(), &response_data); | 7702 rv = ReadTransaction(trans.get(), &response_data); |
7703 EXPECT_EQ(OK, rv); | 7703 EXPECT_EQ(OK, rv); |
7704 EXPECT_EQ("hello world", response_data); | 7704 EXPECT_EQ("hello world", response_data); |
7705 | 7705 |
7706 base::DeleteFile(temp_file_path, false); | 7706 base::DeleteFile(temp_file_path, false); |
7707 } | 7707 } |
7708 | 7708 |
7709 TEST_P(HttpNetworkTransactionTest, UploadUnreadableFile) { | 7709 TEST_P(HttpNetworkTransactionTest, UploadUnreadableFile) { |
7710 base::FilePath temp_file; | 7710 base::FilePath temp_file; |
7711 ASSERT_TRUE(file_util::CreateTemporaryFile(&temp_file)); | 7711 ASSERT_TRUE(base::CreateTemporaryFile(&temp_file)); |
7712 std::string temp_file_content("Unreadable file."); | 7712 std::string temp_file_content("Unreadable file."); |
7713 ASSERT_TRUE(file_util::WriteFile(temp_file, temp_file_content.c_str(), | 7713 ASSERT_TRUE(file_util::WriteFile(temp_file, temp_file_content.c_str(), |
7714 temp_file_content.length())); | 7714 temp_file_content.length())); |
7715 ASSERT_TRUE(file_util::MakeFileUnreadable(temp_file)); | 7715 ASSERT_TRUE(file_util::MakeFileUnreadable(temp_file)); |
7716 | 7716 |
7717 ScopedVector<UploadElementReader> element_readers; | 7717 ScopedVector<UploadElementReader> element_readers; |
7718 element_readers.push_back( | 7718 element_readers.push_back( |
7719 new UploadFileElementReader(base::MessageLoopProxy::current().get(), | 7719 new UploadFileElementReader(base::MessageLoopProxy::current().get(), |
7720 temp_file, | 7720 temp_file, |
7721 0, | 7721 0, |
(...skipping 4556 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12278 // established, to let the HTTP request start. | 12278 // established, to let the HTTP request start. |
12279 ASSERT_EQ(OK, http_callback.WaitForResult()); | 12279 ASSERT_EQ(OK, http_callback.WaitForResult()); |
12280 std::string response_data; | 12280 std::string response_data; |
12281 ASSERT_EQ(OK, ReadTransaction(http_trans.get(), &response_data)); | 12281 ASSERT_EQ(OK, ReadTransaction(http_trans.get(), &response_data)); |
12282 EXPECT_EQ("falafel", response_data); | 12282 EXPECT_EQ("falafel", response_data); |
12283 | 12283 |
12284 EXPECT_EQ(1, GetIdleSocketCountInTransportSocketPool(session)); | 12284 EXPECT_EQ(1, GetIdleSocketCountInTransportSocketPool(session)); |
12285 } | 12285 } |
12286 | 12286 |
12287 } // namespace net | 12287 } // namespace net |
OLD | NEW |