SaketaChalamchala commented on code in PR #4987:
URL: https://github.com/apache/ozone/pull/4987#discussion_r1267405472


##########
hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/endpoint/ObjectEndpoint.java:
##########
@@ -229,15 +229,42 @@ public Response put(
       Map<String, String> customMetadata =
           getCustomMetadataFromHeaders(headers.getRequestHeaders());
 
+      long signedChunksLength = -1;
+      boolean signed = false;
       if ("STREAMING-AWS4-HMAC-SHA256-PAYLOAD"
           .equals(headers.getHeaderString("x-amz-content-sha256"))) {
+        signed = true;
         body = new SignedChunksInputStream(body);
+        //signedChunksLength = body2.readHeader();
+        String decodedContentLength = headers.
+            getHeaderString("x-amz-decoded-content-length");
+        if (decodedContentLength != null) {
+          signedChunksLength = Long.parseLong(decodedContentLength);
+        } else {
+          OS3Exception os3Exception = newError(S3ErrorTable.INVALID_REQUEST,
+              keyPath);
+          os3Exception.setErrorMessage("An error occurred (Missing Header) " +
+              "when calling the PutObject/MPU PartUpload operation: " +
+              " Necessary header 'x-amz-decoded-content-length' missing");
+          throw os3Exception;

Review Comment:
   Thanks for working on this patch @Tejaskriya. Most request header 
validations are performed in 
[StringToSignProducer.java](https://github.com/apache/ozone/blob/master/hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/signature/StringToSignProducer.java)
 during  signature validation.
   Would it make sense to move header pre-reqs for multi-part uploads including 
requirements for Content-Length and Content-Encoding as per [AWS 
docs](https://docs.aws.amazon.com/AmazonS3/latest/API/sigv4-streaming.html#sigv4-chunked-upload-sig-calculation-chunk0)
 to a validation function in StringToSignProducer.java?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to