Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(337)

Side by Side Diff: net/http/http_network_transaction_unittest.cc

Issue 2030353002: UploadDataStream now returns errors on failures (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixed issues and combined with HttpStreamParser cl due to dependencies Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698