Example #1
0
PCS_API PcsBool pcs_http_get_download(PcsHttp handle, const char *url, PcsBool follow_location, curl_off_t max_speed, curl_off_t resume_from, curl_off_t max_length)
{
	struct pcs_http *http = (struct pcs_http *)handle;
	pcs_http_prepare(http, HTTP_METHOD_GET, url, follow_location, &pcs_http_write, http, max_speed, resume_from, max_length);
	http->res_type = PCS_HTTP_RES_TYPE_DOWNLOAD;
	pcs_http_perform(http, url);
	return http->strerror == NULL ? PcsTrue : PcsFalse;
}
Example #2
0
PCS_API char *pcs_http_post(PcsHttp handle, const char *url, char *post_data, PcsBool follow_location)
{
	struct pcs_http *http = (struct pcs_http *)handle;
	pcs_http_prepare(http, HTTP_METHOD_POST, url, follow_location, &pcs_http_write, http, 0, 0, 0, 0);
	if (post_data)
		curl_easy_setopt(http->curl, CURLOPT_POSTFIELDS, post_data);  
	else
		curl_easy_setopt(http->curl, CURLOPT_POSTFIELDS, "");  
	return pcs_http_perform(http, url);
}
Example #3
0
PCS_API char *pcs_http_get_raw(PcsHttp handle, const char *url, PcsBool follow_location, size_t *sz)
{
	struct pcs_http *http = (struct pcs_http *)handle;
	char *data;
	pcs_http_prepare(http, HTTP_METHOD_GET, url, follow_location, &pcs_http_write, http, 0, 0, 0, 0);
	http->res_type = PCS_HTTP_RES_TYPE_RAW;
	data = pcs_http_perform(http, url);
	if (sz) *sz = http->res_body_size;
	return data;
}
Example #4
0
PCS_API char *pcs_post_httpform(PcsHttp handle, const char *url, PcsHttpForm data, PcsBool follow_location)
{
	struct pcs_http *http = (struct pcs_http *)handle;
	struct http_post *formpost = (struct http_post *)data;
	pcs_http_prepare(http, HTTP_METHOD_POST, url, follow_location, &pcs_http_write, http);
	if (data)
		curl_easy_setopt(http->curl, CURLOPT_HTTPPOST, formpost->formpost); 
	else
		curl_easy_setopt(http->curl, CURLOPT_POSTFIELDS, "");  
	return pcs_http_perform(http);
}
Example #5
0
PCS_API char *pcs_post_httpform(PcsHttp handle, const char *url, PcsHttpForm data, curl_off_t max_speed, PcsBool follow_location)
{
	struct pcs_http *http = (struct pcs_http *)handle;
	struct http_post *formpost = (struct http_post *)data;
	char *rc;
	pcs_http_prepare(http, HTTP_METHOD_POST, url, follow_location, &pcs_http_write, http, 0, max_speed, 0, 0);
	if (data){
		curl_easy_setopt(http->curl, CURLOPT_HTTPPOST, formpost->formpost); 
		if (formpost->read_func) {
			curl_easy_setopt(http->curl, CURLOPT_READFUNCTION, formpost->read_func);
			curl_easy_setopt(http->curl, CURLOPT_READDATA, formpost->read_func_data);
		}
	}
	else
		curl_easy_setopt(http->curl, CURLOPT_POSTFIELDS, "");  
	rc = pcs_http_perform(http, url);
	if (data && formpost->read_func) {
		curl_easy_setopt(http->curl, CURLOPT_READFUNCTION, NULL);
		curl_easy_setopt(http->curl, CURLOPT_READDATA, NULL);
	}
	return rc;
}
Example #6
0
PCS_API char *pcs_http_get(PcsHttp handle, const char *url, PcsBool follow_location)
{
	struct pcs_http *http = (struct pcs_http *)handle;
	pcs_http_prepare(http, HTTP_METHOD_GET, url, follow_location, &pcs_http_write, http, 0, 0, 0, 0);
	return pcs_http_perform(http, url);
}