14 #ifndef NETWORK_CORE_TCP_HTTP_H 15 #define NETWORK_CORE_TCP_HTTP_H 35 virtual void OnReceiveData(
const char *data,
size_t length) = 0;
44 char recv_buffer[4096];
62 return this->sock != INVALID_SOCKET;
68 const char *host,
const char *url,
const char *data,
int depth);
73 const char *data = NULL,
int depth = 0);
75 static void HTTPReceive();
96 const char *data = NULL,
int depth = 0) :
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.
virtual void OnFailure()
Callback for when the connection attempt failed.
NetworkHTTPContentConnecter(const NetworkAddress &address, HTTPCallback *callback, const char *url, const char *data=NULL, int depth=0)
Start the connecting.
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).
virtual void OnConnect(SOCKET s)
Callback when the connection succeeded.
~NetworkHTTPContentConnecter()
Free all our allocated data.
bool IsConnected() const
Whether this socket is currently bound to a socket.
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 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.