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