OpenTTD Source: src/network/core/http.h Source File

OpenTTD Source 15.0-RC2

http.h
Go to the documentation of this file.
1/*
2 * This file is part of OpenTTD.
3 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
4 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <https://www.gnu.org/licenses/old-licenses/gpl-2.0>.
6 */
7
12#ifndef NETWORK_CORE_HTTP_H
13#define NETWORK_CORE_HTTP_H
14
15#include "tcp.h"
16
17constexpr int HTTP_429_TOO_MANY_REQUESTS = 429;
18
20 struct HTTPCallback {
25 virtual void OnFailure() = 0;
26
33 virtual void OnReceiveData(std::unique_ptr<char[]> data, size_t length) = 0;
34
42 virtual bool IsCancelled() const = 0;
43
45 virtual ~HTTPCallback() = default;
46};
47
49 class NetworkHTTPSocketHandler {
50public:
58 static void Connect(std::string_view uri, HTTPCallback *callback, std::string &&data = "");
59
63 static void HTTPReceive();
64};
65
69void NetworkHTTPInitialize();
70
74void NetworkHTTPUninitialize();
75
76#endif /* NETWORK_CORE_HTTP_H */
NetworkHTTPSocketHandler
Base socket handler for HTTP traffic.
Definition http.h:49
NetworkHTTPSocketHandler::Connect
static void Connect(std::string_view uri, HTTPCallback *callback, std::string &&data="")
Connect to the given URI.
Definition http_curl.cpp:93
NetworkHTTPSocketHandler::HTTPReceive
static void HTTPReceive()
Do the receiving for all HTTP connections.
Definition http_curl.cpp:107
NetworkHTTPInitialize
void NetworkHTTPInitialize()
Initialize the HTTP socket handler.
Definition http_curl.cpp:250
NetworkHTTPUninitialize
void NetworkHTTPUninitialize()
Uninitialize the HTTP socket handler.
Definition http_curl.cpp:285
HTTPCallback
Callback for when the HTTP handler has something to tell us.
Definition http.h:20
HTTPCallback::IsCancelled
virtual bool IsCancelled() const =0
Check if there is a request to cancel the transfer.
HTTPCallback::~HTTPCallback
virtual ~HTTPCallback()=default
Silentium.
HTTPCallback::OnFailure
virtual void OnFailure()=0
An error has occurred and the connection has been closed.
HTTPCallback::OnReceiveData
virtual void OnReceiveData(std::unique_ptr< char[]> data, size_t length)=0
We're receiving data.
tcp.h
Basic functions to receive and send TCP packets.