| 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 7593 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7604 ASSERT_TRUE(response != NULL); | 7604 ASSERT_TRUE(response != NULL); |
| 7605 | 7605 |
| 7606 EXPECT_TRUE(response->headers.get() != NULL); | 7606 EXPECT_TRUE(response->headers.get() != NULL); |
| 7607 EXPECT_EQ("HTTP/1.0 200 OK", response->headers->GetStatusLine()); | 7607 EXPECT_EQ("HTTP/1.0 200 OK", response->headers->GetStatusLine()); |
| 7608 | 7608 |
| 7609 std::string response_data; | 7609 std::string response_data; |
| 7610 rv = ReadTransaction(trans.get(), &response_data); | 7610 rv = ReadTransaction(trans.get(), &response_data); |
| 7611 EXPECT_EQ(OK, rv); | 7611 EXPECT_EQ(OK, rv); |
| 7612 EXPECT_EQ("hello world", response_data); | 7612 EXPECT_EQ("hello world", response_data); |
| 7613 | 7613 |
| 7614 base::Delete(temp_file_path, false); | 7614 base::DeleteFile(temp_file_path, false); |
| 7615 } | 7615 } |
| 7616 | 7616 |
| 7617 TEST_P(HttpNetworkTransactionTest, UploadUnreadableFile) { | 7617 TEST_P(HttpNetworkTransactionTest, UploadUnreadableFile) { |
| 7618 base::FilePath temp_file; | 7618 base::FilePath temp_file; |
| 7619 ASSERT_TRUE(file_util::CreateTemporaryFile(&temp_file)); | 7619 ASSERT_TRUE(file_util::CreateTemporaryFile(&temp_file)); |
| 7620 std::string temp_file_content("Unreadable file."); | 7620 std::string temp_file_content("Unreadable file."); |
| 7621 ASSERT_TRUE(file_util::WriteFile(temp_file, temp_file_content.c_str(), | 7621 ASSERT_TRUE(file_util::WriteFile(temp_file, temp_file_content.c_str(), |
| 7622 temp_file_content.length())); | 7622 temp_file_content.length())); |
| 7623 ASSERT_TRUE(file_util::MakeFileUnreadable(temp_file)); | 7623 ASSERT_TRUE(file_util::MakeFileUnreadable(temp_file)); |
| 7624 | 7624 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7664 EXPECT_EQ(ERR_IO_PENDING, rv); | 7664 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 7665 | 7665 |
| 7666 rv = callback.WaitForResult(); | 7666 rv = callback.WaitForResult(); |
| 7667 EXPECT_EQ(OK, rv); | 7667 EXPECT_EQ(OK, rv); |
| 7668 | 7668 |
| 7669 const HttpResponseInfo* response = trans->GetResponseInfo(); | 7669 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 7670 ASSERT_TRUE(response != NULL); | 7670 ASSERT_TRUE(response != NULL); |
| 7671 EXPECT_TRUE(response->headers.get() != NULL); | 7671 EXPECT_TRUE(response->headers.get() != NULL); |
| 7672 EXPECT_EQ("HTTP/1.0 200 OK", response->headers->GetStatusLine()); | 7672 EXPECT_EQ("HTTP/1.0 200 OK", response->headers->GetStatusLine()); |
| 7673 | 7673 |
| 7674 base::Delete(temp_file, false); | 7674 base::DeleteFile(temp_file, false); |
| 7675 } | 7675 } |
| 7676 | 7676 |
| 7677 TEST_P(HttpNetworkTransactionTest, UnreadableUploadFileAfterAuthRestart) { | 7677 TEST_P(HttpNetworkTransactionTest, UnreadableUploadFileAfterAuthRestart) { |
| 7678 base::FilePath temp_file; | 7678 base::FilePath temp_file; |
| 7679 ASSERT_TRUE(file_util::CreateTemporaryFile(&temp_file)); | 7679 ASSERT_TRUE(file_util::CreateTemporaryFile(&temp_file)); |
| 7680 std::string temp_file_contents("Unreadable file."); | 7680 std::string temp_file_contents("Unreadable file."); |
| 7681 std::string unreadable_contents(temp_file_contents.length(), '\0'); | 7681 std::string unreadable_contents(temp_file_contents.length(), '\0'); |
| 7682 ASSERT_TRUE(file_util::WriteFile(temp_file, temp_file_contents.c_str(), | 7682 ASSERT_TRUE(file_util::WriteFile(temp_file, temp_file_contents.c_str(), |
| 7683 temp_file_contents.length())); | 7683 temp_file_contents.length())); |
| 7684 | 7684 |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7755 | 7755 |
| 7756 rv = callback2.WaitForResult(); | 7756 rv = callback2.WaitForResult(); |
| 7757 EXPECT_EQ(OK, rv); | 7757 EXPECT_EQ(OK, rv); |
| 7758 | 7758 |
| 7759 response = trans->GetResponseInfo(); | 7759 response = trans->GetResponseInfo(); |
| 7760 ASSERT_TRUE(response != NULL); | 7760 ASSERT_TRUE(response != NULL); |
| 7761 EXPECT_TRUE(response->headers.get() != NULL); | 7761 EXPECT_TRUE(response->headers.get() != NULL); |
| 7762 EXPECT_TRUE(response->auth_challenge.get() == NULL); | 7762 EXPECT_TRUE(response->auth_challenge.get() == NULL); |
| 7763 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 7763 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
| 7764 | 7764 |
| 7765 base::Delete(temp_file, false); | 7765 base::DeleteFile(temp_file, false); |
| 7766 } | 7766 } |
| 7767 | 7767 |
| 7768 // Tests that changes to Auth realms are treated like auth rejections. | 7768 // Tests that changes to Auth realms are treated like auth rejections. |
| 7769 TEST_P(HttpNetworkTransactionTest, ChangeAuthRealms) { | 7769 TEST_P(HttpNetworkTransactionTest, ChangeAuthRealms) { |
| 7770 | 7770 |
| 7771 HttpRequestInfo request; | 7771 HttpRequestInfo request; |
| 7772 request.method = "GET"; | 7772 request.method = "GET"; |
| 7773 request.url = GURL("http://www.google.com/"); | 7773 request.url = GURL("http://www.google.com/"); |
| 7774 request.load_flags = 0; | 7774 request.load_flags = 0; |
| 7775 | 7775 |
| (...skipping 3893 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11669 EXPECT_EQ(OK, rv); | 11669 EXPECT_EQ(OK, rv); |
| 11670 | 11670 |
| 11671 HttpRequestHeaders request_headers; | 11671 HttpRequestHeaders request_headers; |
| 11672 EXPECT_TRUE(trans->GetFullRequestHeaders(&request_headers)); | 11672 EXPECT_TRUE(trans->GetFullRequestHeaders(&request_headers)); |
| 11673 std::string foo; | 11673 std::string foo; |
| 11674 EXPECT_TRUE(request_headers.GetHeader("X-Foo", &foo)); | 11674 EXPECT_TRUE(request_headers.GetHeader("X-Foo", &foo)); |
| 11675 EXPECT_EQ("bar", foo); | 11675 EXPECT_EQ("bar", foo); |
| 11676 } | 11676 } |
| 11677 | 11677 |
| 11678 } // namespace net | 11678 } // namespace net |
| OLD | NEW |