-
Notifications
You must be signed in to change notification settings - Fork 69
Closed
Labels
Needs: Triage 🔍Label added to new issues which need TriageLabel added to new issues which need Triage
Description
Summary
Using this library in a dotnet core application forcefully adds content-type "text/html" (when not set) even if there's no content. This isn't always desired and I think it's neither expected when there is no content for the response.
Motivation and goals
- Some clients break when there is a content-type set but no content
- At least for my migrated projects this doesn't mimic the behavior I had in the old application
Risks / unknowns
If somebody already using this library relies on this header always being set this change may break something
Detailed design
The change I've done for now is very simple.
src/Microsoft.AspNetCore.SystemWebAdapters.CoreServices/SetDefaultResponseHeadersMiddleware.cs -> WriteDefaultContentType
Added new criteria "hasContent"
bool hasContent = context.Response.ContentLength.HasValue;
if (hasContent && context.Response.Headers.ContentType.Count == 0)
{
context.Response.Headers.ContentType = "text/html";
}
Metadata
Metadata
Assignees
Labels
Needs: Triage 🔍Label added to new issues which need TriageLabel added to new issues which need Triage