1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/protocol/http.h
3 // Purpose: HTTP protocol
4 // Author: Guilhem Lavaux
5 // Modified by: Simo Virokannas (authentication, Dec 2005)
6 // Created: August 1997
7 // Copyright: (c) 1997, 1998 Guilhem Lavaux
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
15 #if wxUSE_PROTOCOL_HTTP
17 #include "wx/hashmap.h"
18 #include "wx/protocol/protocol.h"
19 #include "wx/buffer.h"
21 class WXDLLIMPEXP_NET wxHTTP
: public wxProtocol
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
);
32 wxInputStream
*GetInputStream(const wxString
& path
);
34 wxString
GetContentType() const;
35 wxString
GetHeader(const wxString
& header
) const;
36 int GetResponse() const { return m_http_response
; }
38 void SetMethod(const wxString
& method
) { m_method
= method
; }
39 void SetHeader(const wxString
& header
, const wxString
& h_data
);
40 bool SetPostText(const wxString
& contentType
,
42 const wxMBConv
& conv
= wxConvUTF8
);
43 bool SetPostBuffer(const wxString
& contentType
, const wxMemoryBuffer
& data
);
44 void SetProxyMode(bool on
);
47 wxString
GetCookie(const wxString
& cookie
) const;
48 bool HasCookies() const { return m_cookies
.size() > 0; }
50 // Use the other SetPostBuffer() overload or SetPostText() instead.
51 wxDEPRECATED(void SetPostBuffer(const wxString
& post_buf
));
54 typedef wxStringToStringHashMap::iterator wxHeaderIterator
;
55 typedef wxStringToStringHashMap::const_iterator wxHeaderConstIterator
;
56 typedef wxStringToStringHashMap::iterator wxCookieIterator
;
57 typedef wxStringToStringHashMap::const_iterator wxCookieConstIterator
;
59 bool BuildRequest(const wxString
& path
, const wxString
& method
);
63 wxString
GenerateAuthString(const wxString
& user
, const wxString
& pass
) const;
65 // find the header in m_headers
66 wxHeaderIterator
FindHeader(const wxString
& header
);
67 wxHeaderConstIterator
FindHeader(const wxString
& header
) const;
68 wxCookieIterator
FindCookie(const wxString
& cookie
);
69 wxCookieConstIterator
FindCookie(const wxString
& cookie
) const;
71 // deletes the header value strings
75 // internal variables:
78 wxStringToStringHashMap m_cookies
;
80 wxStringToStringHashMap m_headers
;
83 wxSockAddress
*m_addr
;
84 wxMemoryBuffer m_postBuffer
;
85 wxString m_contentType
;
88 DECLARE_DYNAMIC_CLASS(wxHTTP
)
89 DECLARE_PROTOCOL(wxHTTP
)
90 wxDECLARE_NO_COPY_CLASS(wxHTTP
);
93 #endif // wxUSE_PROTOCOL_HTTP