Commit 0ffb3eb2 authored by Yoichi Osato's avatar Yoichi Osato Committed by Commit Bot

Not copy request body in ResourceRequest::CreateRedirectRequest().

That's because the copied body is only used by DevTools to show
redirected body and actually DevTools has already copy of the body.
This CL changed DevTool to reuse the body.

Bug: 787704
Change-Id: I9c9e7433564bda24ef1adf229f315c4629cc2a1d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2059889Reviewed-by: default avatarKent Tamura <tkent@chromium.org>
Reviewed-by: default avatarYutaka Hirano <yhirano@chromium.org>
Reviewed-by: default avatarSigurd Schneider <sigurds@chromium.org>
Commit-Queue: Yoichi Osato <yoichio@chromium.org>
Cr-Commit-Position: refs/heads/master@{#745350}
parent 34963be3
......@@ -9,4 +9,5 @@ include_rules = [
"+cc/trees/transform_node.h",
"+third_party/inspector_protocol/crdtp",
"+third_party/icu/source/common/unicode/locid.h",
"+net/http/http_status_code.h",
]
......@@ -37,6 +37,7 @@
#include "base/macros.h"
#include "base/memory/scoped_refptr.h"
#include "build/build_config.h"
#include "net/http/http_status_code.h"
#include "services/network/public/mojom/referrer_policy.mojom-blink.h"
#include "services/network/public/mojom/websocket.mojom-blink.h"
#include "third_party/blink/public/mojom/loader/request_context_frame_type.mojom-blink.h"
......@@ -497,10 +498,10 @@ static bool FormDataToString(scoped_refptr<EncodedFormData> body,
static std::unique_ptr<protocol::Network::Request>
BuildObjectForResourceRequest(const ResourceRequest& request,
scoped_refptr<EncodedFormData> post_data,
size_t max_body_size) {
String postData;
bool hasPostData =
FormDataToString(request.HttpBody(), max_body_size, &postData);
bool hasPostData = FormDataToString(post_data, max_body_size, &postData);
KURL url = request.Url();
// protocol::Network::Request doesn't have a separate referrer string member
// like blink::ResourceRequest, so here we add ResourceRequest's referrer
......@@ -771,12 +772,15 @@ void InspectorNetworkAgent::WillSendRequestInternal(
String request_id = IdentifiersFactory::RequestId(loader, identifier);
NetworkResourcesData::ResourceData const* data =
resources_data_->Data(request_id);
// Support for POST request redirect
// Support for POST request redirect.
scoped_refptr<EncodedFormData> post_data;
if (data)
if (data &&
(redirect_response.HttpStatusCode() == net::HTTP_TEMPORARY_REDIRECT ||
redirect_response.HttpStatusCode() == net::HTTP_PERMANENT_REDIRECT)) {
post_data = data->PostData();
else if (request.HttpBody())
} else if (request.HttpBody()) {
post_data = request.HttpBody()->DeepCopy();
}
resources_data_->ResourceCreated(request_id, loader_id, request.Url(),
post_data);
......@@ -799,7 +803,8 @@ void InspectorNetworkAgent::WillSendRequestInternal(
initiator_info, std::numeric_limits<int>::max());
std::unique_ptr<protocol::Network::Request> request_info(
BuildObjectForResourceRequest(request, max_post_data_size_.Get()));
BuildObjectForResourceRequest(request, post_data,
max_post_data_size_.Get()));
// |loader| is null while inspecting worker.
// TODO(horo): Refactor MixedContentChecker and set mixed content type even if
......
......@@ -143,8 +143,6 @@ std::unique_ptr<ResourceRequest> ResourceRequest::CreateRedirectRequest(
request->SetKeepalive(GetKeepalive());
request->SetPriority(Priority());
if (request->HttpMethod() == HttpMethod())
request->SetHttpBody(HttpBody());
request->SetCorsPreflightPolicy(CorsPreflightPolicy());
if (IsAdResource())
request->SetIsAdResource();
......
......@@ -394,6 +394,9 @@ _CONFIG = [
# HTTP structured headers
'net::structured_headers::.+',
# HTTP status codes
'net::HTTP_.+',
# Network service.
'network::.+',
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment