@azure/storage-file-share 12.24.0-alpha.20240709.2 → 12.24.0-alpha.20240711.1

Sign up to get free protection for your applications and to get access to all the features.
package/dist/index.js CHANGED
@@ -2503,6 +2503,32 @@ class StorageBrowserPolicyFactory {
2503
2503
  }
2504
2504
  }
2505
2505
 
2506
+ // Copyright (c) Microsoft Corporation.
2507
+ // Licensed under the MIT license.
2508
+ /**
2509
+ * The programmatic identifier of the storageCorrectContentLengthPolicy.
2510
+ */
2511
+ const storageCorrectContentLengthPolicyName = "StorageCorrectContentLengthPolicy";
2512
+ /**
2513
+ * storageCorrectContentLengthPolicy to correctly set Content-Length header with request body length.
2514
+ */
2515
+ function storageCorrectContentLengthPolicy() {
2516
+ function correctContentLength(request) {
2517
+ if (request.body &&
2518
+ (typeof request.body === "string" || Buffer.isBuffer(request.body)) &&
2519
+ request.body.length > 0) {
2520
+ request.headers.set(HeaderConstants.CONTENT_LENGTH, Buffer.byteLength(request.body));
2521
+ }
2522
+ }
2523
+ return {
2524
+ name: storageCorrectContentLengthPolicyName,
2525
+ async sendRequest(request, next) {
2526
+ correctContentLength(request);
2527
+ return next(request);
2528
+ },
2529
+ };
2530
+ }
2531
+
2506
2532
  // Copyright (c) Microsoft Corporation.
2507
2533
  // Licensed under the MIT license.
2508
2534
  /**
@@ -2632,6 +2658,7 @@ function getCoreClientOptions(pipeline) {
2632
2658
  } }));
2633
2659
  corePipeline.removePolicy({ phase: "Retry" });
2634
2660
  corePipeline.removePolicy({ name: coreRestPipeline.decompressResponsePolicyName });
2661
+ corePipeline.addPolicy(storageCorrectContentLengthPolicy());
2635
2662
  corePipeline.addPolicy(storageRetryPolicy(restOptions.retryOptions), { phase: "Retry" });
2636
2663
  corePipeline.addPolicy(storageBrowserPolicy());
2637
2664
  const downlevelResults = processDownlevelPipeline(pipeline);