]>
Commit | Line | Data |
---|---|---|
1 | ///////////////////////////////////////////////////////////////////////////// | |
2 | // Name: http.h | |
3 | // Purpose: HTTP protocol | |
4 | // Author: Guilhem Lavaux | |
5 | // Modified by: | |
6 | // Created: August 1997 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) 1997, 1998 Guilhem Lavaux | |
9 | // Licence: wxWindows licence | |
10 | ///////////////////////////////////////////////////////////////////////////// | |
11 | #ifndef _WX_HTTP_H | |
12 | #define _WX_HTTP_H | |
13 | ||
14 | #include "wx/defs.h" | |
15 | ||
16 | #if wxUSE_PROTOCOL_HTTP | |
17 | ||
18 | #include "wx/hashmap.h" | |
19 | #include "wx/protocol/protocol.h" | |
20 | ||
21 | WX_DECLARE_EXPORTED_STRING_HASH_MAP( wxString, wxStringToStringHashMap ); | |
22 | ||
23 | class WXDLLIMPEXP_BASE wxHTTP : public wxProtocol | |
24 | { | |
25 | public: | |
26 | wxHTTP(); | |
27 | ~wxHTTP(); | |
28 | ||
29 | bool Connect(const wxString& host, unsigned short port = 0); | |
30 | bool Connect(wxSockAddress& addr, bool wait); | |
31 | bool Abort(); | |
32 | wxInputStream *GetInputStream(const wxString& path); | |
33 | inline wxProtocolError GetError() { return m_perr; } | |
34 | wxString GetContentType(); | |
35 | ||
36 | void SetHeader(const wxString& header, const wxString& h_data); | |
37 | wxString GetHeader(const wxString& header) const; | |
38 | void SetPostBuffer(const wxString& post_buf); | |
39 | ||
40 | void SetProxyMode(bool on); | |
41 | ||
42 | protected: | |
43 | enum wxHTTP_Req | |
44 | { | |
45 | wxHTTP_GET, | |
46 | wxHTTP_POST, | |
47 | wxHTTP_HEAD | |
48 | }; | |
49 | ||
50 | typedef wxStringToStringHashMap::iterator wxHeaderIterator; | |
51 | ||
52 | bool BuildRequest(const wxString& path, wxHTTP_Req req); | |
53 | void SendHeaders(); | |
54 | bool ParseHeaders(); | |
55 | ||
56 | // find the header in m_headers | |
57 | wxHeaderIterator FindHeader(const wxString& header) const; | |
58 | ||
59 | // deletes the header value strings | |
60 | void ClearHeaders(); | |
61 | ||
62 | wxProtocolError m_perr; | |
63 | wxStringToStringHashMap m_headers; | |
64 | bool m_read, | |
65 | m_proxy_mode; | |
66 | wxSockAddress *m_addr; | |
67 | wxString m_post_buf; | |
68 | ||
69 | DECLARE_DYNAMIC_CLASS(wxHTTP) | |
70 | DECLARE_PROTOCOL(wxHTTP) | |
71 | DECLARE_NO_COPY_CLASS(wxHTTP) | |
72 | }; | |
73 | ||
74 | #endif // wxUSE_PROTOCOL_HTTP | |
75 | ||
76 | #endif // _WX_HTTP_H | |
77 |