Add wxWebRequestEvent::GetRequest()

It is more convenient to be able to retrieve the request object (which
is needed at least for authentication) from the event than to have to
store it separately.

Closes https://github.com/wxWidgets/wxWidgets/pull/2644

Closes #19360.
This commit is contained in:
Serghei Amelian
2022-01-11 17:35:07 +02:00
committed by Vadim Zeitlin
parent 916df1a1d1
commit 16d096b7ef
3 changed files with 20 additions and 3 deletions

View File

@@ -193,8 +193,9 @@ public:
bool IsPeerVerifyDisabled() const;
private:
// Ctor is only used by wxWebSession.
// Ctor is used by wxWebSession and wxWebRequestImpl.
friend class wxWebSession;
friend class wxWebRequestImpl;
explicit wxWebRequest(const wxWebRequestImplPtr& impl);
wxWebRequestImplPtr m_impl;
@@ -258,15 +259,18 @@ public:
wxWebRequestEvent(wxEventType type = wxEVT_NULL,
int id = wxID_ANY,
wxWebRequest::State state = wxWebRequest::State_Idle,
const wxWebRequest& request = wxWebRequest(),
const wxWebResponse& response = wxWebResponse(),
const wxString& errorDesc = wxString())
: wxEvent(id, type),
m_state(state), m_response(response),
m_state(state), m_request(request), m_response(response),
m_errorDescription(errorDesc)
{ }
wxWebRequest::State GetState() const { return m_state; }
const wxWebRequest& GetRequest() const { return m_request; }
const wxWebResponse& GetResponse() const { return m_response; }
const wxString& GetErrorDescription() const { return m_errorDescription; }
@@ -285,6 +289,7 @@ public:
private:
wxWebRequest::State m_state;
const wxWebRequest m_request;
const wxWebResponse m_response; // may be invalid
wxString m_dataFile;
wxMemoryBuffer m_dataBuf;