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

@@ -65,8 +65,6 @@ public:
bool SetData(wxScopedPtr<wxInputStream>& dataStream, const wxString& contentType, wxFileOffset dataSize = wxInvalidOffset);
void SetIgnoreServerErrorStatus(bool ignore) { m_ignoreServerErrorStatus = ignore; }
void SetStorage(wxWebRequest::Storage storage) { m_storage = storage; }
wxWebRequest::Storage GetStorage() const { return m_storage; }
@@ -111,7 +109,9 @@ protected:
wxWebRequestImpl(wxWebSession& session, wxEvtHandler* handler, int id);
bool CheckServerStatus();
// Call SetState() with either State_Failed or State_Completed appropriate
// for the response status.
void SetFinalStateFromStatus();
static bool IsActiveState(wxWebRequest::State state);
@@ -120,7 +120,6 @@ private:
wxEvtHandler* const m_handler;
const int m_id;
wxWebRequest::State m_state;
bool m_ignoreServerErrorStatus;
wxFileOffset m_bytesReceived;
wxCharBuffer m_dataText;