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

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

Issue 1841863002: Update monet. (Closed) Base URL: https://github.com/domokit/monet.git@master
Patch Set: Created 4 years, 8 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
« no previous file with comments | « net/http/http_network_transaction.cc ('k') | net/http/http_request_headers.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/basictypes.h" 12 #include "base/basictypes.h"
13 #include "base/compiler_specific.h" 13 #include "base/compiler_specific.h"
14 #include "base/files/file_path.h" 14 #include "base/files/file_path.h"
15 #include "base/files/file_util.h" 15 #include "base/files/file_util.h"
16 #include "base/json/json_writer.h" 16 #include "base/json/json_writer.h"
17 #include "base/logging.h" 17 #include "base/logging.h"
18 #include "base/memory/scoped_ptr.h" 18 #include "base/memory/scoped_ptr.h"
19 #include "base/memory/weak_ptr.h" 19 #include "base/memory/weak_ptr.h"
20 #include "base/run_loop.h" 20 #include "base/run_loop.h"
21 #include "base/stl_util.h" 21 #include "base/stl_util.h"
22 #include "base/strings/string_util.h" 22 #include "base/strings/string_util.h"
23 #include "base/strings/utf_string_conversions.h" 23 #include "base/strings/utf_string_conversions.h"
24 #include "base/test/test_file_util.h" 24 #include "base/test/test_file_util.h"
25 #include "base/thread_task_runner_handle.h"
25 #include "net/base/auth.h" 26 #include "net/base/auth.h"
26 #include "net/base/chunked_upload_data_stream.h" 27 #include "net/base/chunked_upload_data_stream.h"
27 #include "net/base/completion_callback.h" 28 #include "net/base/completion_callback.h"
28 #include "net/base/elements_upload_data_stream.h" 29 #include "net/base/elements_upload_data_stream.h"
29 #include "net/base/load_timing_info.h" 30 #include "net/base/load_timing_info.h"
30 #include "net/base/load_timing_info_test_util.h" 31 #include "net/base/load_timing_info_test_util.h"
31 #include "net/base/net_errors.h" 32 #include "net/base/net_errors.h"
32 #include "net/base/request_priority.h" 33 #include "net/base/request_priority.h"
33 #include "net/base/test_completion_callback.h" 34 #include "net/base/test_completion_callback.h"
34 #include "net/base/test_data_directory.h" 35 #include "net/base/test_data_directory.h"
(...skipping 8399 matching lines...) Expand 10 before | Expand all | Expand 10 after
8434 8435
8435 TEST_P(HttpNetworkTransactionTest, UploadFileSmallerThanLength) { 8436 TEST_P(HttpNetworkTransactionTest, UploadFileSmallerThanLength) {
8436 base::FilePath temp_file_path; 8437 base::FilePath temp_file_path;
8437 ASSERT_TRUE(base::CreateTemporaryFile(&temp_file_path)); 8438 ASSERT_TRUE(base::CreateTemporaryFile(&temp_file_path));
8438 const uint64 kFakeSize = 100000; // file is actually blank 8439 const uint64 kFakeSize = 100000; // file is actually blank
8439 UploadFileElementReader::ScopedOverridingContentLengthForTests 8440 UploadFileElementReader::ScopedOverridingContentLengthForTests
8440 overriding_content_length(kFakeSize); 8441 overriding_content_length(kFakeSize);
8441 8442
8442 ScopedVector<UploadElementReader> element_readers; 8443 ScopedVector<UploadElementReader> element_readers;
8443 element_readers.push_back( 8444 element_readers.push_back(
8444 new UploadFileElementReader(base::MessageLoopProxy::current().get(), 8445 new UploadFileElementReader(base::ThreadTaskRunnerHandle::Get().get(),
8445 temp_file_path, 8446 temp_file_path, 0, kuint64max, base::Time()));
8446 0,
8447 kuint64max,
8448 base::Time()));
8449 ElementsUploadDataStream upload_data_stream(element_readers.Pass(), 0); 8447 ElementsUploadDataStream upload_data_stream(element_readers.Pass(), 0);
8450 8448
8451 HttpRequestInfo request; 8449 HttpRequestInfo request;
8452 request.method = "POST"; 8450 request.method = "POST";
8453 request.url = GURL("http://www.example.org/upload"); 8451 request.url = GURL("http://www.example.org/upload");
8454 request.upload_data_stream = &upload_data_stream; 8452 request.upload_data_stream = &upload_data_stream;
8455 request.load_flags = 0; 8453 request.load_flags = 0;
8456 8454
8457 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 8455 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
8458 scoped_ptr<HttpTransaction> trans( 8456 scoped_ptr<HttpTransaction> trans(
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
8491 TEST_P(HttpNetworkTransactionTest, UploadUnreadableFile) { 8489 TEST_P(HttpNetworkTransactionTest, UploadUnreadableFile) {
8492 base::FilePath temp_file; 8490 base::FilePath temp_file;
8493 ASSERT_TRUE(base::CreateTemporaryFile(&temp_file)); 8491 ASSERT_TRUE(base::CreateTemporaryFile(&temp_file));
8494 std::string temp_file_content("Unreadable file."); 8492 std::string temp_file_content("Unreadable file.");
8495 ASSERT_TRUE(base::WriteFile(temp_file, temp_file_content.c_str(), 8493 ASSERT_TRUE(base::WriteFile(temp_file, temp_file_content.c_str(),
8496 temp_file_content.length())); 8494 temp_file_content.length()));
8497 ASSERT_TRUE(base::MakeFileUnreadable(temp_file)); 8495 ASSERT_TRUE(base::MakeFileUnreadable(temp_file));
8498 8496
8499 ScopedVector<UploadElementReader> element_readers; 8497 ScopedVector<UploadElementReader> element_readers;
8500 element_readers.push_back( 8498 element_readers.push_back(
8501 new UploadFileElementReader(base::MessageLoopProxy::current().get(), 8499 new UploadFileElementReader(base::ThreadTaskRunnerHandle::Get().get(),
8502 temp_file, 8500 temp_file, 0, kuint64max, base::Time()));
8503 0,
8504 kuint64max,
8505 base::Time()));
8506 ElementsUploadDataStream upload_data_stream(element_readers.Pass(), 0); 8501 ElementsUploadDataStream upload_data_stream(element_readers.Pass(), 0);
8507 8502
8508 HttpRequestInfo request; 8503 HttpRequestInfo request;
8509 request.method = "POST"; 8504 request.method = "POST";
8510 request.url = GURL("http://www.example.org/upload"); 8505 request.url = GURL("http://www.example.org/upload");
8511 request.upload_data_stream = &upload_data_stream; 8506 request.upload_data_stream = &upload_data_stream;
8512 request.load_flags = 0; 8507 request.load_flags = 0;
8513 8508
8514 // If we try to upload an unreadable file, the transaction should fail. 8509 // If we try to upload an unreadable file, the transaction should fail.
8515 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); 8510 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_));
(...skipping 5737 matching lines...) Expand 10 before | Expand all | Expand 10 after
14253 ASSERT_TRUE(response); 14248 ASSERT_TRUE(response);
14254 ASSERT_TRUE(response->headers.get()); 14249 ASSERT_TRUE(response->headers.get());
14255 14250
14256 EXPECT_EQ(101, response->headers->response_code()); 14251 EXPECT_EQ(101, response->headers->response_code());
14257 14252
14258 trans.reset(); 14253 trans.reset();
14259 session->CloseAllConnections(); 14254 session->CloseAllConnections();
14260 } 14255 }
14261 14256
14262 } // namespace net 14257 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_network_transaction.cc ('k') | net/http/http_request_headers.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698