This module implements an HTTP client in a threaded mode.
What is threaded?
To avoid process blocking, this technique sends the request and wait for response in asynchronous way.
At each StartFrame of hlds server, it checks if there's some pending request and in that case it checks for data in buffer.
It's implemented using a free library HappyHTTP.
How to use it?
From the plugin, call the native: thttp_request
Wait for the forward to be called: thttp_response
Just that.
Example plugin:
Code:
#include <amxmodx>
#include <thttp>
public plugin_init()
{
register_concmd("httpget", "httpget")
}
public thttp_response(key[], data[], code, reason[])
{
log_amx("HTTP: key:%s code:%i reason:%s data:%s\n", key, code, reason, data);
}
public httpget(id)
{
thttp_request("thisisthekey", "www.google.com", "GET", "/search?q=alliedmods");
return PLUGIN_HANDLED
}
public xxx(id)
{
thttp_request("pepepe", "www.google.com", "GET", "/search?q=test");
return PLUGIN_HANDLED
}