23 #include "wxgis/net/net.h"
27 #include <curl/curl.h>
46 class WXDLLIMPEXP_GIS_NET
wxGISCurl :
public wxObject
50 wxGISCurl(const wxString &proxy, const wxString &sHeaders,
int dnscachetimeout,
int timeout,
int conntimeout);
55 bool operator == ( const
wxGISCurl& obj ) const;
56 bool operator != (const
wxGISCurl& obj)
const {
return !(*
this == obj); };
59 virtual void AppendHeader(
const wxString & sHeadStr);
60 virtual void SetDefaultHeader(
void);
61 virtual void FollowLocation(
bool bSet,
unsigned short iMaxRedirs);
62 virtual void SetSSLVersion(
long nVer = CURL_SSLVERSION_SSLv3);
64 virtual bool GetFile(
const wxString & sURL,
const wxString & sPath);
65 virtual PERFORMRESULT Post(
const wxString & sURL,
const wxString & sPostData);
67 virtual PERFORMRESULT PutData(
const wxString & sURL,
const wxString& sPostData);
69 virtual wxObjectRefData *CreateRefData()
const;
70 virtual wxObjectRefData *CloneRefData(
const wxObjectRefData *data)
const;
80 class wxGISCurlRefData :
public wxObjectRefData
84 wxGISCurlRefData(
const wxString & proxy,
const wxString & sHeaders,
int dnscachetimeout,
int timeout,
int conntimeout);
85 virtual ~wxGISCurlRefData(
void);
86 wxGISCurlRefData(
const wxGISCurlRefData& data);
87 bool operator == (
const wxGISCurlRefData& data)
const;
88 void SetDefaultHeader(
void);
89 void AppendHeader(
const wxString & sHeadStr);
90 void FollowLocation(
bool bSet,
unsigned short iMaxRedirs);
91 void SetSSLVersion(
long nVer = CURL_SSLVERSION_SSLv3);
93 bool GetFile(
const wxString & sURL,
const wxString & sPath);
94 PERFORMRESULT Post(
const wxString & sURL,
const wxString & sPostData);
96 PERFORMRESULT PutData(
const wxString & sURL,
const wxString& sPostData);
98 struct curl_slist *slist;
110 struct MemoryStruct bodystruct;
111 struct MemoryStruct headstruct;
113 static void *myrealloc(
void *ptr,
size_t size)
118 return realloc(ptr, size);
123 static size_t write_data(
void *ptr,
size_t size,
size_t nmemb,
void *data)
125 size_t realsize = size * nmemb;
126 struct MemoryStruct *mem = (
struct MemoryStruct *)data;
128 mem->memory = (
char *)myrealloc(mem->memory, mem->size + realsize + 1);
131 memcpy(&(mem->memory[mem->size]), ptr, realsize);
132 mem->size += realsize;
133 mem->memory[mem->size] = 0;
139 #endif //wxGIS_USE_CURL