using neon (an HTTP and WebDAV client library, with a C interface)
see how to use GET / PUT / POST in some (not-so-perfect) examples
headers
GET
PUT/POST
|
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
|
int do_put(string data, string host, string url) {
ne_session *sess;
ne_request *req;
string response;
ne_sock_init();
sess = ne_session_create("http", host.c_str(), 80);
ne_set_useragent(sess, "MyUserAgent/1.0");
req = ne_request_create(sess, "PUT", url.c_str());
ne_add_request_header(req, "Content-type", "text/xml");
ne_set_request_body_buffer(req, data.c_str(), data.size());
int result = ne_request_dispatch(req);
int status = ne_get_status(req)->code;
ne_request_destroy(req);
string errorMessage = ne_get_error(sess);
ne_session_destroy(sess);
// just print result & status
printf("result %d, status %d\n", result, status);
return 0;
}
|
note: when using with VC9, have to specify “Ws2_32.lib libneon.lib” as Additional deps in Linker (Project properties)

