You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by ez...@apache.org on 2026/10/19 22:03:07 UTC

(trafficserver) 03/30: http: reject HEAD requests carrying Content-Length or Transfer-Encoding

This is an automated email from the ASF dual-hosted git repository.

ezelkow1 pushed a commit to branch 9.2.x
in repository https://gitbox.apache.org/repos/asf/trafficserver.git

commit c620c5c2c3a4aae0b6f945aaaba3a8996f527cba
Author: Evan Zelkowitz <e_...@apple.com>
AuthorDate: Wed Aug 26 15:55:41 2026 -0600

    http: reject HEAD requests carrying Content-Length or Transfer-Encoding
    
    A HEAD request has no body, so body framing on one is a request-framing
    error that downstream agents may resolve differently than ATS does.
    Reject such requests with 400, controlled by the new overridable
    proxy.config.http.reject_head_with_content record.
---
 doc/admin-guide/files/records.config.en.rst        |  14 ++
 .../api/functions/TSHttpOverridableConfig.en.rst   |   1 +
 .../api/types/TSOverridableConfigKey.en.rst        |   1 +
 include/ts/apidefs.h.in                            |   1 +
 mgmt/RecordsConfig.cc                              |   2 +
 plugins/lua/ts_lua_http_config.c                   |   2 +
 proxy/http/HttpConfig.cc                           |   2 +
 proxy/http/HttpConfig.h                            |   2 +
 proxy/http/HttpTransact.cc                         |  17 ++
 proxy/http/HttpTransact.h                          |   1 +
 src/shared/overridable_txn_vars.cc                 |   1 +
 src/traffic_server/InkAPI.cc                       |   3 +
 src/traffic_server/InkAPITest.cc                   |  10 +-
 tests/gold_tests/head/head-reject-content.test.py  |  31 +++
 .../head/replay/head-reject-content.replay.yaml    | 243 +++++++++++++++++++++
 15 files changed, 330 insertions(+), 1 deletion(-)

diff --git a/doc/admin-guide/files/records.config.en.rst b/doc/admin-guide/files/records.config.en.rst
index bbf9ff9a1e..718f258bb1 100644
--- a/doc/admin-guide/files/records.config.en.rst
+++ b/doc/admin-guide/files/records.config.en.rst
@@ -1777,6 +1777,20 @@ Origin Server Connect Attempts
 
     Enables (``1``) or disables (``0``) checking the Content-Length: Header for a POST request.
 
+.. ts:cv:: CONFIG proxy.config.http.reject_head_with_content INT 1
+   :reloadable:
+   :overridable:
+
+   Rejects (``1``) HEAD requests that carry non-empty content, declared via a
+   non-zero ``Content-Length`` or a chunked ``Transfer-Encoding``, with a
+   ``400 Bad Request`` response.
+
+   RFC 9110 ยง 9.3.2 states that a client *SHOULD NOT* send content in a HEAD
+   request.  Enabling this setting enforces that recommendation.
+
+   Setting this to ``0`` allows HEAD requests with a body to be forwarded to
+   the origin.  Disabling this setting may introduce security risks.
+
 .. ts:cv:: CONFIG proxy.config.http.down_server.cache_time INT 60
    :reloadable:
    :overridable:
diff --git a/doc/developer-guide/api/functions/TSHttpOverridableConfig.en.rst b/doc/developer-guide/api/functions/TSHttpOverridableConfig.en.rst
index b2b0e23150..b095098c2b 100644
--- a/doc/developer-guide/api/functions/TSHttpOverridableConfig.en.rst
+++ b/doc/developer-guide/api/functions/TSHttpOverridableConfig.en.rst
@@ -112,6 +112,7 @@ TSOverridableConfigKey Value                                              Config
 :c:enumerator:`TS_CONFIG_HTTP_CHUNKING_ENABLED`                           :ts:cv:`proxy.config.http.chunking_enabled`
 :c:enumerator:`TS_CONFIG_HTTP_CHUNKING_SIZE`                              :ts:cv:`proxy.config.http.chunking.size`
 :c:enumerator:`TS_CONFIG_HTTP_STRICT_CHUNK_PARSING`                       :ts:cv:`proxy.config.http.strict_chunk_parsing`
