1998-09-06 14:28:00 -04:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: http.h
|
|
|
|
// Purpose: HTTP protocol
|
|
|
|
// Author: Guilhem Lavaux
|
2006-01-19 05:28:22 -05:00
|
|
|
// Modified by: Simo Virokannas (authentication, Dec 2005)
|
1998-09-06 14:28:00 -04:00
|
|
|
// Created: August 1997
|
|
|
|
// RCS-ID: $Id$
|
|
|
|
// Copyright: (c) 1997, 1998 Guilhem Lavaux
|
2004-05-23 16:53:33 -04:00
|
|
|
// Licence: wxWindows licence
|
1998-09-06 14:28:00 -04:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
#ifndef _WX_HTTP_H
|
|
|
|
#define _WX_HTTP_H
|
|
|
|
|
2001-12-30 17:27:24 -05:00
|
|
|
#include "wx/defs.h"
|
|
|
|
|
|
|
|
#if wxUSE_PROTOCOL_HTTP
|
|
|
|
|
Added --use-stl to cnfigure, wxUSE_STL to setup0.h
Moved wx/datetime.inl contents to wx/datetime.h and removed
inline redefinition hack.
Implemented STL-like interface on top of wxList/wxArray, when wxUSE_STL=0.
Implemented wxList-like and wxArray interfaces on top of std::list and
std::vector, when wxUSE_STL=1.
Added arrstr.h, moved wxArrayString declaration there; string.h
#includes arrstr.h only if WXWIN_COMPATIBILITY_2_4 is enabled.
Added WX_CLEAR_HASH_MAP, WX_CLEAR_HASH_TABLE, WX_CLEAR_LIST macros,
to clear a wxHashMap, wxHashTable, wxList containing pointers: deletes
pointers and makes container zero-sized.
When wxUSE_STL=1, wxStringList works like a std::list<wxString>.
Made wxBase compile when wxUSE_STL=1.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@21768 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2003-07-08 15:52:35 -04:00
|
|
|
#include "wx/hashmap.h"
|
1998-09-06 14:28:00 -04:00
|
|
|
#include "wx/protocol/protocol.h"
|
|
|
|
|
2003-07-27 18:41:06 -04:00
|
|
|
class WXDLLIMPEXP_NET wxHTTP : public wxProtocol
|
2003-07-10 07:40:26 -04:00
|
|
|
{
|
1998-09-06 14:28:00 -04:00
|
|
|
public:
|
2009-01-16 10:08:13 -05:00
|
|
|
wxHTTP();
|
|
|
|
virtual ~wxHTTP();
|
1998-09-06 14:28:00 -04:00
|
|
|
|
2009-01-16 10:08:13 -05:00
|
|
|
virtual bool Connect(const wxString& host, unsigned short port);
|
|
|
|
virtual bool Connect(const wxString& host) { return Connect(host, 0); }
|
|
|
|
virtual bool Connect(const wxSockAddress& addr, bool wait);
|
|
|
|
bool Abort();
|
1998-09-06 14:28:00 -04:00
|
|
|
|
2009-01-16 10:08:13 -05:00
|
|
|
wxInputStream *GetInputStream(const wxString& path);
|
1999-07-28 13:29:59 -04:00
|
|
|
|
2009-01-16 10:08:13 -05:00
|
|
|
wxString GetContentType() const;
|
|
|
|
wxString GetHeader(const wxString& header) const;
|
|
|
|
int GetResponse() const { return m_http_response; }
|
2003-09-20 19:55:32 -04:00
|
|
|
|
2009-01-16 10:08:13 -05:00
|
|
|
void SetHeader(const wxString& header, const wxString& h_data);
|
|
|
|
void SetPostBuffer(const wxString& post_buf);
|
|
|
|
void SetProxyMode(bool on);
|
2006-01-19 05:28:22 -05:00
|
|
|
|
1998-09-06 14:28:00 -04:00
|
|
|
protected:
|
2009-01-16 10:08:13 -05:00
|
|
|
enum wxHTTP_Req
|
|
|
|
{
|
|
|
|
wxHTTP_GET,
|
|
|
|
wxHTTP_POST,
|
|
|
|
wxHTTP_HEAD
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef wxStringToStringHashMap::iterator wxHeaderIterator;
|
|
|
|
typedef wxStringToStringHashMap::const_iterator wxHeaderConstIterator;
|
|
|
|
|
|
|
|
bool BuildRequest(const wxString& path, wxHTTP_Req req);
|
|
|
|
void SendHeaders();
|
|
|
|
bool ParseHeaders();
|
|
|
|
|
|
|
|
wxString GenerateAuthString(const wxString& user, const wxString& pass) const;
|
|
|
|
|
|
|
|
// find the header in m_headers
|
|
|
|
wxHeaderIterator FindHeader(const wxString& header);
|
|
|
|
wxHeaderConstIterator FindHeader(const wxString& header) const;
|
|
|
|
|
|
|
|
// deletes the header value strings
|
|
|
|
void ClearHeaders();
|
|
|
|
|
|
|
|
|
|
|
|
// internal variables:
|
|
|
|
|
|
|
|
wxStringToStringHashMap m_headers;
|
|
|
|
bool m_read,
|
|
|
|
m_proxy_mode;
|
|
|
|
wxSockAddress *m_addr;
|
|
|
|
wxString m_post_buf;
|
|
|
|
int m_http_response;
|
|
|
|
|
|
|
|
DECLARE_DYNAMIC_CLASS(wxHTTP)
|
|
|
|
DECLARE_PROTOCOL(wxHTTP)
|
2009-02-08 06:45:59 -05:00
|
|
|
wxDECLARE_NO_COPY_CLASS(wxHTTP);
|
1998-09-06 14:28:00 -04:00
|
|
|
};
|
|
|
|
|
2001-12-30 17:27:24 -05:00
|
|
|
#endif // wxUSE_PROTOCOL_HTTP
|
|
|
|
|
|
|
|
#endif // _WX_HTTP_H
|
|
|
|
|