X-Git-Url: http://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Flib%2Furllib.qc;h=d1d5c65ed2a3d4bcf34e1a35789a709e44521c07;hb=bf094df0de66898cb15780dbf136bf93b0761857;hp=80145d8b84c15142b97be992968e38601e1f7c5f;hpb=e0e847a336cdb7ab1fcb93d3cf3e1402b761a726;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/lib/urllib.qc b/qcsrc/lib/urllib.qc index 80145d8b8..d1d5c65ed 100644 --- a/qcsrc/lib/urllib.qc +++ b/qcsrc/lib/urllib.qc @@ -7,6 +7,8 @@ const float URL_FH_STDOUT = -2; // URLs .string url_url; +.string url_content_type; +.string url_verb; .float url_wbuf; .float url_wbufpos; .float url_rbuf; @@ -53,7 +55,7 @@ float url_URI_Get_Callback(int id, float status, string data) LOG_INFO("url_URI_Get_Callback: out of memory in buf_create\n"); e.url_ready(e, e.url_ready_pass, URL_READY_ERROR); strunzone(e.url_url); - remove(e); + delete(e); return 1; } e.url_rbufpos = 0; @@ -62,7 +64,7 @@ float url_URI_Get_Callback(int id, float status, string data) LOG_INFO("url_URI_Get_Callback: out of memory in buf_create\n"); e.url_ready(e, e.url_ready_pass, URL_READY_ERROR); strunzone(e.url_url); - remove(e); + delete(e); return 1; } for (i = 0; i < n; ++i) @@ -75,7 +77,7 @@ float url_URI_Get_Callback(int id, float status, string data) // an ERROR e.url_ready(e, e.url_ready_pass, -fabs(status)); strunzone(e.url_url); - remove(e); + delete(e); return 1; } } @@ -96,6 +98,8 @@ void url_single_fopen(string url, int mode, url_ready_func rdy, entity pass) // create a writing end that does nothing yet e = new_pure(url_single_fopen_file); e.url_url = strzone(url); + e.url_content_type = "text/plain"; + e.url_verb = ""; e.url_fh = URL_FH_CURL; e.url_wbuf = buf_create(); if (e.url_wbuf < 0) @@ -103,7 +107,7 @@ void url_single_fopen(string url, int mode, url_ready_func rdy, entity pass) LOG_INFO("url_single_fopen: out of memory in buf_create\n"); rdy(e, pass, URL_READY_ERROR); strunzone(e.url_url); - remove(e); + delete(e); return; } e.url_wbufpos = 0; @@ -225,19 +229,19 @@ void url_fclose(entity e) e.url_ready(e, e.url_ready_pass, URL_READY_ERROR); buf_del(e.url_wbuf); strunzone(e.url_url); - remove(e); + delete(e); return; } } // POST the data - if (!crypto_uri_postbuf(e.url_url, i + MIN_URL_ID, "text/plain", "", e.url_wbuf, 0)) + if (!crypto_uri_postbuf(e.url_url, i + MIN_URL_ID, e.url_content_type, e.url_verb, e.url_wbuf, 0)) { LOG_INFO("url_fclose: failure in crypto_uri_postbuf\n"); e.url_ready(e, e.url_ready_pass, URL_READY_ERROR); buf_del(e.url_wbuf); strunzone(e.url_url); - remove(e); + delete(e); return; } @@ -258,20 +262,20 @@ void url_fclose(entity e) e.url_ready(e, e.url_ready_pass, URL_READY_CLOSED); buf_del(e.url_rbuf); strunzone(e.url_url); - remove(e); + delete(e); } } else if (e.url_fh == URL_FH_STDOUT) { e.url_ready(e, e.url_ready_pass, URL_READY_CLOSED); // closing creates no reading handle - remove(e); + delete(e); } else { // file fclose(e.url_fh); e.url_ready(e, e.url_ready_pass, URL_READY_CLOSED); // closing creates no reading handle - remove(e); + delete(e); } } @@ -312,7 +316,7 @@ void url_fputs(entity e, string s) else if (e.url_fh == URL_FH_STDOUT) { // stdout - LOG_INFO(s); + print(s); } else { @@ -332,7 +336,7 @@ void url_multi_ready(entity fh, entity me, float status) LOG_INFO("uri_multi_ready: got HTTP error 422, data is in unusable format - not continuing\n"); me.url_ready(fh, me.url_ready_pass, status); strunzone(me.url_url); - remove(me); + delete(me); return; } me.url_attempt += 1; @@ -341,7 +345,7 @@ void url_multi_ready(entity fh, entity me, float status) { me.url_ready(fh, me.url_ready_pass, status); strunzone(me.url_url); - remove(me); + delete(me); return; } url_single_fopen(argv(me.url_attempt), me.url_mode, url_multi_ready, me);