Document wxWebResponse::GetContentLength()

Also change its return type from wxInt64 to wxFileOffset for consistency
with all the other length/progress-related functions in wxWebRequest.
This commit is contained in:
Vadim Zeitlin
2021-01-12 03:25:16 +01:00
parent 3da03b3b7b
commit d0f56b1d04
9 changed files with 20 additions and 10 deletions

View File

@@ -24,7 +24,7 @@ class wxWebResponseWinHTTP : public wxWebResponseImpl
public:
wxWebResponseWinHTTP(wxWebRequestWinHTTP& request);
wxInt64 GetContentLength() const wxOVERRIDE { return m_contentLength; }
wxFileOffset GetContentLength() const wxOVERRIDE { return m_contentLength; }
wxString GetURL() const wxOVERRIDE;
@@ -40,7 +40,7 @@ public:
private:
HINTERNET m_requestHandle;
wxInt64 m_contentLength;
wxFileOffset m_contentLength;
wxDECLARE_NO_COPY_CLASS(wxWebResponseWinHTTP);
};

View File

@@ -29,7 +29,7 @@ public:
~wxWebResponseURLSession();
wxInt64 GetContentLength() const wxOVERRIDE;
wxFileOffset GetContentLength() const wxOVERRIDE;
wxString GetURL() const wxOVERRIDE;

View File

@@ -133,7 +133,7 @@ class wxWebResponseImpl : public wxRefCounterMT
public:
virtual ~wxWebResponseImpl();
virtual wxInt64 GetContentLength() const = 0;
virtual wxFileOffset GetContentLength() const = 0;
virtual wxString GetURL() const = 0;

View File

@@ -95,7 +95,7 @@ class wxWebResponseCURL : public wxWebResponseImpl
public:
explicit wxWebResponseCURL(wxWebRequestCURL& request);
wxInt64 GetContentLength() const wxOVERRIDE;
wxFileOffset GetContentLength() const wxOVERRIDE;
wxString GetURL() const wxOVERRIDE;

View File

@@ -93,7 +93,7 @@ public:
bool IsOk() const { return m_impl.get() != NULL; }
wxInt64 GetContentLength() const;
wxFileOffset GetContentLength() const;
wxString GetURL() const;

View File

@@ -394,6 +394,8 @@ public:
This value is based on the @c Content-Length header, if none is found
it will return -1.
@see wxWebResponse::GetContentLength()
*/
wxFileOffset GetBytesExpectedToReceive() const;
///@}
@@ -515,6 +517,14 @@ public:
*/
wxString GetHeader(const wxString& name) const;
/**
Get the length of returned data if available.
Returns the value specified in the @c Content-Length: response header
of @c -1 if not available.
*/
wxFileOffset GetContentLength() const;
/**
Returns the MIME type of the response (if available).
*/

View File

@@ -677,7 +677,7 @@ wxWebResponse::~wxWebResponse()
{
}
wxInt64 wxWebResponse::GetContentLength() const
wxFileOffset wxWebResponse::GetContentLength() const
{
wxCHECK_IMPL( -1 );

View File

@@ -99,7 +99,7 @@ size_t wxWebResponseCURL::CURLOnHeader(const char * buffer, size_t size)
return size;
}
wxInt64 wxWebResponseCURL::GetContentLength() const
wxFileOffset wxWebResponseCURL::GetContentLength() const
{
#if CURL_AT_LEAST_VERSION(7, 55, 0)
curl_off_t len = 0;
@@ -108,7 +108,7 @@ wxInt64 wxWebResponseCURL::GetContentLength() const
#else
double len = 0;
curl_easy_getinfo(GetHandle(), CURLINFO_CONTENT_LENGTH_DOWNLOAD, &len);
return (wxInt64)len;
return (wxFileOffset)len;
#endif
}

View File

@@ -209,7 +209,7 @@ void wxWebResponseURLSession::HandleData(WX_NSData data)
ReportDataReceived(data.length);
}
wxInt64 wxWebResponseURLSession::GetContentLength() const
wxFileOffset wxWebResponseURLSession::GetContentLength() const
{
return m_task.response.expectedContentLength;
}