22#ifdef FREECIV_MSWINDOWS
40#ifdef HAVE_CURL_MIME_API
44 struct curl_httppost *
last;
69#ifdef CUSTOM_CACERT_PATH
70 curl_easy_setopt(
chandle, CURLOPT_CAINFO, CUSTOM_CACERT_PATH);
101 struct curl_slist *headers = NULL;
107 headers = curl_slist_append(headers,
"User-Agent: Freeciv/" VERSION_STRING);
109 curl_easy_setopt(handle, CURLOPT_URL, URL);
110 if (mem_data != NULL) {
111 mem_data->
mem = NULL;
114 curl_easy_setopt(handle, CURLOPT_WRITEDATA, mem_data);
116 curl_easy_setopt(handle, CURLOPT_WRITEDATA, fp);
118 curl_easy_setopt(handle, CURLOPT_HTTPHEADER, headers);
119 curl_easy_setopt(handle, CURLOPT_FAILONERROR, 1);
121 curlret = curl_easy_perform(handle);
123 curl_slist_free_all(headers);
125 if (curlret != CURLE_OK) {
127 char buf[2048 + CURL_ERROR_SIZE];
132 _(
"Failed to fetch %s: %s"), URL,
181 _(
"Could not open %s for writing"), filename);
201#ifdef HAVE_CURL_MIME_API
202 post->mime = curl_mime_init(
chandle);
212 const char *
name,
const char *val)
214#ifdef HAVE_CURL_MIME_API
217 part = curl_mime_addpart(post->mime);
219 curl_mime_data(
part, val, CURL_ZERO_TERMINATED);
223 CURLFORM_COPYNAME,
name,
224 CURLFORM_COPYCONTENTS, val,
233 const char *
name,
const int val)
246#ifdef HAVE_CURL_MIME_API
247 curl_mime_free(post->mime);
249 curl_formfree(post->
first);
275 struct curl_slist *headers = NULL;
280 headers = curl_slist_append(headers,
"User-Agent: Freeciv/" VERSION_STRING);
282 curl_easy_setopt(handle, CURLOPT_URL, URL);
284#ifdef HAVE_CURL_MIME_API
285 curl_easy_setopt(handle, CURLOPT_MIMEPOST, post->mime);
287 curl_easy_setopt(handle, CURLOPT_HTTPPOST, post->
first);
290 if (mem_data != NULL) {
291 mem_data->
mem = NULL;
294 curl_easy_setopt(handle, CURLOPT_WRITEDATA, mem_data);
295 }
else if (reply_fp == NULL) {
296 curl_easy_setopt(handle, CURLOPT_WRITEFUNCTION,
dummy_write);
298 curl_easy_setopt(handle, CURLOPT_WRITEDATA, reply_fp);
301 curl_easy_setopt(handle, CURLOPT_INTERFACE, addr);
303 curl_easy_setopt(handle, CURLOPT_HTTPHEADER, headers);
305 curlret = curl_easy_perform(handle);
307 curl_slist_free_all(headers);
309 if (curlret != CURLE_OK) {
313 curl_easy_getinfo(handle, CURLINFO_RESPONSE_CODE, &http_resp);
315 if (http_resp != 200) {
329#ifndef __EMSCRIPTEN__
fz_FILE * fz_from_memory(char *buffer, int size, bool control)
#define fc_calloc(n, esz)
#define fc_realloc(ptr, sz)
static CURL * netfile_init_handle(void)
void netfile_close_post(struct netfile_post *post)
static char error_buf_curl[CURL_ERROR_SIZE]
struct netfile_post * netfile_start_post(void)
bool netfile_send_post(const char *URL, struct netfile_post *post, FILE *reply_fp, struct netfile_write_cb_data *mem_data, const char *addr)
struct section_file * netfile_get_section_file(const char *URL, nf_errmsg cb, void *data)
void netfile_add_form_int(struct netfile_post *post, const char *name, const int val)
static bool netfile_download_file_core(const char *URL, FILE *fp, struct netfile_write_cb_data *mem_data, nf_errmsg cb, void *data)
size_t(* netfile_write_cb)(char *ptr, size_t size, size_t nmemb, void *userdata)
void netfile_add_form_str(struct netfile_post *post, const char *name, const char *val)
bool netfile_download_file(const char *URL, const char *filename, nf_errmsg cb, void *data)
static size_t netfile_memwrite_cb(char *ptr, size_t size, size_t nmemb, void *userdata)
static size_t dummy_write(void *buffer, size_t size, size_t nmemb, void *userp)
void(* nf_errmsg)(const char *msg, void *data)
struct section_file * secfile_from_stream(fz_FILE *stream, bool allow_duplicates)
struct curl_httppost * first
struct curl_httppost * last
int fc_snprintf(char *str, size_t n, const char *format,...)
FILE * fc_fopen(const char *filename, const char *opentype)