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:
committed by
Vadim Zeitlin
parent
916df1a1d1
commit
16d096b7ef
@@ -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;
|
||||
|
||||
@@ -800,6 +800,13 @@ public:
|
||||
*/
|
||||
wxWebRequest::State GetState() const;
|
||||
|
||||
/**
|
||||
Returns a reference to the @c wxWebRequest object which initiated this event.
|
||||
|
||||
@since 3.1.6
|
||||
*/
|
||||
const wxWebRequest& GetRequest() const;
|
||||
|
||||
/**
|
||||
The response with the state set to @c State_Complete or empty response
|
||||
object for other events.
|
||||
|
||||
@@ -335,10 +335,15 @@ void wxWebRequestImpl::ProcessStateEvent(wxWebRequest::State state, const wxStri
|
||||
{
|
||||
wxString dataFile;
|
||||
|
||||
// wxObjectDataPtr ctor takes ownership of raw pointer, so compensate
|
||||
// DecRef() that will be done in its dtor.
|
||||
IncRef();
|
||||
const wxWebRequestImplPtr request(this);
|
||||
|
||||
const wxWebResponseImplPtr& response = GetResponse();
|
||||
|
||||
wxWebRequestEvent evt(wxEVT_WEBREQUEST_STATE, GetId(), state,
|
||||
wxWebResponse(response), failMsg);
|
||||
wxWebRequest(request), wxWebResponse(response), failMsg);
|
||||
|
||||
bool release = false;
|
||||
switch ( state )
|
||||
|
||||
Reference in New Issue
Block a user