From a40dc01397ffd76a0c5ad03259047f859e197a53 Mon Sep 17 00:00:00 2001 From: Marcus Watts Date: Fri, 8 May 2020 01:41:35 -0400 Subject: [PATCH] rgw/civetweb: handle old clients with transfer-encoding: chunked. s3 clients *should* provide an x-amz-decoded-content-length field when they use transport-encoding: chunked. Some clients do not. With swift we already allow chunked uploads that do not specify the content length in advance. This commit adds similar support for s3. Known client affected by this: boto2. Fixes: https://tracker.ceph.com/issues/45789 Resolves: rhbz#2152801 Signed-off-by: Marcus Watts (cherry picked from commit 22e9509655ca1d799df2eec535390d20f2f60256) --- src/rgw/rgw_rest_s3.cc | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/rgw/rgw_rest_s3.cc b/src/rgw/rgw_rest_s3.cc index ccb8a397aec25..cee0c8d45f146 100644 --- a/src/rgw/rgw_rest_s3.cc +++ b/src/rgw/rgw_rest_s3.cc @@ -2516,8 +2516,15 @@ static inline void map_qs_metadata(req_state* s, bool crypto_too) int RGWPutObj_ObjStore_S3::get_params(optional_yield y) { - if (!s->length) - return -ERR_LENGTH_REQUIRED; + if (!s->length) { + const char *encoding = s->info.env->get("HTTP_TRANSFER_ENCODING"); + if (!encoding || strcmp(encoding, "chunked") != 0) { + ldout(s->cct, 20) << "neither length nor chunked encoding" << dendl; + return -ERR_LENGTH_REQUIRED; + } + + chunked_upload = true; + } int ret; -- 2.39.5