-
Notifications
You must be signed in to change notification settings - Fork 2.1k
FileStreamResult writes to response body for HTTP HEAD when range processing is enabled #7208
Comments
Actually I think line 309 is wrong too, because the request might not even have a range header during a http HEAD request and yet |
I think this bug has been introduced, because a
|
Yeah, SetRangeHeaders needs its own Head check. |
@dustinmoris Thank you for bringing this to our attention. @rynowak @Eilon for the second part of your issue about moving the core functionality for streaming |
@Tratcher - what at the deltas between what MVC does and https://github.com/aspnet/HttpAbstractions/blob/87cd79d6fc54bb4abf07c1e380cd7a9498a78612/src/Microsoft.AspNetCore.Http.Extensions/SendFileResponseExtensions.cs ? Trying to help @dustinmoris question from the OP
|
SendFileAsync's sole function is to copy the contents of the file to the network. It's a glorified MVC can check request headers like Range or If-xxx and alter the response accordingly. It will also set response headers like content-type, content-length, etag, last-modified, etc.. |
Yes agreed, I think it would be hugely beneficial to have a range of HttpContext extensions which can do some of this common work. The MVC Similar things already exist with other complex things like I think this is a good approach and I would love to see this type of architecture take place in other domains of ASP.NET Core as well. |
@Eilon The bug fix is in. Should the second part of the issue (the architecture discussion about moving FileStreamResult to a lower level API) be moved to a new issue in aspnet/Home? |
Hello, thanks for the prompt fix! Sorry for being annoying, but I am implementing something similar in a different application right now and reading all the RFCs and related docs and then comparing it to how MVC has done it as a point of reference and I think I just noticed another very minor bug. The optional
This one can be probably fixed quicker than me creating a new issue, but if you guys prefer to split it out into a new issue and the architectural question as well then I'm happy to do it - just let me know! |
Thanks @dustinmoris! @Tratcher Looks like in |
Similar to this #6260? |
Last question on the topic of |
Hmmm. For background this code was pulled over from StaticFiles where there's always an e-tag. The absence of an e-tag hasn't been thought through. https://tools.ietf.org/html/rfc7232#section-3.1 "It can also be used with safe It doesn't say what to do if the server can't provide an e-tag for the resource. However, e-tags are opaque tokens and are only provided by the server. For a client to have and send one it must have gotten it from the server on a prior request. In this regard I'd expect consistent behavior from the server, either always or never providing an e-tag for a given resource. That makes it extremely unlikely that we'd see this mismatch scenario in real life scenarios, so the existing behavior is probobly fine. |
Moved the discussion about streaming to #7259 |
Uh oh!
There was an error while loading. Please reload this page.
Hi,
I was reviewing some code in order to see how ASP.NET has implemented streaming and I came across something which I believe is a bug, but I haven't tested it, so forgive me if I'm wrong.
I have noticed that if there is a HTTP HEAD request made where range processing is enabled that the
FileResultExecutorBase
calls theSetRangeHeaders
method, which will returnserveBody: true
when the range header was valid.The
serveBody
argument gets passed back into theExecuteAsync
method ofFileStreamResultExecutor
where it then continues to proceed and write the body of the response even though it was aHTTP HEAD
request.Can this be correct?
EDIT:
Also would you be interested in moving the basic functionality of streaming into the core ASP.NET project so it could be used from other frameworks such as Giraffe without having to copy the implementation?
I think it should be easily possible to create a method for
HttpContext
which could do the same as what aFileStreamResult
does now, so it doesn't have to be an MVC specific thing. It could be wrapped by theFileStreamResult
and then it could be re-used by other ASP.NET Core frameworks as well.Any thoughts?
The text was updated successfully, but these errors were encountered: