Get rid of public wxWebSession::GetHeaders()
This is unnecessary, it can be protected and we can initialize wxWebRequest::m_headers directly in its ctor instead of using this function (which also simplifies code and makes it impossible to forget to do this).
This commit is contained in:
@@ -100,14 +100,7 @@ protected:
|
|||||||
wxFileOffset m_dataSize;
|
wxFileOffset m_dataSize;
|
||||||
wxSharedPtr<wxInputStream> m_dataStream;
|
wxSharedPtr<wxInputStream> m_dataStream;
|
||||||
|
|
||||||
wxWebRequest(wxWebSession& session, int id):
|
wxWebRequest(wxWebSession& session, int id);
|
||||||
m_storage(Storage_Memory),
|
|
||||||
m_dataSize(0),
|
|
||||||
m_session(session),
|
|
||||||
m_id(id),
|
|
||||||
m_state(State_Idle),
|
|
||||||
m_ignoreServerErrorStatus(false),
|
|
||||||
m_bytesReceived(0) { }
|
|
||||||
|
|
||||||
bool CheckServerStatus();
|
bool CheckServerStatus();
|
||||||
|
|
||||||
@@ -227,8 +220,6 @@ public:
|
|||||||
virtual void SetHeader(const wxString& name, const wxString& value)
|
virtual void SetHeader(const wxString& name, const wxString& value)
|
||||||
{ m_headers[name] = value; }
|
{ m_headers[name] = value; }
|
||||||
|
|
||||||
const wxWebRequestHeaderMap& GetHeaders() const { return m_headers; }
|
|
||||||
|
|
||||||
void SetTempDir(const wxString& dir) { m_tempDir = dir; }
|
void SetTempDir(const wxString& dir) { m_tempDir = dir; }
|
||||||
|
|
||||||
wxString GetTempDir() const;
|
wxString GetTempDir() const;
|
||||||
@@ -245,7 +236,12 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
wxWebSession();
|
wxWebSession();
|
||||||
|
|
||||||
|
const wxWebRequestHeaderMap& GetHeaders() const { return m_headers; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
// Make it a friend to allow accessing our m_headers.
|
||||||
|
friend class wxWebRequest;
|
||||||
|
|
||||||
wxWebRequestHeaderMap m_headers;
|
wxWebRequestHeaderMap m_headers;
|
||||||
wxString m_tempDir;
|
wxString m_tempDir;
|
||||||
|
|
||||||
|
@@ -59,6 +59,18 @@ wxDEFINE_EVENT(wxEVT_WEBREQUEST_DATA, wxWebRequestEvent);
|
|||||||
//
|
//
|
||||||
// wxWebRequest
|
// wxWebRequest
|
||||||
//
|
//
|
||||||
|
wxWebRequest::wxWebRequest(wxWebSession& session, int id)
|
||||||
|
: m_storage(Storage_Memory),
|
||||||
|
m_headers(session.m_headers),
|
||||||
|
m_dataSize(0),
|
||||||
|
m_session(session),
|
||||||
|
m_id(id),
|
||||||
|
m_state(State_Idle),
|
||||||
|
m_ignoreServerErrorStatus(false),
|
||||||
|
m_bytesReceived(0)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
bool wxWebRequest::CheckServerStatus()
|
bool wxWebRequest::CheckServerStatus()
|
||||||
{
|
{
|
||||||
const wxWebResponse* resp = GetResponse();
|
const wxWebResponse* resp = GetResponse();
|
||||||
|
@@ -149,7 +149,6 @@ static size_t wxCURLRead(char *buffer, size_t size, size_t nitems, void *userdat
|
|||||||
wxWebRequestCURL::wxWebRequestCURL(wxWebSession & session, int id, const wxString & url):
|
wxWebRequestCURL::wxWebRequestCURL(wxWebSession & session, int id, const wxString & url):
|
||||||
wxWebRequest(session, id)
|
wxWebRequest(session, id)
|
||||||
{
|
{
|
||||||
m_headers = session.GetHeaders();
|
|
||||||
m_headerList = NULL;
|
m_headerList = NULL;
|
||||||
|
|
||||||
m_handle = curl_easy_init();
|
m_handle = curl_easy_init();
|
||||||
|
@@ -152,7 +152,6 @@ wxWebRequestWinHTTP::wxWebRequestWinHTTP(int id, wxWebSessionWinHTTP& session, c
|
|||||||
m_request(NULL),
|
m_request(NULL),
|
||||||
m_dataWritten(0)
|
m_dataWritten(0)
|
||||||
{
|
{
|
||||||
m_headers = session.GetHeaders();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wxWebRequestWinHTTP::~wxWebRequestWinHTTP()
|
wxWebRequestWinHTTP::~wxWebRequestWinHTTP()
|
||||||
|
@@ -94,7 +94,6 @@ wxWebRequestURLSession::wxWebRequestURLSession(wxWebSessionURLSession& session,
|
|||||||
wxWebRequest(session, id),
|
wxWebRequest(session, id),
|
||||||
m_url(url)
|
m_url(url)
|
||||||
{
|
{
|
||||||
m_headers = session.GetHeaders();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wxWebRequestURLSession::~wxWebRequestURLSession()
|
wxWebRequestURLSession::~wxWebRequestURLSession()
|
||||||
|
Reference in New Issue
Block a user