@azure/storage-blob 12.24.0-alpha.20240628.1 → 12.24.0-alpha.20240710.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1996,6 +1996,32 @@ class StorageBrowserPolicyFactory {
1996
1996
  }
1997
1997
  }
1998
1998
 
1999
+ // Copyright (c) Microsoft Corporation.
2000
+ // Licensed under the MIT license.
2001
+ /**
2002
+ * The programmatic identifier of the storageCorrectContentLengthPolicy.
2003
+ */
2004
+ const storageCorrectContentLengthPolicyName = "StorageCorrectContentLengthPolicy";
2005
+ /**
2006
+ * storageCorrectContentLengthPolicy to correctly set Content-Length header with request body length.
2007
+ */
2008
+ function storageCorrectContentLengthPolicy() {
2009
+ function correctContentLength(request) {
2010
+ if (request.body &&
2011
+ (typeof request.body === "string" || Buffer.isBuffer(request.body)) &&
2012
+ request.body.length > 0) {
2013
+ request.headers.set(HeaderConstants.CONTENT_LENGTH, Buffer.byteLength(request.body));
2014
+ }
2015
+ }
2016
+ return {
2017
+ name: storageCorrectContentLengthPolicyName,
2018
+ async sendRequest(request, next) {
2019
+ correctContentLength(request);
2020
+ return next(request);
2021
+ },
2022
+ };
2023
+ }
2024
+
1999
2025
  // Copyright (c) Microsoft Corporation.
2000
2026
  // Licensed under the MIT license.
2001
2027
  /**
@@ -2125,6 +2151,7 @@ function getCoreClientOptions(pipeline) {
2125
2151
  } }));
2126
2152
  corePipeline.removePolicy({ phase: "Retry" });
2127
2153
  corePipeline.removePolicy({ name: coreRestPipeline.decompressResponsePolicyName });
2154
+ corePipeline.addPolicy(storageCorrectContentLengthPolicy());
2128
2155
  corePipeline.addPolicy(storageRetryPolicy(restOptions.retryOptions), { phase: "Retry" });
2129
2156
  corePipeline.addPolicy(storageBrowserPolicy());
2130
2157
  const downlevelResults = processDownlevelPipeline(pipeline);