@azure/storage-file-share 12.11.1-alpha.20220722.1 → 12.11.1-alpha.20220816.3

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
@@ -340,6 +340,7 @@ const FILE_MAX_SIZE_BYTES = 4 * 1024 * 1024 * 1024 * 1024; // 4TB
340
340
  const FILE_RANGE_MAX_SIZE_BYTES = 4 * 1024 * 1024; // 4MB
341
341
  const DEFAULT_MAX_DOWNLOAD_RETRY_REQUESTS = 5;
342
342
  const DEFAULT_HIGH_LEVEL_CONCURRENCY = 5;
343
+ const REQUEST_TIMEOUT = 100 * 1000; // In ms
343
344
  const URLConstants = {
344
345
  Parameters: {
345
346
  FORCE_BROWSER_NO_CACHE: "_",
@@ -453,6 +454,30 @@ const StorageFileLoggingAllowedQueryParameters = [
453
454
  "copyid",
454
455
  "restype",
455
456
  ];
457
+ /// List of ports used for path style addressing.
458
+ /// Path style addressing means that storage account is put in URI's Path segment in instead of in host.
459
+ const PathStylePorts = [
460
+ "10000",
461
+ "10001",
462
+ "10002",
463
+ "10003",
464
+ "10004",
465
+ "10100",
466
+ "10101",
467
+ "10102",
468
+ "10103",
469
+ "10104",
470
+ "11000",
471
+ "11001",
472
+ "11002",
473
+ "11003",
474
+ "11004",
475
+ "11100",
476
+ "11101",
477
+ "11102",
478
+ "11103",
479
+ "11104",
480
+ ];
456
481
 
457
482
  // Copyright (c) Microsoft Corporation.
458
483
  /**
@@ -767,7 +792,8 @@ function isIpEndpointStyle(parsedUrl) {
767
792
  // Case 2: localhost(:port), use broad regex to match port part.
768
793
  // Case 3: Ipv4, use broad regex which just check if host contains Ipv4.
769
794
  // For valid host please refer to https://man7.org/linux/man-pages/man7/hostname.7.html.
770
- return /^.*:.*:.*$|^localhost(:[0-9]+)?$|^(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])(\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])){3}(:[0-9]+)?$/.test(host);
795
+ return (/^.*:.*:.*$|^localhost(:[0-9]+)?$|^(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])(\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])){3}(:[0-9]+)?$/.test(host) ||
796
+ (parsedUrl.getPort() !== undefined && PathStylePorts.includes(parsedUrl.getPort())));
771
797
  }
772
798
  function getShareNameAndPathFromUrl(url) {
773
799
  // URL may look like the following
@@ -11581,8 +11607,10 @@ async function streamToBuffer(stream, buffer, offset, end, encoding) {
11581
11607
  let pos = 0; // Position in stream
11582
11608
  const count = end - offset; // Total amount of data needed in stream
11583
11609
  return new Promise((resolve, reject) => {
11610
+ const timeout = setTimeout(() => reject(new Error(`The operation cannot be completed in timeout.`)), REQUEST_TIMEOUT);
11584
11611
  stream.on("readable", () => {
11585
11612
  if (pos >= count) {
11613
+ clearTimeout(timeout);
11586
11614
  resolve();
11587
11615
  return;
11588
11616
  }
@@ -11599,12 +11627,16 @@ async function streamToBuffer(stream, buffer, offset, end, encoding) {
11599
11627
  pos += chunkLength;
11600
11628
  });
11601
11629
  stream.on("end", () => {
11630
+ clearTimeout(timeout);
11602
11631
  if (pos < count) {
11603
11632
  reject(new Error(`Stream drains before getting enough data needed. Data read: ${pos}, data need: ${count}`));
11604
11633
  }
11605
11634
  resolve();
11606
11635
  });
11607
- stream.on("error", reject);
11636
+ stream.on("error", (msg) => {
11637
+ clearTimeout(timeout);
11638
+ reject(msg);
11639
+ });
11608
11640
  });
11609
11641
  }
11610
11642
  /**