HTTP body conversion will throw an InvalidOperationException when the request have an empty body.
Fixed in v1.3.2When using the ASP.NET Core integration, a response is never sent back to the client, the request will hang. (Maybe related to #2476)
With the built-in HTTP type with the default System.Text.Json serializer, a response with status code 500 will be sent back to the client.
With the built-in HTTP type with Newtonsoft as the serializer :
Sending an empty body will throw and a response with status code 500 will be sent back to the client.
Sending an empty body with the header Content-Type: application/json allows the conversion to proceed without any error. The AzureFunction will receive a null object.
With the in-process model sending an empty body will create an instance of the object.
Description
HTTP body conversion will throw an InvalidOperationException when the request have an empty body.
Fixed in v1.3.2
When using the ASP.NET Core integration, a response is never sent back to the client, the request will hang. (Maybe related to #2476)With the built-in HTTP type with the default
System.Text.Json
serializer, a response with status code 500 will be sent back to the client.With the built-in HTTP type with
Newtonsoft
as the serializer :Content-Type: application/json
allows the conversion to proceed without any error. The AzureFunction will receive a null object.With the in-process model sending an empty body will create an instance of the object.
With the built-in HTTP type I have traced the origin of the issue(s) back to this line of the DefaultFromBodyConversionFeature.
Steps to reproduce
This repository has been made available to demonstrate the issue.
Debug each project one by one and send all 3 request to them :
curl -d '{ "Name": "potato" }' -H "Content-Type: application/json" -X POST http://localhost:7021/api/Function1 -v
curl -H "Content-Type: application/json" -X POST http://localhost:7021/api/Function1 -v
curl -X POST http://localhost:7021/api/Function1 -v
This will demonstrate the issues and the difference in behavior between them.
The latest version of the packages have been used :