]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
Fix the handling of HEAD requests that do not comply with RFC standards 58572/head
authorliubingrun <liubr1@chinatelecom.cn>
Tue, 16 Jul 2024 13:47:16 +0000 (09:47 -0400)
committerliubingrun <liubr1@chinatelecom.cn>
Tue, 16 Jul 2024 13:47:16 +0000 (09:47 -0400)
    According to RFC 9110, The HEAD method is identical to GET except
    that the server MUST NOT send content in the response.

    And RFC 9112 indicates that Transfer-Encoding can be omitted in HEAD
    Response.

    The following HEAD OP is using chunked encoding and send the final chunk

    HEAD /bucket?uploads            RGWListBucketMultiparts_ObjStore_S3
    HEAD /bucket/abc?uploadId       RGWListMultipart_ObjStore_S3
    HEAD /                          RGWListBuckets_ObjStore_S3

    Clients using persistent connections, such as nginx, will be unable to handle
    subsequent requests after processing such requests because the final chunk
    remains in the TCP byte stream, preventing the next HTTP response from
    being correctly parsed.

    Ref: https://www.rfc-editor.org/rfc/rfc9110.html#section-9.3.2
         https://www.rfc-editor.org/rfc/rfc9112#section-6.1-9

Signed-off-by: liubingrun <liubr1@chinatelecom.cn>
src/rgw/rgw_rest.cc

index 102f05d786288f2cb52c238f624eb16c560801ef..a202d5acf4e1190121aa7915782a70d5e078f812 100644 (file)
@@ -397,6 +397,10 @@ void dump_content_length(req_state* const s, const uint64_t len)
 
 static void dump_chunked_encoding(req_state* const s)
 {
+  // omit transfer-encoding for HEAD requests so ChunkingFilter doesn't
+  // try to write the final chunk
+  if(s->op == OP_HEAD)
+    return;
   try {
     RESTFUL_IO(s)->send_chunked_transfer_encoding();
   } catch (rgw::io::Exception& e) {