I'm wondering who would be interested in having a HTTP(S) server available from within plugins. I have a fairly simple proof of concept one done now, but if there is interest I can finish the coding for it and release it..
The extension is really just a wrapper around
shttpd
Examples of what I have so far:
Simple fastdownload server
Code:
#include <shttpd>
#include <sourcemod>
new Handle:server;
public OnPluginStart()
{
server = shttpd_init("8888");
shttpd_set_option(server,"root","/data/srcds/cstrike/addons/webroot"); shttpd_set_option(server,"aliases","/maps=/data/srcds/cstrike/maps/,/sounds=/data/srcds/cstrike/sounds");
}
public OnGameFrame()
{
shttpd_poll(server);
}
Simple "Hello World" website:
Code:
#include <shttpd>
#include <sourcemod>
public myhandler(Handle:test)
{
shttpd_printf(test,"Hello world");
}
new Handle:server;
public OnPluginStart()
{
server = shttpd_init("8888");
shttpd_register_url(server,"/gaben",myhandler);
}
public OnGameFrame()
{
shttpd_poll(server);
}
Simple PHP server (Note that this is not really recommended.. just more amusing to see that I could do it)
Code:
#include <shttpd>
#include <sourcemod>
new Handle:server;
public OnPluginStart()
{
server = shttpd_init("9999");
shttpd_set_option(server,"root","/data/srcds/cstrike/addons/webroot");
shttpd_set_option(server,"cgi_ext","php");
shttpd_set_option(server,"cgi_interp","/usr/bin/php-cgi");
shttpd_set_option(server,"mime_types",".php=text/html");
}
public OnGameFrame()
{
shttpd_poll(server);
}
Notes: If it's released, shttpd_poll will be automatically called. I plan on restricting it to ports above 1024 (To go lower would require srcds to run as root, which is not the smartest idea).
__________________