OpenTTD Source
12.0-beta2
|
Go to the documentation of this file.
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;
58 return this->sock != INVALID_SOCKET;
64 const std::string &host,
const char *url,
const char *
data,
int depth);
69 const char *
data =
nullptr,
int depth = 0);
117 this->data =
nullptr;
bool IsConnected() const
Whether this socket is currently bound to a socket.
Base socket handler for HTTP traffic.
HTTPCallback * callback
The callback to call for the incoming data.
Callback for when the HTTP handler has something to tell us.
"Helper" class for creating TCP connections in a non-blocking manner
SocketHandler for all network sockets in OpenTTD.
const char * data
The (POST) data we might want to forward (to a redirect).
virtual void OnReceiveData(const char *data, size_t length)=0
We're receiving data.
const char * url
The URL we want to get at the server.
const char * data
The data to send.
~NetworkHTTPSocketHandler()
Free whatever needs to be freed.
Connect with a HTTP server and do ONE query.
NetworkHTTPSocketHandler(SOCKET sock, HTTPCallback *callback, const std::string &host, const char *url, const char *data, int depth)
Start the querying.
HTTPCallback * callback
Callback to tell that we received some data (or won't).
int redirect_depth
The depth of the redirection.
int recv_pos
Current position in buffer.
char recv_buffer[4096]
Partially received message.
void CloseSocket()
Close the actual socket of the connection.
void OnConnect(SOCKET s) override
Callback when the connection succeeded.
std::string hostname
Hostname we are connecting to.
virtual void OnFailure()=0
An error has occurred and the connection has been closed.
static int Connect(char *uri, HTTPCallback *callback, const char *data=nullptr, int depth=0)
Connect to the given URI.
int Receive()
Handle receiving of HTTP data.
virtual ~HTTPCallback()
Silentium.
static void HTTPReceive()
Do the receiving for all HTTP connections.
char * stredup(const char *s, const char *last)
Create a duplicate of the given string.
int depth
How far we have recursed.
~NetworkHTTPContentConnecter()
Free all our allocated data.
int recv_length
Length of the data still retrieving.
void OnFailure() override
Callback for when the connection attempt failed.
static void free(const void *ptr)
Version of the standard free that accepts const pointers.
SOCKET sock
The socket currently connected to.
NetworkHTTPContentConnecter(const std::string &hostname, HTTPCallback *callback, const char *url, const char *data=nullptr, int depth=0)
Start the connecting.
int HandleHeader()
Handle the header of a HTTP reply.