Implement wxWebResponse::GetMimeType() and GetSuggestedFileName()

This commit is contained in:
Tobias Taschner 2018-10-26 23:23:58 +02:00
parent f1d0a00911
commit 871049f1a1
No known key found for this signature in database
GPG Key ID: AE6ECD71294F87FD
2 changed files with 33 additions and 0 deletions

View File

@ -103,12 +103,16 @@ public:
virtual wxString GetHeader(const wxString& name) const = 0;
virtual wxString GetMimeType() const;
virtual int GetStatus() const = 0;
virtual wxString GetStatusText() const = 0;
virtual wxInputStream* GetStream() const = 0;
virtual wxString GetSuggestedFileName() const;
virtual wxString AsString(wxMBConv* conv = NULL) const = 0;
protected:

View File

@ -18,6 +18,8 @@
#include "wx/webrequest.h"
#include "wx/mstream.h"
#include "wx/uri.h"
#include "wx/filename.h"
#ifndef WX_PRECOMP
#include "wx/app.h"
@ -113,6 +115,33 @@ void wxWebRequest::ProcessStateEvent(State state, const wxString& failMsg)
m_state = state;
}
//
// wxWebResponse
//
wxString wxWebResponse::GetMimeType() const
{
return GetHeader("Mime-Type");
}
wxString wxWebResponse::GetSuggestedFileName() const
{
wxString suggestedFilename;
// TODO: get from Content-Disposition header
wxURI uri(GetURL());
if ( uri.HasPath() )
{
wxFileName fn(uri.GetPath());
suggestedFilename = fn.GetFullName();
}
else
suggestedFilename = uri.GetServer();
return suggestedFilename;
}
//
// wxWebSession
//