-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rewrite System.Net.Http.Json functional tests to use a custom HttpMessageHandler #38733
Conversation
Tagging subscribers to this area: @dotnet/ncl |
System.Net.Http.Json is used by the default Blazor WASM template, and I'd assume the majority of Blazor WASM apps that request JSON payloads over Http. Is there any other way we can test the functionality without creating a socket-based loopback server? |
…sageHandler All of the tests start a socket-based loopback server which doesn't work on WebAssembly. We can do the tests using a custom HttpMessageHandler instead of the loopback server as well.
3e0a659
to
0b54d70
Compare
@eerhardt I rewrote the tests to remove the dependency on the socket-based server |
src/libraries/Common/tests/System/Net/Http/GenericLoopbackServer.cs
Outdated
Show resolved
Hide resolved
src/libraries/Common/tests/System/Net/Http/HttpMessageHandlerLoopbackServer.cs
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good besides those two parts that weren't clear to me.
src/libraries/Common/tests/System/Net/Http/HttpMessageHandlerLoopbackServer.cs
Show resolved
Hide resolved
This will probably collide with #38635. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just one question; otherwise, looks good.
for (int i = 0; i < NumRequests; i++) | ||
{ | ||
await server.HandleRequestAsync(content: json, headers: headers); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is that you only have to call HandleRequestAsync
once now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jozkee In the previous implementation we actually had to create four responses from the socket-based loopback server, one for each request since the callback was only invoked once.
Now we invoke the callback for each request so this is no longer necessary.
All of the tests start a socket-based loopback server which doesn't work on WebAssembly.
We can do the tests using a custom HttpMessageHandler instead of the loopback server as well.