parent
e34c25a0e3
commit
94f4af9d2d
|
@ -101,7 +101,7 @@ IndentCaseBlocks: false
|
||||||
IndentGotoLabels: true
|
IndentGotoLabels: true
|
||||||
IndentPPDirectives: None
|
IndentPPDirectives: None
|
||||||
IndentExternBlock: AfterExternBlock
|
IndentExternBlock: AfterExternBlock
|
||||||
IndentRequires: false
|
IndentRequiresClause: false
|
||||||
IndentWidth: 4
|
IndentWidth: 4
|
||||||
IndentWrappedFunctionNames: false
|
IndentWrappedFunctionNames: false
|
||||||
InsertTrailingCommas: None
|
InsertTrailingCommas: None
|
||||||
|
|
|
@ -12,8 +12,6 @@
|
||||||
#include "route_compare_method.h"
|
#include "route_compare_method.h"
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
|
|
||||||
extern char *uv__strndup(const char *s, size_t n);
|
|
||||||
|
|
||||||
#define CRLF "\r\n"
|
#define CRLF "\r\n"
|
||||||
static const char response_404[] = "HTTP/1.1 404 Not Found" CRLF "Server: Haywire/master" CRLF
|
static const char response_404[] = "HTTP/1.1 404 Not Found" CRLF "Server: Haywire/master" CRLF
|
||||||
"Date: Fri, 26 Aug 2011 00:31:53 GMT" CRLF "Connection: Keep-Alive" CRLF
|
"Date: Fri, 26 Aug 2011 00:31:53 GMT" CRLF "Connection: Keep-Alive" CRLF
|
||||||
|
@ -41,8 +39,8 @@ void hw_print_request_headers(http_request *request) {
|
||||||
|
|
||||||
khash_t(hw_string_hashmap) *h = request->headers;
|
khash_t(hw_string_hashmap) *h = request->headers;
|
||||||
kh_foreach(h, k, v, {
|
kh_foreach(h, k, v, {
|
||||||
char *key = uv__strndup(k->value, k->length + 1);
|
char *key = strndup(k->value, k->length + 1);
|
||||||
char *value = uv__strndup(v->value, v->length + 1);
|
char *value = strndup(v->value, v->length + 1);
|
||||||
printf("KEY: %s VALUE: %s\n", key, value);
|
printf("KEY: %s VALUE: %s\n", key, value);
|
||||||
free(key);
|
free(key);
|
||||||
free(value);
|
free(value);
|
||||||
|
@ -51,7 +49,7 @@ void hw_print_request_headers(http_request *request) {
|
||||||
|
|
||||||
void hw_print_body(http_request *request) {
|
void hw_print_body(http_request *request) {
|
||||||
if (request->body->length > 0) {
|
if (request->body->length > 0) {
|
||||||
char *body = uv__strndup(request->body->value, request->body->length);
|
char *body = strndup(request->body->value, request->body->length);
|
||||||
printf("BODY: %s\n", body);
|
printf("BODY: %s\n", body);
|
||||||
free(body);
|
free(body);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -377,7 +377,12 @@ static void opendhcp_http_get_alluser(http_request *request, hw_http_response *r
|
||||||
}
|
}
|
||||||
|
|
||||||
void opendhcp_init_http_server() {
|
void opendhcp_init_http_server() {
|
||||||
|
static int added = FALSE;
|
||||||
|
|
||||||
|
if (!added) {
|
||||||
hw_http_add_route("/", opendhcp_http_info, nullptr);
|
hw_http_add_route("/", opendhcp_http_info, nullptr);
|
||||||
hw_http_add_route("getuser", opendhcp_http_get_userinfo, nullptr);
|
hw_http_add_route("getuser", opendhcp_http_get_userinfo, nullptr);
|
||||||
hw_http_add_route("allusers", opendhcp_http_get_alluser, nullptr);
|
hw_http_add_route("allusers", opendhcp_http_get_alluser, nullptr);
|
||||||
|
added = TRUE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue