OCT 1. 修正DHCP 接口重复注册问题

2. 修复uv__strndup调用找不到函数问题
This commit is contained in:
huangxin 2022-11-10 17:48:30 +08:00
parent e34c25a0e3
commit 94f4af9d2d
3 changed files with 12 additions and 9 deletions

View File

@ -101,7 +101,7 @@ IndentCaseBlocks: false
IndentGotoLabels: true
IndentPPDirectives: None
IndentExternBlock: AfterExternBlock
IndentRequires: false
IndentRequiresClause: false
IndentWidth: 4
IndentWrappedFunctionNames: false
InsertTrailingCommas: None

View File

@ -12,8 +12,6 @@
#include "route_compare_method.h"
#include "misc.h"
extern char *uv__strndup(const char *s, size_t n);
#define CRLF "\r\n"
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
@ -41,8 +39,8 @@ void hw_print_request_headers(http_request *request) {
khash_t(hw_string_hashmap) *h = request->headers;
kh_foreach(h, k, v, {
char *key = uv__strndup(k->value, k->length + 1);
char *value = uv__strndup(v->value, v->length + 1);
char *key = strndup(k->value, k->length + 1);
char *value = strndup(v->value, v->length + 1);
printf("KEY: %s VALUE: %s\n", key, value);
free(key);
free(value);
@ -51,7 +49,7 @@ void hw_print_request_headers(http_request *request) {
void hw_print_body(http_request *request) {
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);
free(body);
} else {

View File

@ -377,7 +377,12 @@ static void opendhcp_http_get_alluser(http_request *request, hw_http_response *r
}
void opendhcp_init_http_server() {
hw_http_add_route("/", opendhcp_http_info, nullptr);
hw_http_add_route("getuser", opendhcp_http_get_userinfo, nullptr);
hw_http_add_route("allusers", opendhcp_http_get_alluser, nullptr);
static int added = FALSE;
if (!added) {
hw_http_add_route("/", opendhcp_http_info, nullptr);
hw_http_add_route("getuser", opendhcp_http_get_userinfo, nullptr);
hw_http_add_route("allusers", opendhcp_http_get_alluser, nullptr);
added = TRUE;
}
}