fixed URL parsing problem

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@4405 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Václav Slavík
1999-11-06 17:28:02 +00:00
parent 0e528b997e
commit 81915974f6

View File

@@ -70,7 +70,13 @@ class wxInetCacheNode : public wxObject
bool wxInternetFSHandler::CanOpen(const wxString& location) bool wxInternetFSHandler::CanOpen(const wxString& location)
{ {
wxString p = GetProtocol(location); wxString p = GetProtocol(location);
return (p == wxT("http")) || (p == wxT("ftp")); if ((p == wxT("http")) || (p == wxT("ftp")))
{
wxURL url(GetProtocol(location) + wxT(":") + GetRightLocation(location));
return (url.GetError() == wxURL_NOERR);
}
else
return FALSE;
} }
@@ -87,27 +93,30 @@ wxFSFile* wxInternetFSHandler::OpenFile(wxFileSystem& WXUNUSED(fs), const wxStri
if (info == NULL) if (info == NULL)
{ {
wxURL url(right); wxURL url(right);
s = url.GetInputStream(); if (url.GetError() == wxURL_NOERR)
content = url.GetProtocol().GetContentType();
if (content == wxEmptyString) content = GetMimeTypeFromExt(location);
if (s)
{ {
wxChar buf[256]; s = url.GetInputStream();
content = url.GetProtocol().GetContentType();
if (content == wxEmptyString) content = GetMimeTypeFromExt(location);
if (s)
{
wxChar buf[256];
wxGetTempFileName( wxT("wxhtml"), buf); wxGetTempFileName( wxT("wxhtml"), buf);
info = new wxInetCacheNode(buf, content); info = new wxInetCacheNode(buf, content);
m_Cache.Put(right, info); m_Cache.Put(right, info);
{ // ok, now copy it: { // ok, now copy it:
wxFileOutputStream sout((wxString)buf); wxFileOutputStream sout((wxString)buf);
s -> Read(sout); // copy the stream s -> Read(sout); // copy the stream
}
delete s;
} }
delete s; else
return (wxFSFile*) NULL; // we can't open the URL
} }
else else
{ return (wxFSFile*) NULL; // incorrect URL
return (wxFSFile*) NULL; // we can't open the URL
}
} }
// Load item from cache: // Load item from cache: