@azure/storage-queue 12.23.0-alpha.20240628.1 → 12.23.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
@@ -1979,6 +1979,32 @@ class StorageBrowserPolicyFactory {
1979
1979
  }
1980
1980
  }
1981
1981
 
1982
+ // Copyright (c) Microsoft Corporation.
1983
+ // Licensed under the MIT license.
1984
+ /**
1985
+ * The programmatic identifier of the storageCorrectContentLengthPolicy.
1986
+ */
1987
+ const storageCorrectContentLengthPolicyName = "StorageCorrectContentLengthPolicy";
1988
+ /**
1989
+ * storageCorrectContentLengthPolicy to correctly set Content-Length header with request body length.
1990
+ */
1991
+ function storageCorrectContentLengthPolicy() {
1992
+ function correctContentLength(request) {
1993
+ if (request.body &&
1994
+ (typeof request.body === "string" || Buffer.isBuffer(request.body)) &&
1995
+ request.body.length > 0) {
1996
+ request.headers.set(HeaderConstants.CONTENT_LENGTH, Buffer.byteLength(request.body));
1997
+ }
1998
+ }
1999
+ return {
2000
+ name: storageCorrectContentLengthPolicyName,
2001
+ async sendRequest(request, next) {
2002
+ correctContentLength(request);
2003
+ return next(request);
2004
+ },
2005
+ };
2006
+ }
2007
+
1982
2008
  // Copyright (c) Microsoft Corporation.
1983
2009
  // Licensed under the MIT license.
1984
2010
  /**
@@ -2108,6 +2134,7 @@ function getCoreClientOptions(pipeline) {
2108
2134
  } }));
2109
2135
  corePipeline.removePolicy({ phase: "Retry" });
2110
2136
  corePipeline.removePolicy({ name: coreRestPipeline.decompressResponsePolicyName });
2137
+ corePipeline.addPolicy(storageCorrectContentLengthPolicy());
2111
2138
  corePipeline.addPolicy(storageRetryPolicy(restOptions.retryOptions), { phase: "Retry" });
2112
2139
  corePipeline.addPolicy(storageBrowserPolicy());
2113
2140
  const downlevelResults = processDownlevelPipeline(pipeline);