|
OpenTTD Source 20260311-master-g511d3794ce
|
CURL-based implementation for HTTP requests. More...
#include "../../stdafx.h"#include "../../debug.h"#include "../../fileio_func.h"#include "../../rev.h"#include "../../thread.h"#include "../network_internal.h"#include "http.h"#include "http_shared.h"#include <atomic>#include <condition_variable>#include <curl/curl.h>#include <mutex>#include <queue>#include "../../safeguards.h"Go to the source code of this file.
Data Structures | |
| class | NetworkHTTPRequest |
| Single HTTP request. More... | |
Functions | |
| void | CurlSetOption (CURL *curl, auto option, auto value) |
| Set some specific option and emit debug information upon failure. | |
| void | HttpThread () |
| Thread entry point for the HTTP request thread. | |
| void | NetworkHTTPInitialize () |
| Initialize the HTTP socket handler. | |
| void | NetworkHTTPUninitialize () |
| Uninitialize the HTTP socket handler. | |
Variables | |
| static std::vector< HTTPThreadSafeCallback * > | _http_callbacks |
| Callback for the current requests. | |
| static std::vector< HTTPThreadSafeCallback * > | _new_http_callbacks |
| Callbacks for the request that should be started. | |
| static std::mutex | _http_callback_mutex |
| Mutex to prevent concurrent access to _http_callbacks. | |
| static std::mutex | _new_http_callback_mutex |
| Mutex to prevent concurrent access to _new_http_callbacks. | |
| static std::thread | _http_thread |
| The thread running the HTTP requests. | |
| static std::atomic< bool > | _http_thread_exit = false |
| Whether to ask the HTTP request thread to stop. | |
| static std::queue< std::unique_ptr< NetworkHTTPRequest > > | _http_requests |
| HTTP requests that are currently running. | |
| static std::mutex | _http_mutex |
| Mutex to prevent concurrent access _http_requests. | |
| static std::condition_variable | _http_cv |
| Conditional variable to wake up the HTTP request thread. | |
CURL-based implementation for HTTP requests.
Definition in file http_curl.cpp.
| void CurlSetOption | ( | CURL * | curl, |
| auto | option, | ||
| auto | value ) |
Set some specific option and emit debug information upon failure.
| curl | The curl instance we're using. |
| option | The option to set. |
| value | The value for the option. |
Definition at line 131 of file http_curl.cpp.
References Debug.
Referenced by HttpThread().
| void HttpThread | ( | ) |
Thread entry point for the HTTP request thread.
Definition at line 140 of file http_curl.cpp.
References _http_cv, _http_mutex, _http_requests, _http_thread_exit, HTTPThreadSafeCallback::cancelled, CurlSetOption(), Debug, GetNetworkRevisionString(), HTTP_429_TOO_MANY_REQUESTS, lock, and HTTPThreadSafeCallback::OnReceiveData().
Referenced by NetworkHTTPInitialize().
| void NetworkHTTPInitialize | ( | ) |
Initialize the HTTP socket handler.
Definition at line 257 of file http_curl.cpp.
| void NetworkHTTPUninitialize | ( | ) |
Uninitialize the HTTP socket handler.
Definition at line 292 of file http_curl.cpp.
|
static |
Mutex to prevent concurrent access to _http_callbacks.
Definition at line 48 of file http_curl.cpp.
Referenced by NetworkHTTPSocketHandler::HTTPReceive().
|
static |
Callback for the current requests.
Definition at line 46 of file http_curl.cpp.
Referenced by NetworkHTTPSocketHandler::HTTPReceive().
|
static |
Conditional variable to wake up the HTTP request thread.
Definition at line 86 of file http_curl.cpp.
Referenced by NetworkHTTPSocketHandler::Connect(), HttpThread(), and NetworkHTTPUninitialize().
|
static |
Mutex to prevent concurrent access _http_requests.
Definition at line 85 of file http_curl.cpp.
Referenced by NetworkHTTPSocketHandler::Connect(), HttpThread(), and NetworkHTTPUninitialize().
|
static |
HTTP requests that are currently running.
Definition at line 84 of file http_curl.cpp.
Referenced by NetworkHTTPSocketHandler::Connect(), and HttpThread().
|
static |
The thread running the HTTP requests.
Definition at line 82 of file http_curl.cpp.
Referenced by NetworkHTTPInitialize(), and NetworkHTTPUninitialize().
|
static |
Whether to ask the HTTP request thread to stop.
Definition at line 83 of file http_curl.cpp.
Referenced by HttpThread(), NetworkHTTPInitialize(), and NetworkHTTPUninitialize().
|
static |
Mutex to prevent concurrent access to _new_http_callbacks.
Definition at line 49 of file http_curl.cpp.
Referenced by NetworkHTTPSocketHandler::HTTPReceive().
|
static |
Callbacks for the request that should be started.
Definition at line 47 of file http_curl.cpp.
Referenced by NetworkHTTPSocketHandler::HTTPReceive().