1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
#include <stdio.h>
#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;i<headers->nheaders;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);
}
|