+:c:enumerator:`TS_CONFIG_HTTP_REJECT_HEAD_WITH_CONTENT`                   :ts:cv:`proxy.config.http.reject_head_with_content`
 :c:enumerator:`TS_CONFIG_HTTP_CONNECT_ATTEMPTS_MAX_RETRIES_DEAD_SERVER`   :ts:cv:`proxy.config.http.connect_attempts_max_retries_dead_server`
 :c:enumerator:`TS_CONFIG_HTTP_DROP_CHUNKED_TRAILERS`                      :ts:cv:`proxy.config.http.drop_chunked_trailers`
 :c:enumerator:`TS_CONFIG_HTTP_CONNECT_ATTEMPTS_MAX_RETRIES`               :ts:cv:`proxy.config.http.connect_attempts_max_retries`
diff --git a/doc/developer-guide/api/types/TSOverridableConfigKey.en.rst b/doc/developer-guide/api/types/TSOverridableConfigKey.en.rst
index b4291b4657..06b3b59483 100644
--- a/doc/developer-guide/api/types/TSOverridableConfigKey.en.rst
+++ b/doc/developer-guide/api/types/TSOverridableConfigKey.en.rst
@@ -92,6 +92,7 @@ Enumeration Members
 .. c:enumerator:: TS_CONFIG_HTTP_INSERT_AGE_IN_RESPONSE
 .. c:enumerator:: TS_CONFIG_HTTP_CHUNKING_SIZE
 .. c:enumerator:: TS_CONFIG_HTTP_STRICT_CHUNK_PARSING
+.. c:enumerator:: TS_CONFIG_HTTP_REJECT_HEAD_WITH_CONTENT
 .. c:enumerator:: TS_CONFIG_HTTP_DROP_CHUNKED_TRAILERS
 .. c:enumerator:: TS_CONFIG_HTTP_FLOW_CONTROL_ENABLED
 .. c:enumerator:: TS_CONFIG_HTTP_FLOW_CONTROL_LOW_WATER_MARK
diff --git a/include/ts/apidefs.h.in b/include/ts/apidefs.h.in
index 893177c88b..b0860f1761 100644
--- a/include/ts/apidefs.h.in
+++ b/include/ts/apidefs.h.in
@@ -876,6 +876,7 @@ typedef enum {
   TS_CONFIG_HTTP_DISABLE_PARENT_MARKDOWNS,
   TS_CONFIG_HTTP_DROP_CHUNKED_TRAILERS,
   TS_CONFIG_HTTP_STRICT_CHUNK_PARSING,
+  TS_CONFIG_HTTP_REJECT_HEAD_WITH_CONTENT,
   TS_CONFIG_LAST_ENTRY
 } TSOverridableConfigKey;
 
diff --git a/mgmt/RecordsConfig.cc b/mgmt/RecordsConfig.cc
index 5e6c29f6e3..2d5130b720 100644
--- a/mgmt/RecordsConfig.cc
+++ b/mgmt/RecordsConfig.cc
@@ -381,6 +381,8 @@ static const RecordElement RecordsConfig[] =
   ,
   {RECT_CONFIG, "proxy.config.http.post.check.content_length.enabled", RECD_INT, "1", RECU_DYNAMIC, RR_NULL, RECC_INT, "[0-1]", RECA_NULL}
   ,
+  {RECT_CONFIG, "proxy.config.http.reject_head_with_content", RECD_INT, "1", RECU_DYNAMIC, RR_NULL, RECC_INT, "[0-1]", RECA_NULL}
+  ,
   {RECT_CONFIG, "proxy.config.http.strict_uri_parsing", RECD_INT, "2", RECU_DYNAMIC, RR_NULL, RECC_INT, "[0-2]", RECA_NULL}
   ,
   //       # Send http11 requests
