wxHTTP http;
http.SetHeader ( wxT("Accept") , wxT("text/*") );
http.SetHeader ( wxT("User-Agent"), wxGetApp().GetAppName() );
// The wxWidgets default timeout is 10 minutes.
http.SetTimeout ( 120 );
// Note that Connect() wants a host address, not an URL. 80 is the server's port.
if ( http.Connect ( "myserver.com", 80 ) )
{
if ( wxInputStream *stream = http.GetInputStream ( wxT("/path/to/some.file") ) )
{
// Will hold the content of the file (assuming that it's a text file).
wxString data;
wxStringOutputStream out_stream ( &data );
// The data will be streamed to the variable "data".
stream->Read ( out_stream );
delete stream;
}
}
// Handle errors etc.
http.SetHeader ( wxT("Accept") , wxT("text/*") );
http.SetHeader ( wxT("User-Agent"), wxGetApp().GetAppName() );
// The wxWidgets default timeout is 10 minutes.
http.SetTimeout ( 120 );
// Note that Connect() wants a host address, not an URL. 80 is the server's port.
if ( http.Connect ( "myserver.com", 80 ) )
{
if ( wxInputStream *stream = http.GetInputStream ( wxT("/path/to/some.file") ) )
{
// Will hold the content of the file (assuming that it's a text file).
wxString data;
wxStringOutputStream out_stream ( &data );
// The data will be streamed to the variable "data".
stream->Read ( out_stream );
delete stream;
}
}
// Handle errors etc.
No comments are included for this article. Submit a comment with your feedback/suggestions.
Click to View Printer Friendly Version