From ed2b3a38ec05c566c645dc2aabfd513edff8d63b Mon Sep 17 00:00:00 2001 From: tomsmeding Date: Sun, 25 Dec 2016 22:55:21 +0100 Subject: Plugins --- plugins/echoback/echoback.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 plugins/echoback/echoback.c (limited to 'plugins/echoback') diff --git a/plugins/echoback/echoback.c b/plugins/echoback/echoback.c new file mode 100644 index 0000000..af94cbf --- /dev/null +++ b/plugins/echoback/echoback.c @@ -0,0 +1,25 @@ +#include +#include "plugin.h" +#include "util.h" + + +static Handler_ret_t connection_handler(int sock,Headers *headers){ + sendall(sock,"HTTP/1.1 200 OK\r\n" + "Content-Type: text/plain; charset=UTF-8\r\n" + "Server: cserver\r\n" + "\r\n",-1); + + sendallf(sock,"Method: %s\n",headers->method); + sendallf(sock,"URL: %s\n",headers->url); + sendallf(sock,"Version: %s\n",headers->version); + sendall(sock,"\n",1); + for(int i=0;inheaders;i++){ + sendallf(sock,"Header '%s': '%s'\n",headers->headers[i][0],headers->headers[i][1]); + } + + return HR_HANDLED; +} + +void plugin_register_yourself(register_callback_t callback){ + callback("echoback",&connection_handler); +} -- cgit v1.2.3-70-g09d2