diff --git a/plugins/lua/ts_lua_http_config.c b/plugins/lua/ts_lua_http_config.c
index 4b22ee94b5..4ee0a24813 100644
--- a/plugins/lua/ts_lua_http_config.c
+++ b/plugins/lua/ts_lua_http_config.c
@@ -150,6 +150,7 @@ typedef enum {
   TS_LUA_CONFIG_ENABLE_PARENT_TIMEOUT_MARKDOWNS        = TS_CONFIG_HTTP_ENABLE_PARENT_TIMEOUT_MARKDOWNS,
   TS_LUA_CONFIG_DISABLE_PARENT_MARKDOWNS               = TS_CONFIG_HTTP_DISABLE_PARENT_MARKDOWNS,
   TS_LUA_CONFIG_HTTP_STRICT_CHUNK_PARSING              = TS_CONFIG_HTTP_STRICT_CHUNK_PARSING,
+  TS_LUA_CONFIG_HTTP_REJECT_HEAD_WITH_CONTENT          = TS_CONFIG_HTTP_REJECT_HEAD_WITH_CONTENT,
   TS_LUA_CONFIG_LAST_ENTRY                             = TS_CONFIG_LAST_ENTRY,
 } TSLuaOverridableConfigKey;
 
@@ -292,6 +293,7 @@ ts_lua_var_item ts_lua_http_config_vars[] = {
   TS_LUA_MAKE_VAR_ITEM(TS_LUA_CONFIG_ENABLE_PARENT_TIMEOUT_MARKDOWNS),
   TS_LUA_MAKE_VAR_ITEM(TS_LUA_CONFIG_DISABLE_PARENT_MARKDOWNS),
   TS_LUA_MAKE_VAR_ITEM(TS_LUA_CONFIG_HTTP_STRICT_CHUNK_PARSING),
+  TS_LUA_MAKE_VAR_ITEM(TS_LUA_CONFIG_HTTP_REJECT_HEAD_WITH_CONTENT),
   TS_LUA_MAKE_VAR_ITEM(TS_LUA_CONFIG_LAST_ENTRY),
 };
 
diff --git a/proxy/http/HttpConfig.cc b/proxy/http/HttpConfig.cc
index 6c27ee807e..d945acb91d 100644
--- a/proxy/http/HttpConfig.cc
+++ b/proxy/http/HttpConfig.cc
@@ -1205,6 +1205,7 @@ HttpConfig::startup()
   HttpEstablishStaticConfigLongLong(c.oride.flow_high_water_mark, "proxy.config.http.flow_control.high_water");
   HttpEstablishStaticConfigLongLong(c.oride.flow_low_water_mark, "proxy.config.http.flow_control.low_water");
   HttpEstablishStaticConfigByte(c.oride.post_check_content_length_enabled, "proxy.config.http.post.check.content_length.enabled");
+  HttpEstablishStaticConfigByte(c.oride.reject_head_with_content, "proxy.config.http.reject_head_with_content");
   HttpEstablishStaticConfigByte(c.oride.request_buffer_enabled, "proxy.config.http.request_buffer_enabled");
   HttpEstablishStaticConfigByte(c.strict_uri_parsing, "proxy.config.http.strict_uri_parsing");
 
@@ -1523,6 +1524,7 @@ HttpConfig::reconfigure()
   params->oride.http_chunking_size = m_master.oride.http_chunking_size;
 
   params->oride.post_check_content_length_enabled = INT_TO_BOOL(m_master.oride.post_check_content_length_enabled);
+  params->oride.reject_head_with_content          = INT_TO_BOOL(m_master.oride.reject_head_with_content);
 
   params->oride.request_buffer_enabled = INT_TO_BOOL(m_master.oride.request_buffer_enabled);
 
