Skip to content

Commit

Permalink
Parse long ranges #158
Browse files Browse the repository at this point in the history
  • Loading branch information
Tratcher committed Jan 26, 2018
1 parent 6fcee95 commit 1687e9a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Microsoft.Owin.StaticFiles/Infrastructure/RangeHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ internal static bool TryParseRanges(string rangeHeader, out IList<Tuple<long?, l

private static bool TryParseLong(string input, out long? result)
{
int temp;
long temp;
if (!string.IsNullOrWhiteSpace(input)
&& int.TryParse(input, NumberStyles.None, CultureInfo.InvariantCulture, out temp))
&& long.TryParse(input, NumberStyles.None, CultureInfo.InvariantCulture, out temp))
{
result = temp;
return true;
Expand Down
2 changes: 2 additions & 0 deletions tests/Microsoft.Owin.StaticFiles.Tests/RangeHeaderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,8 @@ public async Task HEADIfRangeWithoutRangeShouldServeFullContent()
[InlineData("-26", "36-61", 26, "ABCDEFGHIJKLMNOPQRSTUVWXYZ")] // Last 26
[InlineData("0-", "0-61", 62, "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")]
[InlineData("-1001", "0-61", 62, "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")]
[InlineData("-123456789123", "0-61", 62, "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")]
[InlineData("36-123456789123", "36-61", 26, "ABCDEFGHIJKLMNOPQRSTUVWXYZ")]
public async Task SingleValidRangeShouldServePartialContent(string range, string expectedRange, int length, string expectedData)
{
TestServer server = TestServer.Create(app => app.UseFileServer());
Expand Down

0 comments on commit 1687e9a

Please sign in to comment.