| Index: content/renderer/render_frame_impl.cc
|
| diff --git a/content/renderer/render_frame_impl.cc b/content/renderer/render_frame_impl.cc
|
| index e50f6982219aa78c0e240fd5d7e13eb2b9318219..4dd747475e4a8417e7e5ff145af9f311c86a450c 100644
|
| --- a/content/renderer/render_frame_impl.cc
|
| +++ b/content/renderer/render_frame_impl.cc
|
| @@ -150,6 +150,7 @@
|
| #include "net/base/net_errors.h"
|
| #include "net/base/registry_controlled_domains/registry_controlled_domain.h"
|
| #include "net/http/http_util.h"
|
| +#include "storage/common/data_element.h"
|
| #include "third_party/WebKit/public/platform/URLConversion.h"
|
| #include "third_party/WebKit/public/platform/WebCachePolicy.h"
|
| #include "third_party/WebKit/public/platform/WebData.h"
|
| @@ -539,6 +540,47 @@ WebURLRequest CreateURLRequestForNavigation(
|
| return request;
|
| }
|
|
|
| +// Converts the HTTP body data stored in ResourceRequestBody format to a
|
| +// WebHTTPBody, which is then added to the WebURLRequest.
|
| +// PlzNavigate: used to add the POST data sent by the renderer at commit time
|
| +// to the WebURLRequest used to commit the navigation. This ensures that the
|
| +// POST data will be in the PageState sent to the browser on commit.
|
| +void AddHTTPBodyToRequest(WebURLRequest* request,
|
| + const scoped_refptr<ResourceRequestBody>& body) {
|
| + WebHTTPBody http_body;
|
| + http_body.initialize();
|
| + http_body.setIdentifier(body->identifier());
|
| + for (const ResourceRequestBody::Element& element : *(body->elements())) {
|
| + long long length = -1;
|
| + switch (element.type()) {
|
| + case storage::DataElement::TYPE_BYTES:
|
| + http_body.appendData(WebData(element.bytes(), element.length()));
|
| + break;
|
| + case storage::DataElement::TYPE_FILE:
|
| + if (element.length() != std::numeric_limits<uint64_t>::max())
|
| + length = element.length();
|
| + http_body.appendFileRange(
|
| + element.path().AsUTF16Unsafe(), element.offset(), length,
|
| + element.expected_modification_time().ToDoubleT());
|
| + break;
|
| + case storage::DataElement::TYPE_FILE_FILESYSTEM:
|
| + http_body.appendFileSystemURLRange(
|
| + element.filesystem_url(), element.offset(), element.length(),
|
| + element.expected_modification_time().ToDoubleT());
|
| + break;
|
| + case storage::DataElement::TYPE_BLOB:
|
| + http_body.appendBlob(WebString::fromUTF8(element.blob_uuid()));
|
| + break;
|
| + default:
|
| + // TYPE_BYTES_DESCRIPTION and TYPE_DISK_CACHE_ENTRY should not be
|
| + // encountered.
|
| + NOTREACHED();
|
| + break;
|
| + }
|
| + }
|
| + request->setHTTPBody(http_body);
|
| +}
|
| +
|
| // Sanitizes the navigation_start timestamp for browser-initiated navigations,
|
| // where the browser possibly has a better notion of start time than the
|
| // renderer. In the case of cross-process navigations, this carries over the
|
| @@ -5379,18 +5421,9 @@ void RenderFrameImpl::NavigateInternal(
|
| }
|
| }
|
|
|
| - if (common_params.method == "POST" && !browser_side_navigation) {
|
| - // Set post data.
|
| - WebHTTPBody http_body;
|
| - http_body.initialize();
|
| - const char* data = nullptr;
|
| - if (start_params.browser_initiated_post_data.size()) {
|
| - data = reinterpret_cast<const char*>(
|
| - &start_params.browser_initiated_post_data.front());
|
| - }
|
| - http_body.appendData(
|
| - WebData(data, start_params.browser_initiated_post_data.size()));
|
| - request.setHTTPBody(http_body);
|
| + if (common_params.method == "POST" && !browser_side_navigation &&
|
| + start_params.post_data) {
|
| + AddHTTPBodyToRequest(&request, start_params.post_data);
|
| }
|
|
|
| // A session history navigation should have been accompanied by state.
|
|
|