diff --git a/proxy/http/HttpConfig.h b/proxy/http/HttpConfig.h
index 53d7bbfe8d..53e84a0e54 100644
--- a/proxy/http/HttpConfig.h
+++ b/proxy/http/HttpConfig.h
@@ -596,6 +596,8 @@ struct OverridableHttpConfigParams {
   ////////////////////////
   MgmtByte post_check_content_length_enabled = 1;
 
+  MgmtByte reject_head_with_content = 1;
+
   ////////////////////////////////////////////////
   // Buffer post body before connecting servers //
   ////////////////////////////////////////////////
diff --git a/proxy/http/HttpTransact.cc b/proxy/http/HttpTransact.cc
index d7419baa13..74da1dab14 100644
--- a/proxy/http/HttpTransact.cc
+++ b/proxy/http/HttpTransact.cc
@@ -5644,6 +5644,17 @@ HttpTransact::check_request_validity(State *s, HTTPHdr *incoming_hdr)
       return UNACCEPTABLE_TE_REQUIRED;
     }
 
+    // RFC 9110 section 9.3.2: "A client SHOULD NOT send content in a HEAD
+    // request." has_request_body() is protocol-aware, since HTTP/2 can signal a
+    // body through framing (DATA frames) with no Content-Length header. As with
+    // the POST check below, ua_txn may be absent when a request is created
+    // independent of a transaction, so it must be null checked.
+    if (s->txn_conf->reject_head_with_content && method == HTTP_WKSIDX_HEAD && s->state_machine->ua_txn &&
+        s->state_machine->ua_txn->has_request_body(s->hdr_info.request_content_length,
+                                                   s->client_info.transfer_encoding == CHUNKED_ENCODING)) {
+      return HEAD_CONTENT;
+    }
+
     // Require Content-Length/Transfer-Encoding for POST/PUSH/PUT
     if ((scheme == URL_WKSIDX_HTTP || scheme == URL_WKSIDX_HTTPS) &&
         (method == HTTP_WKSIDX_POST || method == HTTP_WKSIDX_PUSH || method == HTTP_WKSIDX_PUT) &&
@@ -6741,6 +6752,12 @@ HttpTransact::is_request_valid(State *s, HTTPHdr *incoming_request)
     build_error_response(s, HTTP_STATUS_BAD_REQUEST, "Invalid Content Length", "request#invalid_content_length");
     return false;
   }
+  case HEAD_CONTENT: {
+    TxnDebug("http_trans", "HEAD request with body");
+    SET_VIA_STRING(VIA_DETAIL_TUNNEL, VIA_DETAIL_TUNNEL_NO_FORWARD);
+    build_error_response(s, HTTP_STATUS_BAD_REQUEST, "Content Not Allowed", "request#head_content");
+    return false;
+  }
   default:
     return true;
   }
diff --git a/proxy/http/HttpTransact.h b/proxy/http/HttpTransact.h
index f3ae63b389..c43dbc045a 100644
--- a/proxy/http/HttpTransact.h
+++ b/proxy/http/HttpTransact.h
@@ -313,6 +313,7 @@ public:
     SCHEME_NOT_SUPPORTED,
     UNACCEPTABLE_TE_REQUIRED,
     INVALID_POST_CONTENT_LENGTH,
+    HEAD_CONTENT,
     TOTAL_REQUEST_ERROR_TYPES
   };
 
diff --git a/src/shared/overridable_txn_vars.cc b/src/shared/overridable_txn_vars.cc
index f8c6e6e58e..a5dc79e7d6 100644
--- a/src/shared/overridable_txn_vars.cc
+++ b/src/shared/overridable_txn_vars.cc
@@ -32,6 +32,7 @@ const std::unordered_map<std::string_view, std::tuple<const TSOverridableConfigK
      {"proxy.config.http.chunking.size", {TS_CONFIG_HTTP_CHUNKING_SIZE, TS_RECORDDATATYPE_INT}},
      {"proxy.config.http.drop_chunked_trailers", {TS_CONFIG_HTTP_DROP_CHUNKED_TRAILERS, TS_RECORDDATATYPE_INT}},
      {"proxy.config.http.strict_chunk_parsing", {TS_CONFIG_HTTP_STRICT_CHUNK_PARSING, TS_RECORDDATATYPE_INT}},
