]>
Commit | Line | Data |
---|---|---|
f4ada568 GL |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: http.h | |
3 | // Purpose: HTTP protocol | |
4 | // Author: Guilhem Lavaux | |
dbccd1c2 | 5 | // Modified by: Simo Virokannas (authentication, Dec 2005) |
f4ada568 GL |
6 | // Created: August 1997 |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) 1997, 1998 Guilhem Lavaux | |
65571936 | 9 | // Licence: wxWindows licence |
f4ada568 GL |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | #ifndef _WX_HTTP_H | |
12 | #define _WX_HTTP_H | |
13 | ||
a5d46b73 VZ |
14 | #include "wx/defs.h" |
15 | ||
16 | #if wxUSE_PROTOCOL_HTTP | |
17 | ||
df5168c4 | 18 | #include "wx/hashmap.h" |
f4ada568 GL |
19 | #include "wx/protocol/protocol.h" |
20 | ||
7c4728f6 | 21 | class WXDLLIMPEXP_NET wxHTTP : public wxProtocol |
71414756 | 22 | { |
f4ada568 | 23 | public: |
730b772b FM |
24 | wxHTTP(); |
25 | virtual ~wxHTTP(); | |
f4ada568 | 26 | |
730b772b FM |
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(); | |
f4ada568 | 31 | |
730b772b | 32 | wxInputStream *GetInputStream(const wxString& path); |
f61815af | 33 | |
730b772b FM |
34 | wxString GetContentType() const; |
35 | wxString GetHeader(const wxString& header) const; | |
36 | int GetResponse() const { return m_http_response; } | |
2e622163 | 37 | |
730b772b FM |
38 | void SetHeader(const wxString& header, const wxString& h_data); |
39 | void SetPostBuffer(const wxString& post_buf); | |
40 | void SetProxyMode(bool on); | |
dbccd1c2 | 41 | |
906cb3f1 JS |
42 | /* Cookies */ |
43 | wxString GetCookie(const wxString& cookie) const; | |
44 | bool HasCookies() const { return m_cookies.size() > 0; } | |
45 | ||
f4ada568 | 46 | protected: |
730b772b FM |
47 | enum wxHTTP_Req |
48 | { | |
49 | wxHTTP_GET, | |
50 | wxHTTP_POST, | |
51 | wxHTTP_HEAD | |
52 | }; | |
53 | ||
54 | typedef wxStringToStringHashMap::iterator wxHeaderIterator; | |
55 | typedef wxStringToStringHashMap::const_iterator wxHeaderConstIterator; | |
906cb3f1 JS |
56 | typedef wxStringToStringHashMap::iterator wxCookieIterator; |
57 | typedef wxStringToStringHashMap::const_iterator wxCookieConstIterator; | |
730b772b FM |
58 | |
59 | bool BuildRequest(const wxString& path, wxHTTP_Req req); | |
60 | void SendHeaders(); | |
61 | bool ParseHeaders(); | |
62 | ||
63 | wxString GenerateAuthString(const wxString& user, const wxString& pass) const; | |
64 | ||
65 | // find the header in m_headers | |
66 | wxHeaderIterator FindHeader(const wxString& header); | |
67 | wxHeaderConstIterator FindHeader(const wxString& header) const; | |
906cb3f1 JS |
68 | wxCookieIterator FindCookie(const wxString& cookie); |
69 | wxCookieConstIterator FindCookie(const wxString& cookie) const; | |
730b772b FM |
70 | |
71 | // deletes the header value strings | |
72 | void ClearHeaders(); | |
906cb3f1 | 73 | void ClearCookies(); |
730b772b FM |
74 | |
75 | // internal variables: | |
76 | ||
906cb3f1 JS |
77 | wxStringToStringHashMap m_cookies; |
78 | ||
730b772b FM |
79 | wxStringToStringHashMap m_headers; |
80 | bool m_read, | |
81 | m_proxy_mode; | |
82 | wxSockAddress *m_addr; | |
83 | wxString m_post_buf; | |
84 | int m_http_response; | |
85 | ||
86 | DECLARE_DYNAMIC_CLASS(wxHTTP) | |
87 | DECLARE_PROTOCOL(wxHTTP) | |
c0c133e1 | 88 | wxDECLARE_NO_COPY_CLASS(wxHTTP); |
f4ada568 GL |
89 | }; |
90 | ||
a5d46b73 VZ |
91 | #endif // wxUSE_PROTOCOL_HTTP |
92 | ||
93 | #endif // _WX_HTTP_H | |
94 |