]>
Commit | Line | Data |
---|---|---|
f4ada568 | 1 | ///////////////////////////////////////////////////////////////////////////// |
80fdcdb9 | 2 | // Name: wx/protocol/http.h |
f4ada568 GL |
3 | // Purpose: HTTP protocol |
4 | // Author: Guilhem Lavaux | |
dbccd1c2 | 5 | // Modified by: Simo Virokannas (authentication, Dec 2005) |
f4ada568 | 6 | // Created: August 1997 |
f4ada568 | 7 | // Copyright: (c) 1997, 1998 Guilhem Lavaux |
65571936 | 8 | // Licence: wxWindows licence |
f4ada568 GL |
9 | ///////////////////////////////////////////////////////////////////////////// |
10 | #ifndef _WX_HTTP_H | |
11 | #define _WX_HTTP_H | |
12 | ||
a5d46b73 VZ |
13 | #include "wx/defs.h" |
14 | ||
15 | #if wxUSE_PROTOCOL_HTTP | |
16 | ||
df5168c4 | 17 | #include "wx/hashmap.h" |
f4ada568 | 18 | #include "wx/protocol/protocol.h" |
ab9d6a4c | 19 | #include "wx/buffer.h" |
f4ada568 | 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 | |
6535170f | 38 | void SetMethod(const wxString& method) { m_method = method; } |
730b772b | 39 | void SetHeader(const wxString& header, const wxString& h_data); |
ab9d6a4c VZ |
40 | bool SetPostText(const wxString& contentType, |
41 | const wxString& data, | |
42 | const wxMBConv& conv = wxConvUTF8); | |
43 | bool SetPostBuffer(const wxString& contentType, const wxMemoryBuffer& data); | |
730b772b | 44 | void SetProxyMode(bool on); |
dbccd1c2 | 45 | |
906cb3f1 JS |
46 | /* Cookies */ |
47 | wxString GetCookie(const wxString& cookie) const; | |
48 | bool HasCookies() const { return m_cookies.size() > 0; } | |
49 | ||
ab9d6a4c VZ |
50 | // Use the other SetPostBuffer() overload or SetPostText() instead. |
51 | wxDEPRECATED(void SetPostBuffer(const wxString& post_buf)); | |
52 | ||
f4ada568 | 53 | protected: |
730b772b FM |
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 | 58 | |
6535170f | 59 | bool BuildRequest(const wxString& path, const wxString& method); |
730b772b FM |
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 | ||
6535170f | 77 | wxString m_method; |
906cb3f1 JS |
78 | wxStringToStringHashMap m_cookies; |
79 | ||
730b772b FM |
80 | wxStringToStringHashMap m_headers; |
81 | bool m_read, | |
82 | m_proxy_mode; | |
83 | wxSockAddress *m_addr; | |
ab9d6a4c VZ |
84 | wxMemoryBuffer m_postBuffer; |
85 | wxString m_contentType; | |
730b772b FM |
86 | int m_http_response; |
87 | ||
88 | DECLARE_DYNAMIC_CLASS(wxHTTP) | |
89 | DECLARE_PROTOCOL(wxHTTP) | |
c0c133e1 | 90 | wxDECLARE_NO_COPY_CLASS(wxHTTP); |
f4ada568 GL |
91 | }; |
92 | ||
a5d46b73 VZ |
93 | #endif // wxUSE_PROTOCOL_HTTP |
94 | ||
95 | #endif // _WX_HTTP_H | |
96 |