Description
ASP.NET Core Kestrel Request trailer headers moved to new collection
In prior versions Kestrel would add HTTP/1.1 chunked trailer headers into the request headers collection when the request body was read to the end. This caused some concerns about ambiguity between headers and trailers so we decided to separate the trailers out to a new collection.
HTTP/2 request trailers were unavailable in 2.2, but are now also available in this new collection in ASP.NET Core 3.0.
New request extension methods have been added to access these trailers.
HTTP/1.1 trailers are available once the entire request body has been read.
HTTP/2 trailers are available as soon as they’re received from the client, but the client won’t send them until the entire request body has been at least buffered by the server. You may need to read the request body to free up buffer space. Trailers will always be available if you read the request body to the end, as the trailers mark the end of the body.
Version introduced
3.0
Old behavior
Request trailer headers would be added to the HttpRequest.Headers
collection.
New behavior
Request trailer headers are not present in the HttpRequest.Headers
collection. Use the following extension methods on HttpRequest
to access them:
GetDeclaredTrailers()
- Gets the request "Trailer" header that lists which trailers to expect after the body.SupportsTrailers()
- Indicates if the request supports receiving trailer headers.CheckTrailersAvailable()
- Checks if the request supports trailers and they are available to be read now.GetTrailer(string trailerName)
- Gets the requested trailing header from the response.
Reason for change
Trailers are a key feature in scenarios like gRPC and merging them in to request headers was confusing to users.
Recommended action
Use the trailer-related extension methods on HttpRequest
to access trailers.
Category
- ASP.NET Core
Affected APIs
Issue metadata
- Issue type: breaking-change