Implement wxWebResponse::GetMimeType() and GetSuggestedFileName()
This commit is contained in:
@@ -103,12 +103,16 @@ public:
|
|||||||
|
|
||||||
virtual wxString GetHeader(const wxString& name) const = 0;
|
virtual wxString GetHeader(const wxString& name) const = 0;
|
||||||
|
|
||||||
|
virtual wxString GetMimeType() const;
|
||||||
|
|
||||||
virtual int GetStatus() const = 0;
|
virtual int GetStatus() const = 0;
|
||||||
|
|
||||||
virtual wxString GetStatusText() const = 0;
|
virtual wxString GetStatusText() const = 0;
|
||||||
|
|
||||||
virtual wxInputStream* GetStream() const = 0;
|
virtual wxInputStream* GetStream() const = 0;
|
||||||
|
|
||||||
|
virtual wxString GetSuggestedFileName() const;
|
||||||
|
|
||||||
virtual wxString AsString(wxMBConv* conv = NULL) const = 0;
|
virtual wxString AsString(wxMBConv* conv = NULL) const = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@@ -18,6 +18,8 @@
|
|||||||
|
|
||||||
#include "wx/webrequest.h"
|
#include "wx/webrequest.h"
|
||||||
#include "wx/mstream.h"
|
#include "wx/mstream.h"
|
||||||
|
#include "wx/uri.h"
|
||||||
|
#include "wx/filename.h"
|
||||||
|
|
||||||
#ifndef WX_PRECOMP
|
#ifndef WX_PRECOMP
|
||||||
#include "wx/app.h"
|
#include "wx/app.h"
|
||||||
@@ -113,6 +115,33 @@ void wxWebRequest::ProcessStateEvent(State state, const wxString& failMsg)
|
|||||||
m_state = state;
|
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
|
// wxWebSession
|
||||||
//
|
//
|
||||||
|
Reference in New Issue
Block a user