]> git.lizzy.rs Git - dragonfireclient.git/blob - src/httpfetch.cpp
Remove dependency on marshal and many other async changes
[dragonfireclient.git] / src / httpfetch.cpp
1 /*
2 Minetest
3 Copyright (C) 2013 celeron55, Perttu Ahola <celeron55@gmail.com>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published by
7 the Free Software Foundation; either version 2.1 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License along
16 with this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19
20 #include "socket.h" // for select()
21 #include "porting.h" // for sleep_ms(), get_sysinfo()
22 #include "httpfetch.h"
23 #include <iostream>
24 #include <sstream>
25 #include <list>
26 #include <map>
27 #include <errno.h>
28 #include "jthread/jevent.h"
29 #include "config.h"
30 #include "exceptions.h"
31 #include "debug.h"
32 #include "log.h"
33 #include "util/container.h"
34 #include "util/thread.h"
35 #include "version.h"
36 #include "main.h"
37 #include "settings.h"
38
39 JMutex g_httpfetch_mutex;
40 std::map<unsigned long, std::list<HTTPFetchResult> > g_httpfetch_results;
41
42 HTTPFetchRequest::HTTPFetchRequest()
43 {
44         url = "";
45         caller = HTTPFETCH_DISCARD;
46         request_id = 0;
47         timeout = g_settings->getS32("curl_timeout");
48         connect_timeout = timeout;
49         
50         useragent = std::string("Minetest/") + minetest_version_hash + " (" + porting::get_sysinfo() + ")";
51 }
52
53
54 static void httpfetch_deliver_result(const HTTPFetchResult &fetchresult)
55 {
56         unsigned long caller = fetchresult.caller;
57         if (caller != HTTPFETCH_DISCARD) {
58                 JMutexAutoLock lock(g_httpfetch_mutex);
59                 g_httpfetch_results[caller].push_back(fetchresult);
60         }
61 }
62
63 static void httpfetch_request_clear(unsigned long caller);
64
65 unsigned long httpfetch_caller_alloc()
66 {
67         JMutexAutoLock lock(g_httpfetch_mutex);
68
69         // Check each caller ID except HTTPFETCH_DISCARD
70         const unsigned long discard = HTTPFETCH_DISCARD;
71         for (unsigned long caller = discard + 1; caller != discard; ++caller) {
72                 std::map<unsigned long, std::list<HTTPFetchResult> >::iterator
73                         it = g_httpfetch_results.find(caller);
74                 if (it == g_httpfetch_results.end()) {
75                         verbosestream<<"httpfetch_caller_alloc: allocating "
76                                         <<caller<<std::endl;
77                         // Access element to create it
78                         g_httpfetch_results[caller];
79                         return caller;
80                 }
81         }
82
83         assert("httpfetch_caller_alloc: ran out of caller IDs" == 0);
84         return discard;
85 }
86
87 void httpfetch_caller_free(unsigned long caller)
88 {
89         verbosestream<<"httpfetch_caller_free: freeing "
90                         <<caller<<std::endl;
91
92         httpfetch_request_clear(caller);
93         if (caller != HTTPFETCH_DISCARD) {
94                 JMutexAutoLock lock(g_httpfetch_mutex);
95                 g_httpfetch_results.erase(caller);
96         }
97 }
98
99 bool httpfetch_async_get(unsigned long caller, HTTPFetchResult &fetchresult)
100 {
101         JMutexAutoLock lock(g_httpfetch_mutex);
102
103         // Check that caller exists
104         std::map<unsigned long, std::list<HTTPFetchResult> >::iterator
105                 it = g_httpfetch_results.find(caller);
106         if (it == g_httpfetch_results.end())
107                 return false;
108
109         // Check that result queue is nonempty
110         std::list<HTTPFetchResult> &callerresults = it->second;
111         if (callerresults.empty())
112                 return false;
113
114         // Pop first result
115         fetchresult = callerresults.front();
116         callerresults.pop_front();
117         return true;
118 }
119
120 #if USE_CURL
121 #include <curl/curl.h>
122
123 /*
124         USE_CURL is on: use cURL based httpfetch implementation
125 */
126
127 static size_t httpfetch_writefunction(
128                 char *ptr, size_t size, size_t nmemb, void *userdata)
129 {
130         std::ostringstream *stream = (std::ostringstream*)userdata;
131         size_t count = size * nmemb;
132         stream->write(ptr, count);
133         return count;
134 }
135
136 static size_t httpfetch_discardfunction(
137                 char *ptr, size_t size, size_t nmemb, void *userdata)
138 {
139         return size * nmemb;
140 }
141
142 class CurlHandlePool
143 {
144         std::list<CURL*> handles;
145
146 public:
147         CurlHandlePool() {}
148         ~CurlHandlePool()
149         {
150                 for (std::list<CURL*>::iterator it = handles.begin();
151                                 it != handles.end(); ++it) {
152                         curl_easy_cleanup(*it);
153                 }
154         }
155         CURL * alloc()
156         {
157                 CURL *curl;
158                 if (handles.empty()) {
159                         curl = curl_easy_init();
160                         if (curl == NULL) {
161                                 errorstream<<"curl_easy_init returned NULL"<<std::endl;
162                         }
163                 }
164                 else {
165                         curl = handles.front();
166                         handles.pop_front();
167                 }
168                 return curl;
169         }
170         void free(CURL *handle)
171         {
172                 if (handle)
173                         handles.push_back(handle);
174         }
175 };
176
177 struct HTTPFetchOngoing
178 {
179         CurlHandlePool *pool;
180         CURL *curl;
181         CURLM *multi;
182         HTTPFetchRequest request;
183         HTTPFetchResult result;
184         std::ostringstream oss;
185         char *post_fields;
186         struct curl_slist *httpheader;
187
188         HTTPFetchOngoing(HTTPFetchRequest request_, CurlHandlePool *pool_):
189                 pool(pool_),
190                 curl(NULL),
191                 multi(NULL),
192                 request(request_),
193                 result(request_),
194                 oss(std::ios::binary),
195                 httpheader(NULL)
196         {
197                 curl = pool->alloc();
198                 if (curl != NULL) {
199                         // Set static cURL options
200                         curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1);
201                         curl_easy_setopt(curl, CURLOPT_FAILONERROR, 1);
202                         curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1);
203                         curl_easy_setopt(curl, CURLOPT_MAXREDIRS, 1);
204
205 #if LIBCURL_VERSION_NUM >= 0x071304
206                         // Restrict protocols so that curl vulnerabilities in
207                         // other protocols don't affect us.
208                         // These settings were introduced in curl 7.19.4.
209                         long protocols =
210                                 CURLPROTO_HTTP |
211                                 CURLPROTO_HTTPS |
212                                 CURLPROTO_FTP |
213                                 CURLPROTO_FTPS;
214                         curl_easy_setopt(curl, CURLOPT_PROTOCOLS, protocols);
215                         curl_easy_setopt(curl, CURLOPT_REDIR_PROTOCOLS, protocols);
216 #endif
217
218                         // Set cURL options based on HTTPFetchRequest
219                         curl_easy_setopt(curl, CURLOPT_URL,
220                                         request.url.c_str());
221                         curl_easy_setopt(curl, CURLOPT_TIMEOUT_MS,
222                                         request.timeout);
223                         curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT_MS,
224                                         request.connect_timeout);
225
226                         if (request.useragent != "")
227                                 curl_easy_setopt(curl, CURLOPT_USERAGENT, request.useragent.c_str());
228
229                         // Set up a write callback that writes to the
230                         // ostringstream ongoing->oss, unless the data
231                         // is to be discarded
232                         if (request.caller == HTTPFETCH_DISCARD) {
233                                 curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION,
234                                                 httpfetch_discardfunction);
235                                 curl_easy_setopt(curl, CURLOPT_WRITEDATA, NULL);
236                         }
237                         else {
238                                 curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION,
239                                                 httpfetch_writefunction);
240                                 curl_easy_setopt(curl, CURLOPT_WRITEDATA, &oss);
241                         }
242                         // Set POST (or GET) data
243                         if (request.post_fields.empty()) {
244                                 curl_easy_setopt(curl, CURLOPT_HTTPGET, 1);
245                         }
246                         else {
247                                 curl_easy_setopt(curl, CURLOPT_POST, 1);
248                                 curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE,
249                                                 request.post_fields.size());
250                                 curl_easy_setopt(curl, CURLOPT_POSTFIELDS,
251                                                 request.post_fields.c_str());
252                                 // request.post_fields must now *never* be
253                                 // modified until CURLOPT_POSTFIELDS is cleared
254                         }
255                         // Set additional HTTP headers
256                         for (size_t i = 0; i < request.extra_headers.size(); ++i) {
257                                 httpheader = curl_slist_append(
258                                         httpheader,
259                                         request.extra_headers[i].c_str());
260                         }
261                         curl_easy_setopt(curl, CURLOPT_HTTPHEADER, httpheader);
262                 }
263         }
264
265         CURLcode start(CURLM *multi_)
266         {
267                 if (curl == NULL)
268                         return CURLE_FAILED_INIT;
269
270                 if (multi_) {
271                         // Multi interface (async)
272                         CURLMcode mres = curl_multi_add_handle(multi_, curl);
273                         if (mres != CURLM_OK) {
274                                 errorstream<<"curl_multi_add_handle"
275                                         <<" returned error code "<<mres
276                                         <<std::endl;
277                                 return CURLE_FAILED_INIT;
278                         }
279                         multi = multi_; // store for curl_multi_remove_handle
280                         return CURLE_OK;
281                 }
282                 else {
283                         // Easy interface (sync)
284                         return curl_easy_perform(curl);
285                 }
286         }
287
288         void complete(CURLcode res)
289         {
290                 result.succeeded = (res == CURLE_OK);
291                 result.timeout = (res == CURLE_OPERATION_TIMEDOUT);
292                 result.data = oss.str();
293
294                 // Get HTTP/FTP response code
295                 result.response_code = 0;
296                 if (curl != NULL) {
297                         if (curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE,
298                                         &result.response_code) != CURLE_OK) {
299                                 //we failed to get a return code make sure it is still 0
300                                 result.response_code = 0;
301                         }
302                 }
303
304                 if (res != CURLE_OK) {
305                         infostream<<request.url<<" not found ("
306                                 <<curl_easy_strerror(res)<<")"
307                                 <<" (response code "<<result.response_code<<")"
308                                 <<std::endl;
309                 }
310         }
311
312         ~HTTPFetchOngoing()
313         {
314                 if (multi != NULL) {
315                         CURLMcode mres = curl_multi_remove_handle(multi, curl);
316                         if (mres != CURLM_OK) {
317                                 errorstream<<"curl_multi_remove_handle"
318                                         <<" returned error code "<<mres
319                                         <<std::endl;
320                         }
321                 }
322
323                 // Set safe options for the reusable cURL handle
324                 curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION,
325                                 httpfetch_discardfunction);
326                 curl_easy_setopt(curl, CURLOPT_WRITEDATA, NULL);
327                 curl_easy_setopt(curl, CURLOPT_POSTFIELDS, NULL);
328                 if (httpheader != NULL) {
329                         curl_easy_setopt(curl, CURLOPT_HTTPHEADER, NULL);
330                         curl_slist_free_all(httpheader);
331                 }
332
333                 // Store the cURL handle for reuse
334                 pool->free(curl);
335         }
336 };
337
338 class CurlFetchThread : public JThread
339 {
340 protected:
341         enum RequestType {
342                 RT_FETCH,
343                 RT_CLEAR,
344                 RT_WAKEUP,
345         };
346
347         struct Request {
348                 RequestType type;
349                 HTTPFetchRequest fetchrequest;
350                 Event *event;
351         };
352
353         CURLM *m_multi;
354         MutexedQueue<Request> m_requests;
355         size_t m_parallel_limit;
356
357         // Variables exclusively used within thread
358         std::vector<HTTPFetchOngoing*> m_all_ongoing;
359         std::list<HTTPFetchRequest> m_queued_fetches;
360
361 public:
362         CurlFetchThread(int parallel_limit)
363         {
364                 if (parallel_limit >= 1)
365                         m_parallel_limit = parallel_limit;
366                 else
367                         m_parallel_limit = 1;
368         }
369
370         void requestFetch(const HTTPFetchRequest &fetchrequest)
371         {
372                 Request req;
373                 req.type = RT_FETCH;
374                 req.fetchrequest = fetchrequest;
375                 req.event = NULL;
376                 m_requests.push_back(req);
377         }
378
379         void requestClear(unsigned long caller, Event *event)
380         {
381                 Request req;
382                 req.type = RT_CLEAR;
383                 req.fetchrequest.caller = caller;
384                 req.event = event;
385                 m_requests.push_back(req);
386         }
387
388         void requestWakeUp()
389         {
390                 Request req;
391                 req.type = RT_WAKEUP;
392                 req.event = NULL;
393                 m_requests.push_back(req);
394         }
395
396 protected:
397         // Handle a request from some other thread
398         // E.g. new fetch; clear fetches for one caller; wake up
399         void processRequest(const Request &req)
400         {
401                 if (req.type == RT_FETCH) {
402                         // New fetch, queue until there are less
403                         // than m_parallel_limit ongoing fetches
404                         m_queued_fetches.push_back(req.fetchrequest);
405
406                         // see processQueued() for what happens next
407
408                 }
409                 else if (req.type == RT_CLEAR) {
410                         unsigned long caller = req.fetchrequest.caller;
411
412                         // Abort all ongoing fetches for the caller
413                         for (std::vector<HTTPFetchOngoing*>::iterator
414                                         it = m_all_ongoing.begin();
415                                         it != m_all_ongoing.end();) {
416                                 if ((*it)->request.caller == caller) {
417                                         delete (*it);
418                                         it = m_all_ongoing.erase(it);
419                                 }
420                                 else
421                                         ++it;
422                         }
423
424                         // Also abort all queued fetches for the caller
425                         for (std::list<HTTPFetchRequest>::iterator
426                                         it = m_queued_fetches.begin();
427                                         it != m_queued_fetches.end();) {
428                                 if ((*it).caller == caller)
429                                         it = m_queued_fetches.erase(it);
430                                 else
431                                         ++it;
432                         }
433                 }
434                 else if (req.type == RT_WAKEUP) {
435                         // Wakeup: Nothing to do, thread is awake at this point
436                 }
437
438                 if (req.event != NULL)
439                         req.event->signal();
440         }
441
442         // Start new ongoing fetches if m_parallel_limit allows
443         void processQueued(CurlHandlePool *pool)
444         {
445                 while (m_all_ongoing.size() < m_parallel_limit &&
446                                 !m_queued_fetches.empty()) {
447                         HTTPFetchRequest request = m_queued_fetches.front();
448                         m_queued_fetches.pop_front();
449
450                         // Create ongoing fetch data and make a cURL handle
451                         // Set cURL options based on HTTPFetchRequest
452                         HTTPFetchOngoing *ongoing =
453                                 new HTTPFetchOngoing(request, pool);
454
455                         // Initiate the connection (curl_multi_add_handle)
456                         CURLcode res = ongoing->start(m_multi);
457                         if (res == CURLE_OK) {
458                                 m_all_ongoing.push_back(ongoing);
459                         }
460                         else {
461                                 ongoing->complete(res);
462                                 httpfetch_deliver_result(ongoing->result);
463                                 delete ongoing;
464                         }
465                 }
466         }
467
468         // Process CURLMsg (indicates completion of a fetch)
469         void processCurlMessage(CURLMsg *msg)
470         {
471                 // Determine which ongoing fetch the message pertains to
472                 size_t i = 0;
473                 bool found = false;
474                 for (i = 0; i < m_all_ongoing.size(); ++i) {
475                         if (m_all_ongoing[i]->curl == msg->easy_handle) {
476                                 found = true;
477                                 break;
478                         }
479                 }
480                 if (msg->msg == CURLMSG_DONE && found) {
481                         // m_all_ongoing[i] succeeded or failed.
482                         HTTPFetchOngoing *ongoing = m_all_ongoing[i];
483                         ongoing->complete(msg->data.result);
484                         httpfetch_deliver_result(ongoing->result);
485                         delete ongoing;
486                         m_all_ongoing.erase(m_all_ongoing.begin() + i);
487                 }
488         }
489
490         // Wait for a request from another thread, or timeout elapses
491         void waitForRequest(long timeout)
492         {
493                 if (m_queued_fetches.empty()) {
494                         try {
495                                 Request req = m_requests.pop_front(timeout);
496                                 processRequest(req);
497                         }
498                         catch (ItemNotFoundException &e) {}
499                 }
500         }
501
502         // Wait until some IO happens, or timeout elapses
503         void waitForIO(long timeout)
504         {
505                 fd_set read_fd_set;
506                 fd_set write_fd_set;
507                 fd_set exc_fd_set;
508                 int max_fd;
509                 long select_timeout = -1;
510                 struct timeval select_tv;
511                 CURLMcode mres;
512
513                 FD_ZERO(&read_fd_set);
514                 FD_ZERO(&write_fd_set);
515                 FD_ZERO(&exc_fd_set);
516
517                 mres = curl_multi_fdset(m_multi, &read_fd_set,
518                                 &write_fd_set, &exc_fd_set, &max_fd);
519                 if (mres != CURLM_OK) {
520                         errorstream<<"curl_multi_fdset"
521                                 <<" returned error code "<<mres
522                                 <<std::endl;
523                         select_timeout = 0;
524                 }
525
526                 mres = curl_multi_timeout(m_multi, &select_timeout);
527                 if (mres != CURLM_OK) {
528                         errorstream<<"curl_multi_timeout"
529                                 <<" returned error code "<<mres
530                                 <<std::endl;
531                         select_timeout = 0;
532                 }
533
534                 // Limit timeout so new requests get through
535                 if (select_timeout < 0 || select_timeout > timeout)
536                         select_timeout = timeout;
537
538                 if (select_timeout > 0) {
539                         // in Winsock it is forbidden to pass three empty
540                         // fd_sets to select(), so in that case use sleep_ms
541                         if (max_fd != -1) {
542                                 select_tv.tv_sec = select_timeout / 1000;
543                                 select_tv.tv_usec = (select_timeout % 1000) * 1000;
544                                 int retval = select(max_fd + 1, &read_fd_set,
545                                                 &write_fd_set, &exc_fd_set,
546                                                 &select_tv);
547                                 if (retval == -1) {
548                                         #ifdef _WIN32
549                                         errorstream<<"select returned error code "
550                                                 <<WSAGetLastError()<<std::endl;
551                                         #else
552                                         errorstream<<"select returned error code "
553                                                 <<errno<<std::endl;
554                                         #endif
555                                 }
556                         }
557                         else {
558                                 sleep_ms(select_timeout);
559                         }
560                 }
561         }
562
563         void * Thread()
564         {
565                 ThreadStarted();
566                 log_register_thread("CurlFetchThread");
567                 DSTACK(__FUNCTION_NAME);
568
569                 porting::setThreadName("CurlFetchThread");
570
571                 CurlHandlePool pool;
572
573                 m_multi = curl_multi_init();
574                 if (m_multi == NULL) {
575                         errorstream<<"curl_multi_init returned NULL\n";
576                         return NULL;
577                 }
578
579                 assert(m_all_ongoing.empty());
580
581                 while (!StopRequested()) {
582                         BEGIN_DEBUG_EXCEPTION_HANDLER
583
584                         /*
585                                 Handle new async requests
586                         */
587
588                         while (!m_requests.empty()) {
589                                 Request req = m_requests.pop_frontNoEx();
590                                 processRequest(req);
591                         }
592                         processQueued(&pool);
593
594                         /*
595                                 Handle ongoing async requests
596                         */
597
598                         int still_ongoing = 0;
599                         while (curl_multi_perform(m_multi, &still_ongoing) ==
600                                         CURLM_CALL_MULTI_PERFORM)
601                                 /* noop */;
602
603                         /*
604                                 Handle completed async requests
605                         */
606                         if (still_ongoing < (int) m_all_ongoing.size()) {
607                                 CURLMsg *msg;
608                                 int msgs_in_queue;
609                                 msg = curl_multi_info_read(m_multi, &msgs_in_queue);
610                                 while (msg != NULL) {
611                                         processCurlMessage(msg);
612                                         msg = curl_multi_info_read(m_multi, &msgs_in_queue);
613                                 }
614                         }
615
616                         /*
617                                 If there are ongoing requests, wait for data
618                                 (with a timeout of 100ms so that new requests
619                                 can be processed).
620
621                                 If no ongoing requests, wait for a new request.
622                                 (Possibly an empty request that signals
623                                 that the thread should be stopped.)
624                         */
625                         if (m_all_ongoing.empty())
626                                 waitForRequest(100000000);
627                         else
628                                 waitForIO(100);
629
630                         END_DEBUG_EXCEPTION_HANDLER(errorstream)
631                 }
632
633                 // Call curl_multi_remove_handle and cleanup easy handles
634                 for (size_t i = 0; i < m_all_ongoing.size(); ++i) {
635                         delete m_all_ongoing[i];
636                 }
637                 m_all_ongoing.clear();
638
639                 m_queued_fetches.clear();
640
641                 CURLMcode mres = curl_multi_cleanup(m_multi);
642                 if (mres != CURLM_OK) {
643                         errorstream<<"curl_multi_cleanup"
644                                 <<" returned error code "<<mres
645                                 <<std::endl;
646                 }
647
648                 return NULL;
649         }
650 };
651
652 CurlFetchThread *g_httpfetch_thread = NULL;
653
654 void httpfetch_init(int parallel_limit)
655 {
656         verbosestream<<"httpfetch_init: parallel_limit="<<parallel_limit
657                         <<std::endl;
658
659         CURLcode res = curl_global_init(CURL_GLOBAL_DEFAULT);
660         assert(res == CURLE_OK);
661
662         g_httpfetch_thread = new CurlFetchThread(parallel_limit);
663 }
664
665 void httpfetch_cleanup()
666 {
667         verbosestream<<"httpfetch_cleanup: cleaning up"<<std::endl;
668
669         g_httpfetch_thread->Stop();
670         g_httpfetch_thread->requestWakeUp();
671         g_httpfetch_thread->Wait();
672         delete g_httpfetch_thread;
673
674         curl_global_cleanup();
675 }
676
677 void httpfetch_async(const HTTPFetchRequest &fetchrequest)
678 {
679         g_httpfetch_thread->requestFetch(fetchrequest);
680         if (!g_httpfetch_thread->IsRunning())
681                 g_httpfetch_thread->Start();
682 }
683
684 static void httpfetch_request_clear(unsigned long caller)
685 {
686         if (g_httpfetch_thread->IsRunning()) {
687                 Event event;
688                 g_httpfetch_thread->requestClear(caller, &event);
689                 event.wait();
690         }
691         else {
692                 g_httpfetch_thread->requestClear(caller, NULL);
693         }
694 }
695
696 void httpfetch_sync(const HTTPFetchRequest &fetchrequest,
697                 HTTPFetchResult &fetchresult)
698 {
699         // Create ongoing fetch data and make a cURL handle
700         // Set cURL options based on HTTPFetchRequest
701         CurlHandlePool pool;
702         HTTPFetchOngoing ongoing(fetchrequest, &pool);
703         // Do the fetch (curl_easy_perform)
704         CURLcode res = ongoing.start(NULL);
705         // Update fetchresult
706         ongoing.complete(res);
707         fetchresult = ongoing.result;
708 }
709
710 #else  // USE_CURL
711
712 /*
713         USE_CURL is off:
714
715         Dummy httpfetch implementation that always returns an error.
716 */
717
718 void httpfetch_init(int parallel_limit)
719 {
720 }
721
722 void httpfetch_cleanup()
723 {
724 }
725
726 void httpfetch_async(const HTTPFetchRequest &fetchrequest)
727 {
728         errorstream<<"httpfetch_async: unable to fetch "<<fetchrequest.url
729                         <<" because USE_CURL=0"<<std::endl;
730
731         HTTPFetchResult fetchresult(fetchrequest); // sets succeeded = false etc.
732         httpfetch_deliver_result(fetchresult);
733 }
734
735 static void httpfetch_request_clear(unsigned long caller)
736 {
737 }
738
739 void httpfetch_sync(const HTTPFetchRequest &fetchrequest,
740                 HTTPFetchResult &fetchresult)
741 {
742         errorstream<<"httpfetch_sync: unable to fetch "<<fetchrequest.url
743                         <<" because USE_CURL=0"<<std::endl;
744
745         fetchresult = HTTPFetchResult(fetchrequest); // sets succeeded = false etc.
746 }
747
748 #endif  // USE_CURL