]> git.saurik.com Git - wxWidgets.git/blame - include/wx/protocol/http.h
activating DrawRectangle optimization
[wxWidgets.git] / include / wx / protocol / http.h
CommitLineData
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
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 19#include "wx/protocol/protocol.h"
ab9d6a4c 20#include "wx/buffer.h"
f4ada568 21
7c4728f6 22class WXDLLIMPEXP_NET wxHTTP : public wxProtocol
71414756 23{
f4ada568 24public:
730b772b
FM
25 wxHTTP();
26 virtual ~wxHTTP();
f4ada568 27
730b772b
FM
28 virtual bool Connect(const wxString& host, unsigned short port);
29 virtual bool Connect(const wxString& host) { return Connect(host, 0); }
30 virtual bool Connect(const wxSockAddress& addr, bool wait);
31 bool Abort();
f4ada568 32
730b772b 33 wxInputStream *GetInputStream(const wxString& path);
f61815af 34
730b772b
FM
35 wxString GetContentType() const;
36 wxString GetHeader(const wxString& header) const;
37 int GetResponse() const { return m_http_response; }
2e622163 38
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 53protected:
730b772b
FM
54 enum wxHTTP_Req
55 {
56 wxHTTP_GET,
57 wxHTTP_POST,
58 wxHTTP_HEAD
59 };
60
61 typedef wxStringToStringHashMap::iterator wxHeaderIterator;
62 typedef wxStringToStringHashMap::const_iterator wxHeaderConstIterator;
906cb3f1
JS
63 typedef wxStringToStringHashMap::iterator wxCookieIterator;
64 typedef wxStringToStringHashMap::const_iterator wxCookieConstIterator;
730b772b
FM
65
66 bool BuildRequest(const wxString& path, wxHTTP_Req req);
67 void SendHeaders();
68 bool ParseHeaders();
69
70 wxString GenerateAuthString(const wxString& user, const wxString& pass) const;
71
72 // find the header in m_headers
73 wxHeaderIterator FindHeader(const wxString& header);
74 wxHeaderConstIterator FindHeader(const wxString& header) const;
906cb3f1
JS
75 wxCookieIterator FindCookie(const wxString& cookie);
76 wxCookieConstIterator FindCookie(const wxString& cookie) const;
730b772b
FM
77
78 // deletes the header value strings
79 void ClearHeaders();
906cb3f1 80 void ClearCookies();
730b772b
FM
81
82 // internal variables:
83
906cb3f1
JS
84 wxStringToStringHashMap m_cookies;
85
730b772b
FM
86 wxStringToStringHashMap m_headers;
87 bool m_read,
88 m_proxy_mode;
89 wxSockAddress *m_addr;
ab9d6a4c
VZ
90 wxMemoryBuffer m_postBuffer;
91 wxString m_contentType;
730b772b
FM
92 int m_http_response;
93
94 DECLARE_DYNAMIC_CLASS(wxHTTP)
95 DECLARE_PROTOCOL(wxHTTP)
c0c133e1 96 wxDECLARE_NO_COPY_CLASS(wxHTTP);
f4ada568
GL
97};
98
a5d46b73
VZ
99#endif // wxUSE_PROTOCOL_HTTP
100
101#endif // _WX_HTTP_H
102