Search code examples
encryptiondotnet-httpclientfiddler

Fiddler HTTPS Decrypt causes HttpClient to throw "Task was canceled" exception when used with AutoResponder


My app calls an external API, to avoid flooding them with test requests I decided to use Fiddler's AutoResponder to catch the request and respond with a specific response.

The issue that I am running into is that the request is HTTPS, so Fiddler has to be configured to decrypt HTTPS traffic to trigger the AutoResponder rule, but then HttpClient throws a "Task is canceled" exception.

If I turn off HTTPS decryption, then the call goes out to the external API and returns a response, so I know that the code is working as expected.

I am assuming it could be that the AutoResponder's response is not encrypted, or something about the encryption is incorrect.

I have trusted the Fiddler certificate.


Solution

  • The issue was that the response data did not end with two line breaks.

    Adding the line breaks made HttpClient read the response and continue processing as expected.