[HttpMessageContent] Invalid Server header when multiple values are present
manandre opened this issue · 1 comments
manandre commented
When serializing the Server
header, the comma ,
separator is used while the RFC 9110 states that the space
seaprator should be used, like for the User-Agent
header.
It is also correctly stated and implemented in .NET runtime
How to reproduce the issue
using System.Net;
var httpResponseMessage = new HttpResponseMessage(HttpStatusCode.OK);
httpResponseMessage.Headers.Add("Server", new[] {"My", "Gateway"});
var message = new HttpMessageContent(httpResponseMessage);
var messageString = await message.ReadAsStringAsync();
Console.WriteLine(messageString);
Obtained result
HTTP/1.1 200 OK
Server: My, Gateway
Expected result
HTTP/1.1 200 OK
Server: My Gateway
Fix proposal
Add the Server
header to the existing list of _spaceSeparatedValueHeaderFields
AspNetWebStack/src/System.Net.Http.Formatting/HttpMessageContent.cs
Lines 45 to 49 in 1231b77
mkArtakMSFT commented
Thanks for contacting us.
We're not making any improvements in this area any more as this project is in maintenance mode. Only critical blocking issue with wide impact and security issues are considered.