Skip to content

DefaultBinder.Bind errors when POST request with empty body is sent #2813

@yaziciahmet

Description

@yaziciahmet

When a POST request is sent with an empty body, and Bind is called to bind param values, it fails with 415 unsupported media type.

I sent this request from browser and observed that Content-Length = 0 header is actually being sent, but on the server this header seems to be stripped out of headers, and ContentLength on the request object is set to -1, causing the request content length to be treated as unknown, and causing Bind method to fail.

I am aware I can just use c.Param or just sent an empty json etc. but this failing felt off so wanted to share it.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions