- // Get the data
- wxFile fileTest(wxT("test.url"));
- wxFileOutputStream sout(fileTest);
- if (!sout.Ok())
- {
- m_text->AppendText(_("Error: couldn't open file for output\n"));
- m_text->AppendText(_("=== URL test ends ===\n"));
- return;
- }
+ TestLogger logtest("URL");
+
+ // Parse the URL
+ wxURL url(urlname);
+ if ( url.GetError() != wxURL_NOERR )
+ {
+ wxLogError("Failed to parse URL \"%s\"", urlname);
+ return;
+ }
+
+ // Try to get the input stream (connects to the given URL)
+ wxLogMessage("Establishing connection to \"%s\"...", urlname);
+ const std::auto_ptr<wxInputStream> data(url.GetInputStream());
+ if ( !data.get() )
+ {
+ wxLogError("Failed to retrieve URL \"%s\"", urlname);
+ return;
+ }
+
+ // Print the contents type and file size
+ wxLogMessage("Contents type: %s\nFile size: %i\nStarting to download...",
+ url.GetProtocol().GetContentType(),
+ data->GetSize());