]> git.saurik.com Git - wxWidgets.git/blame - interface/wx/protocol/http.h
abandon attempts to make wxAnyStrPtr behave as bool: user-defined logical operators...
[wxWidgets.git] / interface / wx / protocol / http.h
CommitLineData
23324ae1
FM
1/////////////////////////////////////////////////////////////////////////////
2// Name: protocol/http.h
e54c96f1 3// Purpose: interface of wxHTTP
23324ae1
FM
4// Author: wxWidgets team
5// RCS-ID: $Id$
6// Licence: wxWindows license
7/////////////////////////////////////////////////////////////////////////////
8
9/**
10 @class wxHTTP
7c913512 11
a30b5ab9 12 wxHTTP can be used to establish a connection to an HTTP server.
7c913512 13
730b772b
FM
14 wxHTTP can thus be used to create a (basic) HTTP @b client.
15
23324ae1
FM
16 @library{wxnet}
17 @category{net}
7c913512 18
e54c96f1 19 @see wxSocketBase, wxURL
23324ae1
FM
20*/
21class wxHTTP : public wxProtocol
22{
23public:
730b772b
FM
24 /**
25 Default constructor.
26 */
27 wxHTTP();
28
29 /**
30 Destructor will close the connection if connected.
31 */
32 virtual ~wxHTTP();
33
e57337ce
VZ
34 //@{
35 /**
36 Connect to the HTTP server.
37
38 By default, connection is made to the port 80 of the specified @a host.
39 You may connect to a non-default port by specifying it explicitly using
40 the second overload.
41 */
882678eb
FM
42 virtual bool Connect(const wxString& host);
43 virtual bool Connect(const wxString& host, unsigned short port);
e57337ce
VZ
44 //@}
45
23324ae1 46 /**
730b772b 47 Returns the data attached with a field whose name is specified by @a header.
a30b5ab9
FM
48 If the field doesn't exist, it will return an empty string and not a @NULL string.
49
50 @note
51 The header is not case-sensitive, i.e. "CONTENT-TYPE" and "content-type"
52 represent the same header.
23324ae1 53 */
adaaa686 54 wxString GetHeader(const wxString& header) const;
23324ae1
FM
55
56 /**
a30b5ab9
FM
57 Creates a new input stream on the specified path.
58
59 Notice that this stream is unseekable, i.e. SeekI() and TellI() methods
60 shouldn't be used.
61
7c913512 62 Note that you can still know the size of the file you are getting using
a30b5ab9
FM
63 wxStreamBase::GetSize(). However there is a limitation: in HTTP protocol,
64 the size is not always specified so sometimes @c (size_t)-1 can returned to
65 indicate that the size is unknown.
66 In such case, you may want to use wxInputStream::LastRead() method in a loop
67 to get the total size.
68
d29a9a8a 69 @return Returns the initialized stream. You must delete it yourself
a30b5ab9 70 once you don't use it anymore and this must be done before
4cc4bfaf
FM
71 the wxHTTP object itself is destroyed. The destructor
72 closes the network connection. The next time you will
73 try to get a file the network connection will have to
74 be reestablished, but you don't have to take care of
75 this since wxHTTP reestablishes it automatically.
a30b5ab9 76
4cc4bfaf 77 @see wxInputStream
23324ae1 78 */
adaaa686 79 virtual wxInputStream* GetInputStream(const wxString& path);
23324ae1
FM
80
81 /**
a30b5ab9
FM
82 Returns the HTTP response code returned by the server.
83
84 Please refer to RFC 2616 for the list of responses.
23324ae1 85 */
730b772b 86 int GetResponse() const;
23324ae1
FM
87
88 /**
89 It sets data of a field to be sent during the next request to the HTTP server.
a30b5ab9 90
730b772b 91 The field name is specified by @a header and the content by @a h_data.
23324ae1
FM
92 This is a low level function and it assumes that you know what you are doing.
93 */
94 void SetHeader(const wxString& header, const wxString& h_data);
95};
e54c96f1 96