1998-09-06 14:28:00 -04:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: http.h
|
|
|
|
// Purpose: HTTP protocol
|
|
|
|
// Author: Guilhem Lavaux
|
|
|
|
// Modified by:
|
|
|
|
// 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
|
|
|
WX_DECLARE_STRING_HASH_MAP_WITH_DECL( wxString, wxStringToStringHashMap,
|
|
|
|
class WXDLLIMPEXP_NET );
|
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
|
|
|
|
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:
|
|
|
|
wxHTTP();
|
|
|
|
~wxHTTP();
|
|
|
|
|
2003-09-11 05:58:31 -04:00
|
|
|
virtual bool Connect(const wxString& host, unsigned short port);
|
|
|
|
virtual bool Connect(const wxString& host) { return Connect(host, 0); }
|
|
|
|
virtual bool Connect(wxSockAddress& addr, bool wait);
|
1998-09-06 14:28:00 -04:00
|
|
|
bool Abort();
|
|
|
|
wxInputStream *GetInputStream(const wxString& path);
|
|
|
|
inline wxProtocolError GetError() { return m_perr; }
|
|
|
|
wxString GetContentType();
|
|
|
|
|
|
|
|
void SetHeader(const wxString& header, const wxString& h_data);
|
2003-07-10 07:40:26 -04:00
|
|
|
wxString GetHeader(const wxString& header) const;
|
2003-07-09 18:22:47 -04:00
|
|
|
void SetPostBuffer(const wxString& post_buf);
|
1998-09-06 14:28:00 -04:00
|
|
|
|
1999-07-28 13:29:59 -04:00
|
|
|
void SetProxyMode(bool on);
|
|
|
|
|
2003-09-20 19:55:32 -04:00
|
|
|
int GetResponse() { return m_http_response; }
|
|
|
|
|
1998-09-06 14:28:00 -04:00
|
|
|
protected:
|
2003-07-10 07:40:26 -04:00
|
|
|
enum wxHTTP_Req
|
|
|
|
{
|
1999-07-25 10:26:15 -04:00
|
|
|
wxHTTP_GET,
|
2003-07-09 18:22:47 -04:00
|
|
|
wxHTTP_POST,
|
1999-07-25 10:26:15 -04:00
|
|
|
wxHTTP_HEAD
|
2003-07-10 07:40:26 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef wxStringToStringHashMap::iterator wxHeaderIterator;
|
2004-05-08 16:20:24 -04:00
|
|
|
typedef wxStringToStringHashMap::const_iterator wxHeaderConstIterator;
|
2003-07-10 07:40:26 -04:00
|
|
|
|
1998-09-06 14:28:00 -04:00
|
|
|
bool BuildRequest(const wxString& path, wxHTTP_Req req);
|
|
|
|
void SendHeaders();
|
|
|
|
bool ParseHeaders();
|
2002-01-03 12:18:38 -05:00
|
|
|
|
2003-07-10 07:40:26 -04:00
|
|
|
// find the header in m_headers
|
2004-05-08 16:20:24 -04:00
|
|
|
wxHeaderIterator FindHeader(const wxString& header);
|
|
|
|
wxHeaderConstIterator FindHeader(const wxString& header) const;
|
2003-07-10 07:40:26 -04:00
|
|
|
|
2002-01-03 12:18:38 -05:00
|
|
|
// deletes the header value strings
|
|
|
|
void ClearHeaders();
|
2003-01-02 18:38:11 -05:00
|
|
|
|
2003-07-10 07:40:26 -04:00
|
|
|
wxProtocolError m_perr;
|
|
|
|
wxStringToStringHashMap m_headers;
|
|
|
|
bool m_read,
|
|
|
|
m_proxy_mode;
|
|
|
|
wxSockAddress *m_addr;
|
|
|
|
wxString m_post_buf;
|
2003-09-20 19:55:32 -04:00
|
|
|
int m_http_response;
|
2003-07-10 07:40:26 -04:00
|
|
|
|
|
|
|
DECLARE_DYNAMIC_CLASS(wxHTTP)
|
|
|
|
DECLARE_PROTOCOL(wxHTTP)
|
|
|
|
DECLARE_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
|
|
|
|
|