diff --git a/include/wx/webrequest.h b/include/wx/webrequest.h index da6ec690e5..62d5ac4884 100644 --- a/include/wx/webrequest.h +++ b/include/wx/webrequest.h @@ -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: diff --git a/src/common/webrequest.cpp b/src/common/webrequest.cpp index 4432762d77..20f6afa719 100644 --- a/src/common/webrequest.cpp +++ b/src/common/webrequest.cpp @@ -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 //