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 <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
(...skipping 9666 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9677 }; | 9677 }; |
9678 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0); | 9678 StaticSocketDataProvider data(data_reads, arraysize(data_reads), NULL, 0); |
9679 session_deps_.socket_factory->AddSocketDataProvider(&data); | 9679 session_deps_.socket_factory->AddSocketDataProvider(&data); |
9680 | 9680 |
9681 TestCompletionCallback callback; | 9681 TestCompletionCallback callback; |
9682 | 9682 |
9683 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); | 9683 int rv = trans->Start(&request, callback.callback(), BoundNetLog()); |
9684 EXPECT_EQ(ERR_IO_PENDING, rv); | 9684 EXPECT_EQ(ERR_IO_PENDING, rv); |
9685 | 9685 |
9686 rv = callback.WaitForResult(); | 9686 rv = callback.WaitForResult(); |
9687 EXPECT_EQ(OK, rv); | 9687 EXPECT_EQ(ERR_UPLOAD_FILE_CHANGED, rv); |
9688 | 9688 |
9689 const HttpResponseInfo* response = trans->GetResponseInfo(); | 9689 const HttpResponseInfo* response = trans->GetResponseInfo(); |
9690 ASSERT_TRUE(response); | 9690 ASSERT_TRUE(response); |
9691 | 9691 |
9692 EXPECT_TRUE(response->headers); | 9692 EXPECT_FALSE(response->headers); |
9693 EXPECT_EQ("HTTP/1.0 200 OK", response->headers->GetStatusLine()); | |
9694 | |
9695 std::string response_data; | |
9696 rv = ReadTransaction(trans.get(), &response_data); | |
9697 EXPECT_EQ(OK, rv); | |
9698 EXPECT_EQ("hello world", response_data); | |
9699 | 9693 |
9700 base::DeleteFile(temp_file_path, false); | 9694 base::DeleteFile(temp_file_path, false); |
9701 } | 9695 } |
9702 | 9696 |
9703 TEST_P(HttpNetworkTransactionTest, UploadUnreadableFile) { | 9697 TEST_P(HttpNetworkTransactionTest, UploadUnreadableFile) { |
9704 base::FilePath temp_file; | 9698 base::FilePath temp_file; |
9705 ASSERT_TRUE(base::CreateTemporaryFile(&temp_file)); | 9699 ASSERT_TRUE(base::CreateTemporaryFile(&temp_file)); |
9706 std::string temp_file_content("Unreadable file."); | 9700 std::string temp_file_content("Unreadable file."); |
9707 ASSERT_TRUE(base::WriteFile(temp_file, temp_file_content.c_str(), | 9701 ASSERT_TRUE(base::WriteFile(temp_file, temp_file_content.c_str(), |
9708 temp_file_content.length())); | 9702 temp_file_content.length())); |
(...skipping 6435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
16144 base::RunLoop().RunUntilIdle(); | 16138 base::RunLoop().RunUntilIdle(); |
16145 | 16139 |
16146 EXPECT_TRUE(trans.GetResponseInfo()->was_fetched_via_spdy); | 16140 EXPECT_TRUE(trans.GetResponseInfo()->was_fetched_via_spdy); |
16147 HttpRequestHeaders headers; | 16141 HttpRequestHeaders headers; |
16148 ASSERT_TRUE(trans.GetFullRequestHeaders(&headers)); | 16142 ASSERT_TRUE(trans.GetFullRequestHeaders(&headers)); |
16149 EXPECT_TRUE(headers.HasHeader(HttpRequestHeaders::kTokenBinding)); | 16143 EXPECT_TRUE(headers.HasHeader(HttpRequestHeaders::kTokenBinding)); |
16150 } | 16144 } |
16151 #endif // !defined(OS_IOS) | 16145 #endif // !defined(OS_IOS) |
16152 | 16146 |
16153 } // namespace net | 16147 } // namespace net |
OLD | NEW |