+     {"proxy.config.http.reject_head_with_content", {TS_CONFIG_HTTP_REJECT_HEAD_WITH_CONTENT, TS_RECORDDATATYPE_INT}},
      {"proxy.config.ssl.client.cert.path", {TS_CONFIG_SSL_CERT_FILEPATH, TS_RECORDDATATYPE_STRING}},
      {"proxy.config.http.allow_half_open", {TS_CONFIG_HTTP_ALLOW_HALF_OPEN, TS_RECORDDATATYPE_INT}},
      {"proxy.config.http.chunking_enabled", {TS_CONFIG_HTTP_CHUNKING_ENABLED, TS_RECORDDATATYPE_INT}},
diff --git a/src/traffic_server/InkAPI.cc b/src/traffic_server/InkAPI.cc
index b90bc098ef..ff8a8b4a29 100644
--- a/src/traffic_server/InkAPI.cc
+++ b/src/traffic_server/InkAPI.cc
@@ -8949,6 +8949,9 @@ _conf_to_memberp(TSOverridableConfigKey conf, OverridableHttpConfigParams *overr
   case TS_CONFIG_HTTP_STRICT_CHUNK_PARSING:
     ret = _memberp_to_generic(&overridableHttpConfig->http_strict_chunk_parsing, conv);
     break;
+  case TS_CONFIG_HTTP_REJECT_HEAD_WITH_CONTENT:
+    ret = _memberp_to_generic(&overridableHttpConfig->reject_head_with_content, conv);
+    break;
   case TS_CONFIG_HTTP_FLOW_CONTROL_ENABLED:
     ret = _memberp_to_generic(&overridableHttpConfig->flow_control_enabled, conv);
     break;
diff --git a/src/traffic_server/InkAPITest.cc b/src/traffic_server/InkAPITest.cc
index 808e922c02..26a4fcce99 100644
--- a/src/traffic_server/InkAPITest.cc
+++ b/src/traffic_server/InkAPITest.cc
@@ -8772,7 +8772,15 @@ std::array<std::string_view, TS_CONFIG_LAST_ENTRY> SDK_Overridable_Configs = {
    "proxy.config.http.parent_proxy.enable_parent_timeout_markdowns",
    "proxy.config.http.parent_proxy.disable_parent_markdowns",
    "proxy.config.http.drop_chunked_trailers",
-   "proxy.config.http.strict_chunk_parsing"}};
+   "proxy.config.http.strict_chunk_parsing",
+   "proxy.config.http.reject_head_with_content"}};
+
+// Nothing else keeps this array in step with TSOverridableConfigKey, and a
+// missing entry is not a build failure by itself: std::array simply
+// default-constructs the tail, and the empty name then trips
+// sdk_sanity_check_null_ptr inside TSHttpTxnConfigFind at run time.
+static_assert(SDK_Overridable_Configs.size() == TS_CONFIG_LAST_ENTRY,
+              "SDK_Overridable_Configs size must match TS_CONFIG_LAST_ENTRY");
 
 extern ClassAllocator<HttpSM> httpSMAllocator;
 
