| 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/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/callback.h" | 9 #include "base/callback.h" |
| 10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
| (...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 481 const std::vector<char>& bytes_1, | 481 const std::vector<char>& bytes_1, |
| 482 const std::vector<char>& bytes_2) { | 482 const std::vector<char>& bytes_2) { |
| 483 // The request URL can be arbitrary but must have an HTTP or HTTPS scheme. | 483 // The request URL can be arbitrary but must have an HTTP or HTTPS scheme. |
| 484 GURL request_url("http://www.example.com"); | 484 GURL request_url("http://www.example.com"); |
| 485 net::URLRequest request(request_url, &delegate_, context_.get()); | 485 net::URLRequest request(request_url, &delegate_, context_.get()); |
| 486 request.set_method(method); | 486 request.set_method(method); |
| 487 if (content_type != NULL) | 487 if (content_type != NULL) |
| 488 request.SetExtraRequestHeaderByName(net::HttpRequestHeaders::kContentType, | 488 request.SetExtraRequestHeaderByName(net::HttpRequestHeaders::kContentType, |
| 489 content_type, | 489 content_type, |
| 490 true /* overwrite */); | 490 true /* overwrite */); |
| 491 request.AppendBytesToUpload(&(bytes_1[0]), bytes_1.size()); | 491 scoped_refptr<net::UploadData> upload_data(new net::UploadData()); |
| 492 net::UploadData* data = request.get_upload_mutable(); | 492 upload_data->AppendBytes(&(bytes_1[0]), bytes_1.size()); |
| 493 data->AppendFileRange(::FilePath(), 0, 0, base::Time()); | 493 upload_data->AppendFileRange(::FilePath(), 0, 0, base::Time()); |
| 494 request.AppendBytesToUpload(&(bytes_2[0]), bytes_2.size()); | 494 upload_data->AppendBytes(&(bytes_2[0]), bytes_2.size()); |
| 495 request.set_upload(upload_data); |
| 495 ipc_sender_.PushTask(base::Bind(&base::DoNothing)); | 496 ipc_sender_.PushTask(base::Bind(&base::DoNothing)); |
| 496 request.Start(); | 497 request.Start(); |
| 497 } | 498 } |
| 498 | 499 |
| 499 TEST_F(ExtensionWebRequestTest, AccessRequestBodyData) { | 500 TEST_F(ExtensionWebRequestTest, AccessRequestBodyData) { |
| 500 // We verify that URLRequest body is accessible to OnBeforeRequest listeners. | 501 // We verify that URLRequest body is accessible to OnBeforeRequest listeners. |
| 501 // These testing steps are repeated twice in a row: | 502 // These testing steps are repeated twice in a row: |
| 502 // 1. Register an extension requesting "requestBody" in ExtraInfoSpec and | 503 // 1. Register an extension requesting "requestBody" in ExtraInfoSpec and |
| 503 // file a POST URLRequest with a multipart-encoded form. See it getting | 504 // file a POST URLRequest with a multipart-encoded form. See it getting |
| 504 // parsed. | 505 // parsed. |
| (...skipping 1632 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2137 EXPECT_TRUE(credentials_set); | 2138 EXPECT_TRUE(credentials_set); |
| 2138 EXPECT_FALSE(auth3.Empty()); | 2139 EXPECT_FALSE(auth3.Empty()); |
| 2139 EXPECT_EQ(username, auth1.username()); | 2140 EXPECT_EQ(username, auth1.username()); |
| 2140 EXPECT_EQ(password, auth1.password()); | 2141 EXPECT_EQ(password, auth1.password()); |
| 2141 EXPECT_EQ(1u, warning_set.size()); | 2142 EXPECT_EQ(1u, warning_set.size()); |
| 2142 EXPECT_TRUE(HasWarning(warning_set, "extid2")); | 2143 EXPECT_TRUE(HasWarning(warning_set, "extid2")); |
| 2143 EXPECT_EQ(3u, capturing_net_log.GetSize()); | 2144 EXPECT_EQ(3u, capturing_net_log.GetSize()); |
| 2144 } | 2145 } |
| 2145 | 2146 |
| 2146 } // namespace extensions | 2147 } // namespace extensions |
| OLD | NEW |