Minetest  5.4.0
httpfetch.cpp File Reference
#include "httpfetch.h"
#include "porting.h"
#include <iostream>
#include <sstream>
#include <list>
#include <map>
#include <cerrno>
#include <mutex>
#include "network/socket.h"
#include "threading/event.h"
#include "config.h"
#include "exceptions.h"
#include "debug.h"
#include "log.h"
#include "util/container.h"
#include "util/thread.h"
#include "version.h"
#include "settings.h"
#include "noise.h"
#include <curl/curl.h>
+ Include dependency graph for httpfetch.cpp:

Classes

class  CurlHandlePool
 
class  HTTPFetchOngoing
 
class  CurlFetchThread
 
struct  CurlFetchThread::Request
 

Functions

static void httpfetch_deliver_result (const HTTPFetchResult &fetch_result)
 
static void httpfetch_request_clear (unsigned long caller)
 
unsigned long httpfetch_caller_alloc ()
 
unsigned long httpfetch_caller_alloc_secure ()
 
void httpfetch_caller_free (unsigned long caller)
 
bool httpfetch_async_get (unsigned long caller, HTTPFetchResult &fetch_result)
 
static size_t httpfetch_writefunction (char *ptr, size_t size, size_t nmemb, void *userdata)
 
static size_t httpfetch_discardfunction (char *ptr, size_t size, size_t nmemb, void *userdata)
 
void httpfetch_init (int parallel_limit)
 
void httpfetch_cleanup ()
 
void httpfetch_async (const HTTPFetchRequest &fetch_request)
 
void httpfetch_sync (const HTTPFetchRequest &fetch_request, HTTPFetchResult &fetch_result)
 

Variables

std::mutex g_httpfetch_mutex
 
std::map< unsigned long, std::queue< HTTPFetchResult > > g_httpfetch_results
 
PcgRandom g_callerid_randomness
 
CurlFetchThreadg_httpfetch_thread = NULL
 

Function Documentation

◆ httpfetch_async()

void httpfetch_async ( const HTTPFetchRequest fetch_request)

References g_httpfetch_thread, Thread::isRunning(), CurlFetchThread::requestFetch(), and Thread::start().

Referenced by ClientMediaDownloader::initialStep(), ModApiHttp::l_http_fetch_async(), ServerList::sendAnnounce(), and ClientMediaDownloader::startRemoteMediaTransfers().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ httpfetch_async_get()

bool httpfetch_async_get ( unsigned long  caller,
HTTPFetchResult fetch_result 
)

References g_httpfetch_mutex, and g_httpfetch_results.

Referenced by ModApiHttp::l_http_fetch_async_get(), and ClientMediaDownloader::step().

+ Here is the caller graph for this function:

◆ httpfetch_caller_alloc()

unsigned long httpfetch_caller_alloc ( )

References FATAL_ERROR, g_httpfetch_mutex, g_httpfetch_results, HTTPFETCH_DISCARD, and verbosestream.

Referenced by ClientMediaDownloader::initialStep().

+ Here is the caller graph for this function:

◆ httpfetch_caller_alloc_secure()

unsigned long httpfetch_caller_alloc_secure ( )

References FATAL_ERROR, g_callerid_randomness, g_httpfetch_mutex, g_httpfetch_results, HTTPFETCH_DISCARD, PcgRandom::next(), and verbosestream.

Referenced by ModApiHttp::read_http_fetch_request().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ httpfetch_caller_free()

void httpfetch_caller_free ( unsigned long  caller)

References g_httpfetch_mutex, g_httpfetch_results, HTTPFETCH_DISCARD, httpfetch_request_clear(), and verbosestream.

Referenced by ClientMediaDownloader::~ClientMediaDownloader().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ httpfetch_cleanup()

void httpfetch_cleanup ( )

References g_httpfetch_thread, CurlFetchThread::requestWakeUp(), Thread::stop(), verbosestream, and Thread::wait().

Referenced by main().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ httpfetch_deliver_result()

static void httpfetch_deliver_result ( const HTTPFetchResult fetch_result)
static

References HTTPFetchResult::caller, g_httpfetch_mutex, g_httpfetch_results, and HTTPFETCH_DISCARD.

Referenced by CurlFetchThread::processCurlMessage(), and CurlFetchThread::processQueued().

+ Here is the caller graph for this function:

◆ httpfetch_discardfunction()

static size_t httpfetch_discardfunction ( char *  ptr,
size_t  size,
size_t  nmemb,
void *  userdata 
)
static

Referenced by HTTPFetchOngoing::HTTPFetchOngoing(), and HTTPFetchOngoing::~HTTPFetchOngoing().

+ Here is the caller graph for this function:

◆ httpfetch_init()

void httpfetch_init ( int  parallel_limit)

References FATAL_ERROR_IF, g_callerid_randomness, g_httpfetch_thread, porting::secure_rand_fill_buf(), and verbosestream.

Referenced by init_common().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ httpfetch_request_clear()

static void httpfetch_request_clear ( unsigned long  caller)
static

References g_httpfetch_thread, Thread::isRunning(), and CurlFetchThread::requestClear().

Referenced by httpfetch_caller_free().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ httpfetch_sync()

void httpfetch_sync ( const HTTPFetchRequest fetch_request,
HTTPFetchResult fetch_result 
)

References HTTPFetchOngoing::complete(), and HTTPFetchOngoing::start().

Referenced by GUIEngine::downloadFile(), fetchJsonValue(), and ModApiHttp::l_http_fetch_sync().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ httpfetch_writefunction()

static size_t httpfetch_writefunction ( char *  ptr,
size_t  size,
size_t  nmemb,
void *  userdata 
)
static

Referenced by HTTPFetchOngoing::HTTPFetchOngoing().

+ Here is the caller graph for this function:

Variable Documentation

◆ g_callerid_randomness

PcgRandom g_callerid_randomness

◆ g_httpfetch_mutex

◆ g_httpfetch_results

◆ g_httpfetch_thread