12 #ifndef NETWORK_CORE_TCP_HTTP_H 13 #define NETWORK_CORE_TCP_HTTP_H 31 virtual void OnReceiveData(
const char *data,
size_t length) = 0;
40 char recv_buffer[4096];
58 return this->sock != INVALID_SOCKET;
64 const char *host,
const char *url,
const char *data,
int depth);
69 const char *data =
nullptr,
int depth = 0);
71 static void HTTPReceive();
92 const char *data =
nullptr,
int depth = 0) :
117 this->data =
nullptr;
Connect with a HTTP server and do ONE query.
SOCKET sock
The socket currently connected to.
"Helper" class for creating TCP connections in a non-blocking manner
virtual ~HTTPCallback()
Silentium.
Wrapper for (un)resolved network addresses; there's no reason to transform a numeric IP to a string a...
int redirect_depth
The depth of the redirection.
const char * url
The URL we want to get at the server.
virtual void OnReceiveData(const char *data, size_t length)=0
We're receiving data.
const char * data
The data to send.
int recv_pos
Current position in buffer.
virtual void OnFailure()=0
An error has occurred and the connection has been closed.
char * stredup(const char *s, const char *last)
Create a duplicate of the given string.
NetworkRecvStatus
Status of a network client; reasons why a client has quit.
const char * data
The (POST) data we might want to forward (to a redirect).
~NetworkHTTPContentConnecter()
Free all our allocated data.
bool IsConnected() const
Whether this socket is currently bound to a socket.
void OnConnect(SOCKET s) override
Callback when the connection succeeded.
HTTPCallback * callback
Callback to tell that we received some data (or won't).
Base socket handler for HTTP traffic.
int depth
How far we have recursed.
void OnFailure() override
Callback for when the connection attempt failed.
void CDECL error(const char *s,...)
Error handling for fatal non-user errors.
Callback for when the HTTP handler has something to tell us.
static void free(const void *ptr)
Version of the standard free that accepts const pointers.
HTTPCallback * callback
The callback to call for the incoming data.
int recv_length
Length of the data still retrieving.
Basic functions to receive and send TCP packets.
SocketHandler for all network sockets in OpenTTD.
NetworkHTTPContentConnecter(const NetworkAddress &address, HTTPCallback *callback, const char *url, const char *data=nullptr, int depth=0)
Start the connecting.