OpenTTD Source 20241224-master-gf74b0cf984
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 <http://www.gnu.org/licenses/>.
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
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
50public:
58 static void Connect(const std::string &uri, HTTPCallback *callback, const std::string data = "");
59
63 static void HTTPReceive();
64};
65
70
75
76#endif /* NETWORK_CORE_HTTP_H */
Base socket handler for HTTP traffic.
Definition http.h:49
static void Connect(const std::string &uri, HTTPCallback *callback, const std::string data="")
Connect to the given URI.
Definition http_curl.cpp:93
static void HTTPReceive()
Do the receiving for all HTTP connections.
void NetworkHTTPInitialize()
Initialize the HTTP socket handler.
void NetworkHTTPUninitialize()
Uninitialize the HTTP socket handler.
Callback for when the HTTP handler has something to tell us.
Definition http.h:20
virtual bool IsCancelled() const =0
Check if there is a request to cancel the transfer.
virtual ~HTTPCallback()=default
Silentium.
virtual void OnFailure()=0
An error has occurred and the connection has been closed.
virtual void OnReceiveData(std::unique_ptr< char[]> data, size_t length)=0
We're receiving data.
Basic functions to receive and send TCP packets.