Skip to content
This repository was archived by the owner on Dec 24, 2022. It is now read-only.

Commit 5a4702a

Browse files
committed
Update HttpUtils.WebRequest.cs
1 parent da747ae commit 5a4702a

File tree

1 file changed

+3
-17
lines changed

1 file changed

+3
-17
lines changed

src/ServiceStack.Text/HttpUtils.WebRequest.cs

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1089,24 +1089,10 @@ public static void DownloadFileTo(this string downloadUrl, string fileName,
10891089

10901090
public static void SetRange(this HttpWebRequest request, long from, long? to)
10911091
{
1092-
var rangeSpecifier = "bytes";
1093-
var curRange = request.Headers[HttpRequestHeader.Range];
1094-
1095-
if (string.IsNullOrEmpty(curRange))
1096-
{
1097-
curRange = rangeSpecifier + "=";
1098-
}
1092+
if (to != null)
1093+
request.AddRange(from, to.Value);
10991094
else
1100-
{
1101-
if (string.Compare(curRange.Substring(0, curRange.IndexOf('=')), rangeSpecifier, StringComparison.OrdinalIgnoreCase) != 0)
1102-
throw new NotSupportedException("Invalid Range: " + curRange);
1103-
curRange = string.Empty;
1104-
}
1105-
curRange += from.ToString();
1106-
if (to != null) {
1107-
curRange += "-" + to;
1108-
}
1109-
request.Headers[HttpRequestHeader.Range] = curRange;
1095+
request.AddRange(from);
11101096
}
11111097

11121098
public static void AddHeader(this HttpWebRequest res, string name, string value) =>

0 commit comments

Comments
 (0)