Remove unnecessary SetIgnoreServerErrorStatus() from the API

It's up to the application code to decide how it handles the HTTP status
codes it gets back from server, there is no need to have a special
method for handling them in wxWebRequest itself.

We also shouldn't skip downloading the response body just because it was
unsuccessful, we may still need it (e.g. it's very common to return the
detailed error description in a JSON object in the message body when
returning some 4xx error), so don't do it in wxMSW implementation and
add a test verifying that we still get the expected body even for an
error status.

Also improve wxWebRequest::State values documentation.
This commit is contained in:
Vadim Zeitlin
2021-01-15 02:59:54 +01:00
parent bafbcfa90f
commit ef08d499ce
8 changed files with 60 additions and 43 deletions

View File

@@ -192,6 +192,21 @@ TEST_CASE_METHOD(RequestFixture,
Run(wxWebRequest::State_Failed, 404);
}
TEST_CASE_METHOD(RequestFixture,
"WebRequest::Error::Body", "[net][webrequest][error]")
{
if ( !InitBaseURL() )
return;
// We can't use the same httpbin.org server that we use for the other tests
// for this one because it doesn't return anything in the body when
// returning an error status code, so use another one.
CreateAbs("https://httpstat.us/418");
Run(wxWebRequest::State_Failed, 418);
CHECK( request.GetResponse().AsString() == "418 I'm a teapot" );
}
TEST_CASE_METHOD(RequestFixture,
"WebRequest::Error::Connect", "[net][webrequest][error]")
{