Add wxWebRequest progress methods
This commit is contained in:
parent
871049f1a1
commit
cf85c04d25
@ -84,6 +84,14 @@ public:
|
||||
|
||||
wxWebAuthChallenge* GetAuthChallenge() const wxOVERRIDE { return m_authChallenge.get(); }
|
||||
|
||||
wxFileOffset GetBytesSent() const wxOVERRIDE { return m_dataWritten; }
|
||||
|
||||
wxFileOffset GetBytesExpectedToSend() const wxOVERRIDE { return m_dataSize; }
|
||||
|
||||
wxFileOffset GetBytesReceived() const wxOVERRIDE { return m_bytesReceived; }
|
||||
|
||||
wxFileOffset GetBytesExpectedToReceive() const wxOVERRIDE { return m_bytesExpectedToReceive; }
|
||||
|
||||
void HandleCallback(DWORD dwInternetStatus, LPVOID lpvStatusInformation,
|
||||
DWORD dwStatusInformationLength);
|
||||
|
||||
@ -98,6 +106,8 @@ private:
|
||||
wxScopedPtr<wxWebAuthChallengeWinHTTP> m_authChallenge;
|
||||
wxMemoryBuffer m_dataWriteBuffer;
|
||||
wxFileOffset m_dataWritten;
|
||||
wxFileOffset m_bytesExpectedToReceive;
|
||||
wxFileOffset m_bytesReceived;
|
||||
|
||||
void SendRequest();
|
||||
|
||||
@ -108,6 +118,7 @@ private:
|
||||
void SetFailedWithLastError();
|
||||
|
||||
friend class wxWebAuthChallengeWinHTTP;
|
||||
friend class wxWebResponseWinHTTP;
|
||||
|
||||
wxDECLARE_NO_COPY_CLASS(wxWebRequestWinHTTP);
|
||||
};
|
||||
|
@ -65,6 +65,14 @@ public:
|
||||
|
||||
State GetState() const { return m_state; }
|
||||
|
||||
virtual wxFileOffset GetBytesSent() const = 0;
|
||||
|
||||
virtual wxFileOffset GetBytesExpectedToSend() const = 0;
|
||||
|
||||
virtual wxFileOffset GetBytesReceived() const = 0;
|
||||
|
||||
virtual wxFileOffset GetBytesExpectedToReceive() const = 0;
|
||||
|
||||
protected:
|
||||
wxString m_method;
|
||||
wxWebRequestHeaderMap m_headers;
|
||||
|
@ -147,7 +147,10 @@ wxWebRequestWinHTTP::wxWebRequestWinHTTP(int id, wxWebSessionWinHTTP& session, c
|
||||
m_session(session),
|
||||
m_url(url),
|
||||
m_connect(NULL),
|
||||
m_request(NULL)
|
||||
m_request(NULL),
|
||||
m_dataWritten(0),
|
||||
m_bytesExpectedToReceive(0),
|
||||
m_bytesReceived(0)
|
||||
{
|
||||
m_headers = session.GetHeaders();
|
||||
}
|
||||
@ -219,6 +222,7 @@ void wxWebRequestWinHTTP::CreateResponse()
|
||||
if (::WinHttpReceiveResponse(m_request, NULL))
|
||||
{
|
||||
m_response.reset(new wxWebResponseWinHTTP(*this));
|
||||
m_bytesExpectedToReceive = m_response->GetContentLength();
|
||||
int status = m_response->GetStatus();
|
||||
if ( status == 401 || status == 407)
|
||||
{
|
||||
@ -415,6 +419,7 @@ bool wxWebResponseWinHTTP::ReadData()
|
||||
bool wxWebResponseWinHTTP::ReportAvailableData(DWORD dataLen)
|
||||
{
|
||||
m_readBuffer.UngetAppendBuf(dataLen);
|
||||
m_request.m_bytesReceived += dataLen;
|
||||
return ReadData();
|
||||
}
|
||||
|
||||
|
@ -96,6 +96,8 @@ TEST_CASE_METHOD(RequestFixture, "WebRequest", "[net][.]")
|
||||
Create("/bytes/65536");
|
||||
Run();
|
||||
REQUIRE( request->GetResponse()->GetContentLength() == 65536 );
|
||||
REQUIRE( request->GetBytesExpectedToReceive() == 65536 );
|
||||
REQUIRE( request->GetBytesReceived() == 65536 );
|
||||
}
|
||||
|
||||
SECTION("GET 404 error")
|
||||
|
Loading…
Reference in New Issue
Block a user