-
Notifications
You must be signed in to change notification settings - Fork 0
/
HttpClient.h
62 lines (38 loc) · 1.35 KB
/
HttpClient.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/*************************************************************************
> File Name: HttpClient.h
> Author: berli
> Mail: [email protected]
> Created Time: Wed 12 Dec 2012 05:33:53 PM CST
************************************************************************/
#ifndef HTTP_CLIENT_H_2012_12_12
#define HTTP_CLIENT_H_2012_12_12
#include <iostream>
#include <string>
using namespace std;
#include "curl/curl.h"
class HttpClient
{
public:
HttpClient();
virtual ~HttpClient();
static int InitHttp();
int Post(const string&asURL, const string&asBody, string&asResponse, const bool&abXml=false);
int Get(const string&asURL, string&asResponse);
int Put(const string&asUrl, const string&asParam, string&asResponse, const string&asMethod="PUT");
int Upload(const string&asUrl, const string&asFile, string&asResponse, const string&asParam = "files");
void SetHttpProxy(const string&asProxy);
void SetHttpProxyPort(const size_t&aiProxyPort);
void setHeader(const string&asHeader);
void SetTimeout(const size_t&aiTimeout);
private:
int InitHttp( const string& url, string &asResponse);
static long Writer(void *data, int size, int nmemb, string &asResponse);
protected:
CURL *cpCurl;
char csError[1024];
string csProxy;
size_t ciPort;
string csHeader;
size_t ciTimeout;
};
#endif