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

Add EnableRangeProcessingSwitch for FileContentResult and Fil… #6839

Merged
merged 3 commits into from
Sep 18, 2017

Conversation

jbagga
Copy link
Contributor

@jbagga jbagga commented Sep 15, 2017

…eStreamResult

Addresses #6792

cc @Tratcher

@@ -17,6 +17,8 @@ namespace Microsoft.AspNetCore.Mvc.Internal
{
public class FileResultExecutorBase
{
internal const string ProcessRangeRequestsSwitch = "Switch.Microsoft.AspNetCore.Mvc.TurnOnRangeProcessing";
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this name confusing? The switch only applies to FileContentResult and FileStreamResult.

cc @Eilon

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah that's fine actually. Or maybe instead of TurnOn use Enable?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changing it to EnableRangeProcessing

@jbagga jbagga changed the base branch from rel/2.0.1 to feature/2.0.1 September 15, 2017 22:57
@@ -40,6 +42,7 @@ internal enum PreconditionState
ActionContext context,
FileResult result,
long? fileLength,
bool isRangeRequest = true,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

enableRangeProcessing = true
Why not add it at the end? Then you don't have to change PhysicalFile or VirtualFile.

@@ -33,12 +33,20 @@ public virtual Task ExecuteAsync(ActionContext context, FileStreamResult result)
fileLength = result.FileStream.Length;
}

#if NET451
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does this work? MVC.Core only targets netstandard2.0

Assert.Equal(contentLength, httpResponse.ContentLength);
Assert.Equal(expectedString, body);

#if NET451
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be NET461, but the fact that the else worked likely means you don't need it at all. I assume this was copied from something outdated?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah this might not be needed at all if the switch APIs are available in netstandard20. The sample it's copied from is designed for things back to .NET 4.5.1.

@jbagga jbagga force-pushed the jbagga/RangeProcessingSwitch6792 branch from 5b19a9b to a9a87a5 Compare September 15, 2017 23:57
@jbagga
Copy link
Contributor Author

jbagga commented Sep 15, 2017

@Tratcher Updated

@jbagga jbagga changed the title [Design] Add ProcessRangeRequestsSwitch for FileContentResult and Fil… Add EnableRangeProcessingSwitch for FileContentResult and Fil… Sep 16, 2017
Copy link
Contributor

@Eilon Eilon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jbagga
Copy link
Contributor Author

jbagga commented Sep 18, 2017

I'll merge when @Tratcher approves. Thanks!

@jbagga jbagga merged commit b3aa691 into feature/2.0.1 Sep 18, 2017
@jbagga jbagga deleted the jbagga/RangeProcessingSwitch6792 branch September 18, 2017 17:57
Copy link
Member

@Tratcher Tratcher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants