aspnet / AspNetWebStack

ASP.NET MVC 5.x, Web API 2.x, and Web Pages 3.x (not ASP.NET Core)
Other
854 stars 353 forks source link

Remove msgtype requirement in HttpMessageContent #407

Open jods4 opened 1 year ago

jods4 commented 1 year ago

HttpMessageContent serializes HTTP requests/responses inside a mulitpart/mixed body.

For requests, it sends the header Content-Type: application/http; msgtype=request. For responses, it expects the header Content-Type: application/http; msgtype=response.

This is where msgtype=request is added in source: https://github.com/aspnet/AspNetWebStack/blob/1231b77d79956152831b75ad7f094f844251b97f/src/System.Net.Http.Formatting/HttpMessageContent.cs#L68

This is where msgtype=response is validated in source: https://github.com/aspnet/AspNetWebStack/blob/1231b77d79956152831b75ad7f094f844251b97f/src/System.Net.Http.Formatting/HttpMessageContent.cs#L142-L171

HttpMessageContent should be configurable to not sent a msgtype parameter, and accept responses without a msgtype (given Content-Type: application/http).

As a common real-world example, the OData specification uses Content-Type: application/http without any further msgtype in both its batched requests and responses, see: https://www.odata.org/documentation/odata-version-2-0/batch-processing/

Inside Microsoft, Dataverse exposes OData services and its batching endpoint is unusable with HttpMessageContent because:

MackinnonBuck commented 1 year ago

Thanks for reaching out. We are currently prioritizing critical bug fixes and security issues over new features in this repository. Putting this in the backlog to collect more feedback.