This repository was archived by the owner on Dec 18, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 516
Set Date and Server headers on response start #862
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 0 additions & 40 deletions
40
src/Microsoft.AspNetCore.Server.Kestrel/Infrastructure/Headers.cs
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -70,7 +70,7 @@ public async Task TestBadRequestLines(string request) | |
| { | ||
| using (var server = new TestServer(context => { return Task.FromResult(0); })) | ||
| { | ||
| using (var connection = new TestConnection(server.Port)) | ||
| using (var connection = server.CreateConnection()) | ||
| { | ||
| await connection.SendEnd(request); | ||
| await ReceiveBadRequestResponse(connection); | ||
|
|
@@ -87,7 +87,7 @@ public async Task ServerClosesConnectionAsSoonAsBadRequestLineIsDetected(string | |
| { | ||
| using (var server = new TestServer(context => { return Task.FromResult(0); })) | ||
| { | ||
| using (var connection = new TestConnection(server.Port)) | ||
| using (var connection = server.CreateConnection()) | ||
| { | ||
| await connection.Send(request); | ||
| await ReceiveBadRequestResponse(connection); | ||
|
|
@@ -103,10 +103,9 @@ await connection.Receive( | |
| await connection.Receive( | ||
| "Connection: close", | ||
| ""); | ||
| await connection.ReceiveStartsWith("Date: "); | ||
| await connection.ReceiveEnd( | ||
| $"Date: {connection.Server.Context.DateHeaderValue}", | ||
| "Content-Length: 0", | ||
| "Server: Kestrel", | ||
| "", | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are there any remaining tests the verify that the "Server: Kestrel" header is sent by default? |
||
| ""); | ||
| } | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks kind of gross. Can we just change the type of the
RequestHeadersandResponseHeadersproperties fromIHeaderDictionarytoFrameRequestHeadersandFrameResponseHeadersand use those properties everywhere?Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure it becomes much better. You'd get into issues with the explicit implementations of
IDictionary<string, StringValues>inFrameHeadersand casting in Frame.FeatureCollection. Example:There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Settable features. What a pain! It makes sense now though.
Is
RequestHeaderseven reset between requests? It doesn't look like it, and I think it needs to be. This seems to be a preexisting issue, but we might as well fix it now that we're looking at it.It looks like
ResponseHeadersis reset inProduceEndwhich works I guess.@Tratcher Why is
IHttpResponseFeature.Headerssettable to begin with? It's not like Kestrel would send those headers to begin with.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@halter73 largely because everything else is. in theory you could wrap the headers collection and apply filters/transforms. No, I would not expect Kestrel to send headers from a new dictionary.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@halter73 Uuuh. Isn't this resetting
RequestHeaders?FrameRequestHeadersandRequestHeadersare the same, remember? 😉 Which in turn is the same asIHttpRequestFeature.Headers... 😖There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@khellang I was referring specifically to the issue you filed in #879 which is that the
RequestHeadersreference should be reset toFrameRequestHeaderslike theResponseHeadersreference is reset toFrameResponseHeadersinProduceEnd. Not thatReset()needs to be called on theRequestHeadersobject itself.