Index: content/browser/frame_host/navigation_handle_impl.cc |
diff --git a/content/browser/frame_host/navigation_handle_impl.cc b/content/browser/frame_host/navigation_handle_impl.cc |
index 240eba7416107135f096249c2f9b94954e080c84..26456034434a5bffc8ae0e62ec8060d8cd9e8d1b 100644 |
--- a/content/browser/frame_host/navigation_handle_impl.cc |
+++ b/content/browser/frame_host/navigation_handle_impl.cc |
@@ -6,16 +6,20 @@ |
#include <utility> |
+#include "base/logging.h" |
#include "content/browser/frame_host/frame_tree_node.h" |
#include "content/browser/frame_host/navigator.h" |
#include "content/browser/frame_host/navigator_delegate.h" |
#include "content/browser/service_worker/service_worker_context_wrapper.h" |
#include "content/browser/service_worker/service_worker_navigation_handle.h" |
#include "content/common/frame_messages.h" |
+#include "content/common/resource_request_body.h" |
#include "content/public/browser/content_browser_client.h" |
#include "content/public/common/browser_side_navigation_policy.h" |
#include "content/public/common/content_client.h" |
#include "net/url_request/redirect_info.h" |
+#include "url/gurl.h" |
+#include "url/url_constants.h" |
namespace content { |
@@ -250,7 +254,18 @@ NavigationHandleImpl::CallWillStartRequestForTesting( |
ui::PageTransition transition, |
bool is_external_protocol) { |
NavigationThrottle::ThrottleCheckResult result = NavigationThrottle::DEFER; |
- WillStartRequest(is_post ? "POST" : "GET", sanitized_referrer, |
+ |
+ scoped_refptr<ResourceRequestBody> resource_request_body; |
+ std::string method = "GET"; |
+ if (is_post) { |
+ method = "POST"; |
+ |
+ std::string body = "test=body"; |
+ resource_request_body = new ResourceRequestBody(); |
+ resource_request_body->AppendBytes(body.data(), body.size()); |
+ } |
+ |
+ WillStartRequest(method, resource_request_body, sanitized_referrer, |
has_user_gesture, transition, is_external_protocol, |
base::Bind(&UpdateThrottleCheckResult, &result)); |
@@ -289,13 +304,22 @@ void NavigationHandleImpl::InitServiceWorkerHandle( |
void NavigationHandleImpl::WillStartRequest( |
const std::string& method, |
+ scoped_refptr<content::ResourceRequestBody> resource_request_body, |
const Referrer& sanitized_referrer, |
bool has_user_gesture, |
ui::PageTransition transition, |
bool is_external_protocol, |
const ThrottleChecksFinishedCallback& callback) { |
+ // |method != "POST"| should imply absence of |resource_request_body|. |
+ if (method != "POST" && resource_request_body) { |
+ NOTREACHED(); |
+ resource_request_body = nullptr; |
+ } |
+ |
// Update the navigation parameters. |
method_ = method; |
+ if (method_ == "POST") |
+ resource_request_body_ = resource_request_body; |
sanitized_referrer_ = sanitized_referrer; |
has_user_gesture_ = has_user_gesture; |
transition_ = transition; |
@@ -339,6 +363,8 @@ void NavigationHandleImpl::WillRedirectRequest( |
is_external_protocol_ = new_is_external_protocol; |
response_headers_ = response_headers; |
was_redirected_ = true; |
+ if (new_method != "POST") |
+ resource_request_body_ = nullptr; |
state_ = WILL_REDIRECT_REQUEST; |
complete_callback_ = callback; |