Put and Post are now functional
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -467,6 +467,22 @@ void restd_http_response(struct evhttp_request *req, int code, const char *conte
|
||||
evhttp_send_reply(req, code, NULL ,resp_buf);
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
char *restd_http_get_body(struct evhttp_request *req)
|
||||
{
|
||||
char *body = NULL;
|
||||
struct evbuffer *buf;
|
||||
|
||||
buf = evhttp_request_get_input_buffer(req);
|
||||
size_t len = evbuffer_get_length(buf);
|
||||
|
||||
body = malloc(len +1 );
|
||||
int ret = evbuffer_copyout(buf, body, len);
|
||||
body[len] = '\0';
|
||||
|
||||
return body;
|
||||
}
|
||||
|
||||
/*--------------------------- LOCAL FUNCTIONS -------------------------------*/
|
||||
|
||||
@@ -657,6 +673,7 @@ void rest_request_cb(struct evhttp_request *req, void *arg)
|
||||
const char *cmdtype;
|
||||
restd_server_t *server = (restd_server_t *)arg;
|
||||
|
||||
#if 0
|
||||
printf("request.\n");
|
||||
switch (evhttp_request_get_command(req))
|
||||
{
|
||||
@@ -694,6 +711,7 @@ void rest_request_cb(struct evhttp_request *req, void *arg)
|
||||
|
||||
printf("Received a %s request for %s\nHeaders:\n",
|
||||
cmdtype, evhttp_request_get_uri(req));
|
||||
#endif
|
||||
|
||||
qlist_t *hooks = server->hooks;
|
||||
//int reason = RESTD_ERROR_PATH_NOT_FOUND;
|
||||
@@ -705,12 +723,12 @@ void rest_request_cb(struct evhttp_request *req, void *arg)
|
||||
if (hook->cb)
|
||||
{
|
||||
const char *request_path = evhttp_request_get_uri(req);
|
||||
printf("==== call_hooks: method: %d - %d \n", hook->method, evhttp_request_get_command(req));
|
||||
printf("==== call_hooks: path: %s - %s\n", hook->path, request_path);
|
||||
printf("==== HOOK FOUND !!!!\n");
|
||||
//printf("==== call_hooks: method: %d - %d \n", hook->method, evhttp_request_get_command(req));
|
||||
//printf("==== call_hooks: path: %s - %s\n", hook->path, request_path);
|
||||
//printf("==== HOOK FOUND !!!!\n");
|
||||
if (hook->method != evhttp_request_get_command(req))
|
||||
{
|
||||
printf("==== Hook found but method failed -> next.\n");
|
||||
//printf("==== Hook found but method failed -> next.\n");
|
||||
//reason = RESTD_ERROR_METHOD_NOT_ALLOWED;
|
||||
continue;
|
||||
}
|
||||
@@ -747,7 +765,7 @@ void rest_request_cb(struct evhttp_request *req, void *arg)
|
||||
}
|
||||
}
|
||||
|
||||
evhttp_send_reply(req, 200, "OK", NULL);
|
||||
evhttp_send_reply(req, 500, "Internal Error", NULL);
|
||||
}
|
||||
#if 0
|
||||
int restd_rest_handler(short event, restd_conn_t *conn)
|
||||
|
||||
@@ -58,7 +58,7 @@ extern void restd_server_register_hook_on_path(restd_server_t *server, enum evht
|
||||
restd_callback cb, void *userdata);
|
||||
|
||||
extern void restd_http_response(struct evhttp_request *req, int code, const char *contenttype, const char *data);
|
||||
|
||||
extern char *restd_http_get_body(struct evhttp_request *req);
|
||||
|
||||
/*------------------------------- DEFINES ------------------------------------*/
|
||||
|
||||
|
||||
Reference in New Issue
Block a user