diff --git a/tests/gold_tests/head/head-reject-content.test.py b/tests/gold_tests/head/head-reject-content.test.py
new file mode 100644
index 0000000000..7242c7cb7e
--- /dev/null
+++ b/tests/gold_tests/head/head-reject-content.test.py
@@ -0,0 +1,31 @@
+'''
+Verify HEAD requests carrying declared body content are rejected.
+'''
+#  Licensed to the Apache Software Foundation (ASF) under one
+#  or more contributor license agreements.  See the NOTICE file
+#  distributed with this work for additional information
+#  regarding copyright ownership.  The ASF licenses this file
+#  to you under the Apache License, Version 2.0 (the
+#  "License"); you may not use this file except in compliance
+#  with the License.  You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing, software
+#  distributed under the License is distributed on an "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#  See the License for the specific language governing permissions and
+#  limitations under the License.
+
+Test.Summary = '''
+Verify HEAD requests with a non-zero Content-Length or chunked
+Transfer-Encoding are rejected with 400, HEAD requests without declared
+content are forwarded normally, proxy.config.http.reject_head_with_content
+set to 0 forwards a HEAD request body to the origin, and a HEAD request
+carrying a body via HTTP/2 DATA frames (with no Content-Length header) is
+also rejected.
+'''
+
+Test.SkipUnless(Condition.HasProxyVerifierVersion('2.8.0'))
+
+Test.ATSReplayTest(replay_file='replay/head-reject-content.replay.yaml')
diff --git a/tests/gold_tests/head/replay/head-reject-content.replay.yaml b/tests/gold_tests/head/replay/head-reject-content.replay.yaml
new file mode 100644
index 0000000000..7998b7c44f
--- /dev/null
+++ b/tests/gold_tests/head/replay/head-reject-content.replay.yaml
@@ -0,0 +1,243 @@
+#  Licensed to the Apache Software Foundation (ASF) under one
+#  or more contributor license agreements.  See the NOTICE file
+#  distributed with this work for additional information
+#  regarding copyright ownership.  The ASF licenses this file
+#  to you under the Apache License, Version 2.0 (the
+#  "License"); you may not use this file except in compliance
+#  with the License.  You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing, software
+#  distributed under the License is distributed on an "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#  See the License for the specific language governing permissions and
+#  limitations under the License.
+
+meta:
+  version: "1.0"
+
+autest:
+  description: 'Verify HEAD requests carrying declared body content are rejected'
+
+  dns:
+    name: 'dns'
+
+  server:
+    name: 'server'
+
+  client:
+    name: 'client'
+
+  ats:
+    name: 'ts'
+    process_config:
+      enable_cache: false
+      enable_tls: true
+
+    records_config:
+      proxy.config.diags.debug.enabled: 1
+      proxy.config.diags.debug.tags: 'http|http_trans'
+      proxy.config.ssl.client.verify.server.policy: 'PERMISSIVE'
+
+    remap_config:
+      - from: "http://example.com/"
+        to: "http://backend.example.com:{SERVER_HTTP_PORT}/"
+
+      - from: "https://example.com/"
+        to: "http://backend.example.com:{SERVER_HTTP_PORT}/"
+
+      - from: "http://allow-body.example.com/"
+        to: "http://backend.example.com:{SERVER_HTTP_PORT}/"
+        plugins:
+          - name: "conf_remap.so"
+            args:
+              - "proxy.config.http.reject_head_with_content=0"
+
+sessions:
+
+# HEAD with a non-zero Content-Length should be rejected before reaching the
+# origin.
+- transactions:
+  - client-request:
+      method: "HEAD"
+      version: "1.1"
+      url: /reject/content-length
+      headers:
+        fields:
+        - [ Host, example.com ]
+        - [ Content-Length, 5 ]
+        - [ uuid, head-reject-content-length ]
+      content:
+        data: "hello"
+
+    proxy-request:
+      expect: absent
+
+    # Never exercised, since proxy-request expects absent. Proxy Verifier's
+    # server requires every transaction to carry a server-response node.
+    server-response:
+      status: 200
+      reason: OK
+      headers:
+        fields:
+        - [ Content-Length, 0 ]
+
+    proxy-response:
+      status: 400
+
+# HEAD with a chunked Transfer-Encoding should be rejected before reaching the
+# origin.
+- transactions:
+  - client-request:
+      method: "HEAD"
+      version: "1.1"
+      url: /reject/chunked
+      headers:
+        fields:
+        - [ Host, example.com ]
+        - [ Transfer-Encoding, chunked ]
+        - [ uuid, head-reject-chunked ]
+      content:
+        transfer: plain
+        encoding: uri
+        # 3-byte chunk, abc.
+        data: 3%0D%0Aabc%0D%0A0%0D%0A%0D%0A
+
+    proxy-request:
+      expect: absent
+
+    # Never exercised, since proxy-request expects absent. Proxy Verifier's
+    # server requires every transaction to carry a server-response node.
+    server-response:
+      status: 200
+      reason: OK
+      headers:
+        fields:
+        - [ Content-Length, 0 ]
+
+    proxy-response:
+      status: 400
+
+# HEAD requests that don't declare any content are unaffected and are
+# forwarded to the origin as usual.
+- transactions:
+  - client-request:
+      method: "HEAD"
+      version: "1.1"
+      url: /allow/zero-length
+      headers:
+        fields:
+        - [ Host, example.com ]
+        - [ Content-Length, 0 ]
+        - [ uuid, head-allow-zero-length ]
+
+    proxy-request:
+      method: "HEAD"
+
+    server-response:
+      status: 200
+      reason: OK
+      headers:
+        fields:
+        - [ Content-Type, text/plain ]
+        - [ Content-Length, 14 ]
+
+    proxy-response:
+      status: 200
+
+  - client-request:
+      method: "HEAD"
+      version: "1.1"
+      url: /allow/no-framing
+      headers:
+        fields:
+        - [ Host, example.com ]
+        - [ uuid, head-allow-no-framing ]
+
+    proxy-request:
+      method: "HEAD"
+
+    server-response:
+      status: 200
+      reason: OK
+      headers:
+        fields:
+        - [ Content-Type, text/plain ]
+        - [ Content-Length, 14 ]
+
+    proxy-response:
+      status: 200
+
+  # With proxy.config.http.reject_head_with_content set to 0 on this remap
+  # rule, a HEAD request with a body is forwarded to the origin unchanged.
+  - client-request:
+      method: "HEAD"
+      version: "1.1"
+      url: /override/content-length
+      headers:
+        fields:
+        - [ Host, allow-body.example.com ]
+        - [ Content-Length, 5 ]
+        - [ uuid, head-override-content-length ]
+      content:
+        data: "hello"
+
+    proxy-request:
+      method: "HEAD"
+      headers:
+        fields:
+        - [ Content-Length, { value: "5", as: equal } ]
+
+    server-response:
+      status: 200
+      reason: OK
+      headers:
+        fields:
+        - [ Content-Type, text/plain ]
+        - [ Content-Length, 14 ]
+
+    proxy-response:
+      status: 200
+
+# An HTTP/2 HEAD request can carry a body via DATA frame framing without a
+# Content-Length header. This must be rejected the same as HEAD requests that
+# declare Content-Length or Transfer-Encoding, since HTTP/2 signals the body
+# through framing rather than a header.
+- protocol:
+  - name: http
+    version: 2
+  - name: tls
+    sni: example.com
+
+  transactions:
+  - client-request:
+      frames:
+      - HEADERS:
+          headers:
+            fields:
+            - [":method", HEAD]
+            - [":scheme", https]
+            - [":authority", example.com]
+            - [":path", /reject/h2-framed-body]
+            - [uuid, head-reject-h2-framed-body]
+      - DATA:
+          content:
+            encoding: plain
+            data: hello
+            size: 5
+
+    proxy-request:
+      expect: absent
+
+    # Never exercised, since proxy-request expects absent. Proxy Verifier's
+    # server requires every transaction to carry a server-response node.
+    server-response:
+      status: 200
+      reason: OK
+      headers:
+        fields:
+        - [ Content-Length, 0 ]
+
+    proxy-response:
+      status: 400