#include <wx/protocol/http.h>
wxHTTP can be used to establish a connection to an HTTP server.
wxHTTP can thus be used to create a (basic) HTTP client.
Public Member Functions | |
wxHTTP () | |
Default constructor. | |
virtual | ~wxHTTP () |
Destructor will close the connection if connected. | |
wxString | GetHeader (const wxString &header) const |
Returns the data attached with a field whose name is specified by header. | |
virtual wxInputStream * | GetInputStream (const wxString &path) |
Creates a new input stream on the specified path. | |
int | GetResponse () const |
Returns the HTTP response code returned by the server. | |
void | SetHeader (const wxString &header, const wxString &h_data) |
It sets data of a field to be sent during the next request to the HTTP server. | |
wxString | GetCookie (const wxString &cookie) const |
Returns the value of a cookie. | |
bool | HasCookies () const |
Returns true if there were cookies. | |
virtual bool | Connect (const wxString &host) |
Connect to the HTTP server. | |
virtual bool | Connect (const wxString &host, unsigned short port) |
Connect to the HTTP server. |
wxHTTP::wxHTTP | ( | ) |
Default constructor.
virtual wxHTTP::~wxHTTP | ( | ) | [virtual] |
Destructor will close the connection if connected.
virtual bool wxHTTP::Connect | ( | const wxString & | host, | |
unsigned short | port | |||
) | [virtual] |
Connect to the HTTP server.
By default, connection is made to the port 80 of the specified host. You may connect to a non-default port by specifying it explicitly using the second overload.
virtual bool wxHTTP::Connect | ( | const wxString & | host | ) | [virtual] |
Connect to the HTTP server.
By default, connection is made to the port 80 of the specified host. You may connect to a non-default port by specifying it explicitly using the second overload.
Returns the data attached with a field whose name is specified by header.
If the field doesn't exist, it will return an empty string and not a NULL string.
virtual wxInputStream* wxHTTP::GetInputStream | ( | const wxString & | path | ) | [virtual] |
Creates a new input stream on the specified path.
Notice that this stream is unseekable, i.e. SeekI() and TellI() methods shouldn't be used.
Note that you can still know the size of the file you are getting using wxStreamBase::GetSize(). However there is a limitation: in HTTP protocol, the size is not always specified so sometimes (size_t)-1 can returned to indicate that the size is unknown. In such case, you may want to use wxInputStream::LastRead() method in a loop to get the total size.
Implements wxProtocol.
int wxHTTP::GetResponse | ( | ) | const |
Returns the HTTP response code returned by the server.
Please refer to RFC 2616 for the list of responses.
bool wxHTTP::HasCookies | ( | ) | const |
Returns true if there were cookies.
![]() |
[ top ] |