richardszalay/mockhttp

Not Compatible with Sync HttpClient Send

microalps opened this issue · 4 comments

Functional impact

Unable to utilize new Send method implemented in NET5 - dotnet/runtime#34948

Expected result

Return a response, same as awaiting the async version. MockHttpMessageHandler does not implement Send.

Actual result

NotSupportedException: The synchronous method is not supported by 'RichardSzalay.MockHttp.MockHttpMessageHandler'. If you're using a custom 'HttpMessageHandler' and wish to use synchronous HTTP methods, you must override its 'Send' virtual method.

@richardszalay would you be open to a PR? It will also need a dedicated .NET 5 build I guess (not netstandard)

@microalps Do you actually target net5? Given net5's SLS status I'd be more inclined to target net6 if that works for you.

No, but since the change is on net5 I suggested it. I use net6.

Support for this is coming in MockHttp 7.0.0. I will close this ticket once it is released.