]> git.saurik.com Git - wxWidgets.git/blob - include/wx/protocol/http.h
unicode compilation fix
[wxWidgets.git] / include / wx / protocol / http.h
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_STRING_HASH_MAP_WITH_DECL( wxString, wxStringToStringHashMap,
22 class WXDLLIMPEXP_NET );
23
24 class WXDLLIMPEXP_NET wxHTTP : public wxProtocol
25 {
26 public:
27 wxHTTP();
28 ~wxHTTP();
29
30 bool Connect(const wxString& host, unsigned short port = 0);
31 bool Connect(wxSockAddress& addr, bool wait);
32 bool Abort();
33 wxInputStream *GetInputStream(const wxString& path);
34 inline wxProtocolError GetError() { return m_perr; }
35 wxString GetContentType();
36
37 void SetHeader(const wxString& header, const wxString& h_data);
38 wxString GetHeader(const wxString& header) const;
39 void SetPostBuffer(const wxString& post_buf);
40
41 void SetProxyMode(bool on);
42
43 protected:
44 enum wxHTTP_Req
45 {
46 wxHTTP_GET,
47 wxHTTP_POST,
48 wxHTTP_HEAD
49 };
50
51 typedef wxStringToStringHashMap::iterator wxHeaderIterator;
52
53 bool BuildRequest(const wxString& path, wxHTTP_Req req);
54 void SendHeaders();
55 bool ParseHeaders();
56
57 // find the header in m_headers
58 wxHeaderIterator FindHeader(const wxString& header) const;
59
60 // deletes the header value strings
61 void ClearHeaders();
62
63 wxProtocolError m_perr;
64 wxStringToStringHashMap m_headers;
65 bool m_read,
66 m_proxy_mode;
67 wxSockAddress *m_addr;
68 wxString m_post_buf;
69
70 DECLARE_DYNAMIC_CLASS(wxHTTP)
71 DECLARE_PROTOCOL(wxHTTP)
72 DECLARE_NO_COPY_CLASS(wxHTTP)
73 };
74
75 #endif // wxUSE_PROTOCOL_HTTP
76
77 #endif // _WX_HTTP_H
78