mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-01-11 21:10:32 +01:00
Body matching can cause "The response ended prematurely" errors #290
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @ilia-cy on GitHub (Aug 14, 2020).
I'm using the mock server for some time now, and I recently started to encounter this strange issue.
All mocked responses work properly, except for ones that are attempting to respond to POST requests that contain something in the body.
These mocked responses fail our CI once in a while, as when the client performs the POST request it receives the following
HttpRequestException:The way i'm matching the responses is either:
.WithBody(new JsonMatcher(bodyContent))if the request body is a JSON..WithBody(new ExactMatcher(bodyContent))if the request body contains encoded parameters.The strange thing is that it doesn't reproduce every time.
Some CIs pass (and I can see the mock server debug of returning the proper response for the request), and some do not (in which I don't see any logs from the mock server for this request).
Please update me if you need more details.
I'm using
WireMock.Net.StandAloneversion 1.2.12 on .NET core.The server is running inside a docker if that makes any difference.
Thanks
@StefH commented on GitHub (Aug 14, 2020):
Is your application running on Linux or Windows?
And could it be that the HttpClient you are using is not used optimally? (there are several StackOverflow articles when you search : https://www.google.com/search?client=firefox-b-d&q=System.IO.IOException%3A+The+response+ended+prematurely.%5Cn+++at+System.Net.Http.HttpConnection.FillAsync%28%29%5C
@StefH commented on GitHub (Aug 14, 2020):
And can you upgrade to latest version? Maybe your bug is related to https://github.com/WireMock-Net/WireMock.Net/issues/474 ?
@ilia-cy commented on GitHub (Aug 14, 2020):
Running on Linux.
Nothing special regarding the HttpClient.
It is the standard .Net Core client, with no special tweaks or settings.
I'll try upgrading to the latest version to see whether it solves it.
Thanks!
@ilia-cy commented on GitHub (Aug 20, 2020):
Upgrading the version to 1.2.18 solved the issue.
Thanks a lot!
@StefH commented on GitHub (Aug 20, 2020):
Hello @ilia-cy, I'm glad your issue is solved.
Closing this one now...