Commit abcdc459 authored by Kouhei Ueno's avatar Kouhei Ueno Committed by Commit Bot

SignedExchange: Clarify which HTTP methods are allowed

No behaviour change.
This CL clarifies which HTTP methods are actually in the allowed set.

Bug: 803774
Change-Id: Ie787a72c2600b96e97aa8540826b5adf63894715
Reviewed-on: https://chromium-review.googlesource.com/c/1313809
Commit-Queue: Kouhei Ueno <kouhei@chromium.org>
Reviewed-by: default avatarKunihiko Sakamoto <ksakamoto@chromium.org>
Reviewed-by: default avatarKinuko Yasuda <kinuko@chromium.org>
Cr-Commit-Position: refs/heads/master@{#604812}
parent b269640d
...@@ -65,10 +65,6 @@ bool IsStatefulResponseHeader(base::StringPiece name) { ...@@ -65,10 +65,6 @@ bool IsStatefulResponseHeader(base::StringPiece name) {
return false; return false;
} }
bool IsMethodCacheable(base::StringPiece method) {
return method == "GET" || method == "HEAD" || method == "POST";
}
bool ParseRequestMap(const cbor::Value& value, bool ParseRequestMap(const cbor::Value& value,
SignedExchangeEnvelope* out, SignedExchangeEnvelope* out,
SignedExchangeDevToolsProxy* devtools_proxy) { SignedExchangeDevToolsProxy* devtools_proxy) {
...@@ -96,8 +92,12 @@ bool ParseRequestMap(const cbor::Value& value, ...@@ -96,8 +92,12 @@ bool ParseRequestMap(const cbor::Value& value,
// 3. If exchange’s request method is not safe (Section 4.2.1 of [RFC7231]) // 3. If exchange’s request method is not safe (Section 4.2.1 of [RFC7231])
// or not cacheable (Section 4.2.3 of [RFC7231]), return “invalid”. // or not cacheable (Section 4.2.3 of [RFC7231]), return “invalid”.
// [spec text] // [spec text]
if (!net::HttpUtil::IsMethodSafe(method_str.as_string()) || //
!IsMethodCacheable(method_str)) { // Note: Per [RFC7231],
// Safe methods are "GET", "HEAD", "OPTIONS", and "TRACE".
// Cachable methods are "GET", "HEAD", and "POST",
// and we only allow methods that satisfy both.
if (method_str != "GET" && method_str != "HEAD") {
signed_exchange_utils::ReportErrorAndTraceEvent( signed_exchange_utils::ReportErrorAndTraceEvent(
devtools_proxy, devtools_proxy,
base::StringPrintf( base::StringPrintf(
......
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