Make HTTP requests with not matching Content-Length and body length for testing purposes

282 Views Asked by At

For testing purposes I want to make some invalid HTTP requests, e.g. Content-Length header smaller than the real body size and also the other way (Content-Length header larger than the real body size).

I tried with the .NET HttpClient, but the client does some checks on it's client side, so I end up with

System.Net.Http.HttpRequestException: Unable to write content to request stream; content would exceed Content-Length.

respectively

System.Net.Http.HttpRequestException: Unable to write content to request stream; content would exceed Content-Length.

Any way to turn this checks of or any HttpClient implementations for C#/.NET that just do what I want?

0

There are 0 best solutions below