OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <map> | 5 #include <map> |
6 #include <queue> | 6 #include <queue> |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
511 // The request URL can be arbitrary but must have an HTTP or HTTPS scheme. | 511 // The request URL can be arbitrary but must have an HTTP or HTTPS scheme. |
512 GURL request_url("http://www.example.com"); | 512 GURL request_url("http://www.example.com"); |
513 scoped_ptr<net::URLRequest> request(context_->CreateRequest( | 513 scoped_ptr<net::URLRequest> request(context_->CreateRequest( |
514 request_url, net::DEFAULT_PRIORITY, &delegate_)); | 514 request_url, net::DEFAULT_PRIORITY, &delegate_)); |
515 request->set_method(method); | 515 request->set_method(method); |
516 if (content_type != NULL) { | 516 if (content_type != NULL) { |
517 request->SetExtraRequestHeaderByName(net::HttpRequestHeaders::kContentType, | 517 request->SetExtraRequestHeaderByName(net::HttpRequestHeaders::kContentType, |
518 content_type, | 518 content_type, |
519 true /* overwrite */); | 519 true /* overwrite */); |
520 } | 520 } |
521 ScopedVector<net::UploadElementReader> element_readers; | 521 std::vector<scoped_ptr<net::UploadElementReader>> element_readers; |
522 element_readers.push_back(new net::UploadBytesElementReader( | 522 element_readers.push_back(make_scoped_ptr( |
523 &(bytes_1[0]), bytes_1.size())); | 523 new net::UploadBytesElementReader(&(bytes_1[0]), bytes_1.size()))); |
524 element_readers.push_back( | 524 element_readers.push_back(make_scoped_ptr(new net::UploadFileElementReader( |
525 new net::UploadFileElementReader( | 525 base::ThreadTaskRunnerHandle::Get().get(), base::FilePath(), 0, 0, |
526 base::ThreadTaskRunnerHandle::Get() | 526 base::Time()))); |
527 .get(), | 527 element_readers.push_back(make_scoped_ptr( |
528 base::FilePath(), | 528 new net::UploadBytesElementReader(&(bytes_2[0]), bytes_2.size()))); |
529 0, | |
530 0, | |
531 base::Time())); | |
532 element_readers.push_back( | |
533 new net::UploadBytesElementReader(&(bytes_2[0]), bytes_2.size())); | |
534 request->set_upload(make_scoped_ptr( | 529 request->set_upload(make_scoped_ptr( |
535 new net::ElementsUploadDataStream(element_readers.Pass(), 0))); | 530 new net::ElementsUploadDataStream(std::move(element_readers), 0))); |
536 ipc_sender_.PushTask(base::Bind(&base::DoNothing)); | 531 ipc_sender_.PushTask(base::Bind(&base::DoNothing)); |
537 request->Start(); | 532 request->Start(); |
538 } | 533 } |
539 | 534 |
540 TEST_F(ExtensionWebRequestTest, AccessRequestBodyData) { | 535 TEST_F(ExtensionWebRequestTest, AccessRequestBodyData) { |
541 // We verify that URLRequest body is accessible to OnBeforeRequest listeners. | 536 // We verify that URLRequest body is accessible to OnBeforeRequest listeners. |
542 // These testing steps are repeated twice in a row: | 537 // These testing steps are repeated twice in a row: |
543 // 1. Register an extension requesting "requestBody" in ExtraInfoSpec and | 538 // 1. Register an extension requesting "requestBody" in ExtraInfoSpec and |
544 // file a POST URLRequest with a multipart-encoded form. See it getting | 539 // file a POST URLRequest with a multipart-encoded form. See it getting |
545 // parsed. | 540 // parsed. |
(...skipping 1702 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2248 EXPECT_TRUE(credentials_set); | 2243 EXPECT_TRUE(credentials_set); |
2249 EXPECT_FALSE(auth3.Empty()); | 2244 EXPECT_FALSE(auth3.Empty()); |
2250 EXPECT_EQ(username, auth1.username()); | 2245 EXPECT_EQ(username, auth1.username()); |
2251 EXPECT_EQ(password, auth1.password()); | 2246 EXPECT_EQ(password, auth1.password()); |
2252 EXPECT_EQ(1u, warning_set.size()); | 2247 EXPECT_EQ(1u, warning_set.size()); |
2253 EXPECT_TRUE(HasWarning(warning_set, "extid2")); | 2248 EXPECT_TRUE(HasWarning(warning_set, "extid2")); |
2254 EXPECT_EQ(3u, capturing_net_log.GetSize()); | 2249 EXPECT_EQ(3u, capturing_net_log.GetSize()); |
2255 } | 2250 } |
2256 | 2251 |
2257 } // namespace extensions | 2252 } // namespace extensions |
OLD | NEW |