]>
Commit | Line | Data |
---|---|---|
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 | |
23324ae1 FM |
14 | @library{wxnet} |
15 | @category{net} | |
7c913512 | 16 | |
e54c96f1 | 17 | @see wxSocketBase, wxURL |
23324ae1 FM |
18 | */ |
19 | class wxHTTP : public wxProtocol | |
20 | { | |
21 | public: | |
e57337ce VZ |
22 | //@{ |
23 | /** | |
24 | Connect to the HTTP server. | |
25 | ||
26 | By default, connection is made to the port 80 of the specified @a host. | |
27 | You may connect to a non-default port by specifying it explicitly using | |
28 | the second overload. | |
29 | */ | |
30 | bool Connect(const wxString& host); | |
31 | bool Connect(const wxString& host, unsigned short port); | |
32 | //@} | |
33 | ||
23324ae1 FM |
34 | /** |
35 | Returns the data attached with a field whose name is specified by @e header. | |
a30b5ab9 FM |
36 | If the field doesn't exist, it will return an empty string and not a @NULL string. |
37 | ||
38 | @note | |
39 | The header is not case-sensitive, i.e. "CONTENT-TYPE" and "content-type" | |
40 | represent the same header. | |
23324ae1 | 41 | */ |
adaaa686 | 42 | wxString GetHeader(const wxString& header) const; |
23324ae1 FM |
43 | |
44 | /** | |
a30b5ab9 FM |
45 | Creates a new input stream on the specified path. |
46 | ||
47 | Notice that this stream is unseekable, i.e. SeekI() and TellI() methods | |
48 | shouldn't be used. | |
49 | ||
7c913512 | 50 | Note that you can still know the size of the file you are getting using |
a30b5ab9 FM |
51 | wxStreamBase::GetSize(). However there is a limitation: in HTTP protocol, |
52 | the size is not always specified so sometimes @c (size_t)-1 can returned to | |
53 | indicate that the size is unknown. | |
54 | In such case, you may want to use wxInputStream::LastRead() method in a loop | |
55 | to get the total size. | |
56 | ||
d29a9a8a | 57 | @return Returns the initialized stream. You must delete it yourself |
a30b5ab9 | 58 | once you don't use it anymore and this must be done before |
4cc4bfaf FM |
59 | the wxHTTP object itself is destroyed. The destructor |
60 | closes the network connection. The next time you will | |
61 | try to get a file the network connection will have to | |
62 | be reestablished, but you don't have to take care of | |
63 | this since wxHTTP reestablishes it automatically. | |
a30b5ab9 | 64 | |
4cc4bfaf | 65 | @see wxInputStream |
23324ae1 | 66 | */ |
adaaa686 | 67 | virtual wxInputStream* GetInputStream(const wxString& path); |
23324ae1 FM |
68 | |
69 | /** | |
a30b5ab9 FM |
70 | Returns the HTTP response code returned by the server. |
71 | ||
72 | Please refer to RFC 2616 for the list of responses. | |
23324ae1 | 73 | */ |
adaaa686 | 74 | int GetResponse(); |
23324ae1 FM |
75 | |
76 | /** | |
77 | It sets data of a field to be sent during the next request to the HTTP server. | |
a30b5ab9 FM |
78 | |
79 | The field name is specified by @a header and the content by @e h_data. | |
23324ae1 FM |
80 | This is a low level function and it assumes that you know what you are doing. |
81 | */ | |
82 | void SetHeader(const wxString& header, const wxString& h_data); | |
83 | }; | |
e54c96f1 | 84 |