Commit ef7bf539 authored by Takeshi Yoshino's avatar Takeshi Yoshino Committed by Commit Bot

Use the constants defined in HTTPNames where possible

Bug: 
Change-Id: Ia32d500ba42bdd485f0c35e1a34659332002a162
Reviewed-on: https://chromium-review.googlesource.com/648909
Commit-Queue: Takeshi Yoshino <tyoshino@chromium.org>
Reviewed-by: default avatarYutaka Hirano <yhirano@chromium.org>
Reviewed-by: default avatarKinuko Yasuda <kinuko@chromium.org>
Cr-Commit-Position: refs/heads/master@{#517760}
parent ccd0bd54
...@@ -45,6 +45,7 @@ ...@@ -45,6 +45,7 @@
#include "platform/heap/Handle.h" #include "platform/heap/Handle.h"
#include "platform/network/EncodedFormData.h" #include "platform/network/EncodedFormData.h"
#include "platform/network/FormDataEncoder.h" #include "platform/network/FormDataEncoder.h"
#include "platform/network/http_names.h"
#include "platform/wtf/CurrentTime.h" #include "platform/wtf/CurrentTime.h"
#include "platform/wtf/text/StringBuilder.h" #include "platform/wtf/text/StringBuilder.h"
#include "platform/wtf/text/TextEncoding.h" #include "platform/wtf/text/TextEncoding.h"
...@@ -293,7 +294,7 @@ FrameLoadRequest FormSubmission::CreateFrameLoadRequest( ...@@ -293,7 +294,7 @@ FrameLoadRequest FormSubmission::CreateFrameLoadRequest(
frame_request.SetFrameName(target_); frame_request.SetFrameName(target_);
if (method_ == FormSubmission::kPostMethod) { if (method_ == FormSubmission::kPostMethod) {
frame_request.GetResourceRequest().SetHTTPMethod("POST"); frame_request.GetResourceRequest().SetHTTPMethod(HTTPNames::POST);
frame_request.GetResourceRequest().SetHTTPBody(form_data_); frame_request.GetResourceRequest().SetHTTPBody(form_data_);
// construct some user headers if necessary // construct some user headers if necessary
......
...@@ -79,6 +79,7 @@ ...@@ -79,6 +79,7 @@
#include "platform/loader/fetch/fetch_initiator_type_names.h" #include "platform/loader/fetch/fetch_initiator_type_names.h"
#include "platform/mhtml/MHTMLArchive.h" #include "platform/mhtml/MHTMLArchive.h"
#include "platform/network/NetworkStateNotifier.h" #include "platform/network/NetworkStateNotifier.h"
#include "platform/network/http_names.h"
#include "platform/scheduler/child/web_scheduler.h" #include "platform/scheduler/child/web_scheduler.h"
#include "platform/scheduler/renderer/web_view_scheduler.h" #include "platform/scheduler/renderer/web_view_scheduler.h"
#include "platform/weborigin/SchemeRegistry.h" #include "platform/weborigin/SchemeRegistry.h"
...@@ -374,8 +375,8 @@ mojom::FetchCacheMode FrameFetchContext::ResourceRequestCachePolicy( ...@@ -374,8 +375,8 @@ mojom::FetchCacheMode FrameFetchContext::ResourceRequestCachePolicy(
DCHECK(GetFrame()); DCHECK(GetFrame());
if (type == Resource::kMainResource) { if (type == Resource::kMainResource) {
const auto cache_mode = DetermineCacheMode( const auto cache_mode = DetermineCacheMode(
request.HttpMethod() == "POST" ? RequestMethod::kIsPost request.HttpMethod() == HTTPNames::POST ? RequestMethod::kIsPost
: RequestMethod::kIsNotPost, : RequestMethod::kIsNotPost,
request.IsConditional() ? RequestType::kIsConditional request.IsConditional() ? RequestType::kIsConditional
: RequestType::kIsNotConditional, : RequestType::kIsNotConditional,
ResourceType::kIsMainResource, MasterDocumentLoader()->LoadType()); ResourceType::kIsMainResource, MasterDocumentLoader()->LoadType());
......
...@@ -45,6 +45,7 @@ ...@@ -45,6 +45,7 @@
#include "platform/loader/fetch/UniqueIdentifier.h" #include "platform/loader/fetch/UniqueIdentifier.h"
#include "platform/loader/testing/MockFetchContext.h" #include "platform/loader/testing/MockFetchContext.h"
#include "platform/loader/testing/MockResourceClient.h" #include "platform/loader/testing/MockResourceClient.h"
#include "platform/network/http_names.h"
#include "platform/scheduler/test/fake_web_task_runner.h" #include "platform/scheduler/test/fake_web_task_runner.h"
#include "platform/testing/RuntimeEnabledFeaturesTestHelpers.h" #include "platform/testing/RuntimeEnabledFeaturesTestHelpers.h"
#include "platform/testing/ScopedMockedURL.h" #include "platform/testing/ScopedMockedURL.h"
...@@ -1410,7 +1411,7 @@ TEST(ImageResourceTest, FetchAllowPlaceholderPostRequest) { ...@@ -1410,7 +1411,7 @@ TEST(ImageResourceTest, FetchAllowPlaceholderPostRequest) {
KURL test_url(kTestURL); KURL test_url(kTestURL);
ScopedMockedURLLoad scoped_mocked_url_load(test_url, GetTestFilePath()); ScopedMockedURLLoad scoped_mocked_url_load(test_url, GetTestFilePath());
ResourceRequest resource_request(test_url); ResourceRequest resource_request(test_url);
resource_request.SetHTTPMethod("POST"); resource_request.SetHTTPMethod(HTTPNames::POST);
FetchParameters params(resource_request); FetchParameters params(resource_request);
params.SetAllowImagePlaceholder(); params.SetAllowImagePlaceholder();
ImageResource* image_resource = ImageResource::Fetch(params, CreateFetcher()); ImageResource* image_resource = ImageResource::Fetch(params, CreateFetcher());
......
...@@ -78,7 +78,8 @@ const ForbiddenHeaderNames& ForbiddenHeaderNames::Get() { ...@@ -78,7 +78,8 @@ const ForbiddenHeaderNames& ForbiddenHeaderNames::Get() {
bool FetchUtils::IsCORSSafelistedMethod(const String& method) { bool FetchUtils::IsCORSSafelistedMethod(const String& method) {
// https://fetch.spec.whatwg.org/#cors-safelisted-method // https://fetch.spec.whatwg.org/#cors-safelisted-method
// "A CORS-safelisted method is a method that is `GET`, `HEAD`, or `POST`." // "A CORS-safelisted method is a method that is `GET`, `HEAD`, or `POST`."
return method == "GET" || method == "HEAD" || method == "POST"; return method == HTTPNames::GET || method == HTTPNames::HEAD ||
method == HTTPNames::POST;
} }
bool FetchUtils::IsCORSSafelistedHeader(const AtomicString& name, bool FetchUtils::IsCORSSafelistedHeader(const AtomicString& name,
......
...@@ -340,7 +340,8 @@ static bool ShouldIgnoreHeaderForCacheReuse(AtomicString header_name) { ...@@ -340,7 +340,8 @@ static bool ShouldIgnoreHeaderForCacheReuse(AtomicString header_name) {
static bool IsCacheableHTTPMethod(const AtomicString& method) { static bool IsCacheableHTTPMethod(const AtomicString& method) {
// Per http://www.w3.org/Protocols/rfc2616/rfc2616-sec13.html#sec13.10, // Per http://www.w3.org/Protocols/rfc2616/rfc2616-sec13.html#sec13.10,
// these methods always invalidate the cache entry. // these methods always invalidate the cache entry.
return method != "POST" && method != "PUT" && method != "DELETE"; return method != HTTPNames::POST && method != HTTPNames::PUT &&
method != "DELETE";
} }
bool RawResource::CanReuse(const FetchParameters& new_fetch_parameters) const { bool RawResource::CanReuse(const FetchParameters& new_fetch_parameters) const {
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
"HEAD", "HEAD",
"POST", "POST",
"OPTIONS", "OPTIONS",
"PUT",
"Accept", "Accept",
"Accept-CH", "Accept-CH",
"Accept-CH-Lifetime", "Accept-CH-Lifetime",
......
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