2008-03-08 08:52:38 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: protocol/http.h
|
2008-03-10 11:24:38 -04:00
|
|
|
// Purpose: interface of wxHTTP
|
2008-03-08 08:52:38 -05:00
|
|
|
// Author: wxWidgets team
|
|
|
|
// RCS-ID: $Id$
|
|
|
|
// Licence: wxWindows license
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
/**
|
|
|
|
@class wxHTTP
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-04-10 17:31:05 -04:00
|
|
|
wxHTTP can be used to establish a connection to an HTTP server.
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
@library{wxnet}
|
|
|
|
@category{net}
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-10 11:24:38 -04:00
|
|
|
@see wxSocketBase, wxURL
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
class wxHTTP : public wxProtocol
|
|
|
|
{
|
|
|
|
public:
|
2008-09-24 09:16:17 -04:00
|
|
|
//@{
|
|
|
|
/**
|
|
|
|
Connect to the HTTP server.
|
|
|
|
|
|
|
|
By default, connection is made to the port 80 of the specified @a host.
|
|
|
|
You may connect to a non-default port by specifying it explicitly using
|
|
|
|
the second overload.
|
|
|
|
*/
|
|
|
|
bool Connect(const wxString& host);
|
|
|
|
bool Connect(const wxString& host, unsigned short port);
|
|
|
|
//@}
|
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
/**
|
|
|
|
Returns the data attached with a field whose name is specified by @e header.
|
2008-04-10 17:31:05 -04:00
|
|
|
If the field doesn't exist, it will return an empty string and not a @NULL string.
|
|
|
|
|
|
|
|
@note
|
|
|
|
The header is not case-sensitive, i.e. "CONTENT-TYPE" and "content-type"
|
|
|
|
represent the same header.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
wxString GetHeader(const wxString& header) const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
2008-04-10 17:31:05 -04:00
|
|
|
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.
|
|
|
|
|
2008-03-08 09:43:31 -05:00
|
|
|
Note that you can still know the size of the file you are getting using
|
2008-04-10 17:31:05 -04:00
|
|
|
wxStreamBase::GetSize(). However there is a limitation: in HTTP protocol,
|
|
|
|
the size is not always specified so sometimes @c (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.
|
|
|
|
|
2008-05-10 21:38:53 -04:00
|
|
|
@return Returns the initialized stream. You must delete it yourself
|
2008-04-10 17:31:05 -04:00
|
|
|
once you don't use it anymore and this must be done before
|
2008-03-09 08:33:59 -04:00
|
|
|
the wxHTTP object itself is destroyed. The destructor
|
|
|
|
closes the network connection. The next time you will
|
|
|
|
try to get a file the network connection will have to
|
|
|
|
be reestablished, but you don't have to take care of
|
|
|
|
this since wxHTTP reestablishes it automatically.
|
2008-04-10 17:31:05 -04:00
|
|
|
|
2008-03-09 08:33:59 -04:00
|
|
|
@see wxInputStream
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
virtual wxInputStream* GetInputStream(const wxString& path);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
2008-04-10 17:31:05 -04:00
|
|
|
Returns the HTTP response code returned by the server.
|
|
|
|
|
|
|
|
Please refer to RFC 2616 for the list of responses.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
int GetResponse();
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
It sets data of a field to be sent during the next request to the HTTP server.
|
2008-04-10 17:31:05 -04:00
|
|
|
|
|
|
|
The field name is specified by @a header and the content by @e h_data.
|
2008-03-08 08:52:38 -05:00
|
|
|
This is a low level function and it assumes that you know what you are doing.
|
|
|
|
*/
|
|
|
|
void SetHeader(const wxString& header, const wxString& h_data);
|
|
|
|
};
|
2008-03-10 11:24:38 -04:00
|
|
|
|