]> git.saurik.com Git - wxWidgets.git/blob - include/wx/protocol/http.h
1e99661b1e086ca489001cf2909ba309c4cfeed3
[wxWidgets.git] / include / wx / protocol / http.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: http.h
3 // Purpose: HTTP protocol
4 // Author: Guilhem Lavaux
5 // Modified by: Simo Virokannas (authentication, Dec 2005)
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 class WXDLLIMPEXP_NET wxHTTP : public wxProtocol
22 {
23 public:
24 wxHTTP();
25 virtual ~wxHTTP();
26
27 virtual bool Connect(const wxString& host, unsigned short port);
28 virtual bool Connect(const wxString& host) { return Connect(host, 0); }
29 virtual bool Connect(const wxSockAddress& addr, bool wait);
30 bool Abort();
31
32 wxInputStream *GetInputStream(const wxString& path);
33
34 wxString GetContentType() const;
35 wxString GetHeader(const wxString& header) const;
36 int GetResponse() const { return m_http_response; }
37
38 void SetHeader(const wxString& header, const wxString& h_data);
39 void SetPostBuffer(const wxString& post_buf);
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 typedef wxStringToStringHashMap::const_iterator wxHeaderConstIterator;
52
53 bool BuildRequest(const wxString& path, wxHTTP_Req req);
54 void SendHeaders();
55 bool ParseHeaders();
56
57 wxString GenerateAuthString(const wxString& user, const wxString& pass) const;
58
59 // find the header in m_headers
60 wxHeaderIterator FindHeader(const wxString& header);
61 wxHeaderConstIterator FindHeader(const wxString& header) const;
62
63 // deletes the header value strings
64 void ClearHeaders();
65
66
67 // internal variables:
68
69 wxStringToStringHashMap m_headers;
70 bool m_read,
71 m_proxy_mode;
72 wxSockAddress *m_addr;
73 wxString m_post_buf;
74 int m_http_response;
75
76 DECLARE_DYNAMIC_CLASS(wxHTTP)
77 DECLARE_PROTOCOL(wxHTTP)
78 wxDECLARE_NO_COPY_CLASS(wxHTTP);
79 };
80
81 #endif // wxUSE_PROTOCOL_HTTP
82
83 #endif // _WX_HTTP_H
84