Commit 673796fb authored by Deomid Ryabkov's avatar Deomid Ryabkov Committed by rojer

Improve HTTP erro reporting (send reason)

A few tweaks to TI example
Clean up mbuf_insert code a bit

PUBLISHED_FROM=00ed7aff05d6b760e10c7f14a503eccfc9a284bd
parent 482ab33c
...@@ -3,11 +3,10 @@ ...@@ -3,11 +3,10 @@
* All rights reserved * All rights reserved
*/ */
#include <malloc.h>
#include <stdbool.h> #include <stdbool.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h>
#include <string.h> #include <string.h>
#include <unistd.h>
/* Driverlib includes */ /* Driverlib includes */
#include "hw_types.h" #include "hw_types.h"
...@@ -29,7 +28,7 @@ ...@@ -29,7 +28,7 @@
#include "simplelink.h" #include "simplelink.h"
#include "device.h" #include "device.h"
#include "oslib/osi.h" #include "osi.h"
#include "mongoose.h" #include "mongoose.h"
...@@ -44,6 +43,7 @@ ...@@ -44,6 +43,7 @@
#define CONSOLE_UART UARTA0_BASE #define CONSOLE_UART UARTA0_BASE
#define CONSOLE_UART_PERIPH PRCM_UARTA0 #define CONSOLE_UART_PERIPH PRCM_UARTA0
#define SYS_CLK 80000000 #define SYS_CLK 80000000
#define MG_TASK_STACK_SIZE 8192
#define BM222_ADDR 0x18 #define BM222_ADDR 0x18
#define TMP006_ADDR 0x41 #define TMP006_ADDR 0x41
...@@ -72,7 +72,7 @@ void SimpleLinkNetAppEventHandler(SlNetAppEvent_t *e) { ...@@ -72,7 +72,7 @@ void SimpleLinkNetAppEventHandler(SlNetAppEvent_t *e) {
LOG(LL_INFO, ("IP: %lu.%lu.%lu.%lu", SL_IPV4_BYTE(ed->ip, 3), LOG(LL_INFO, ("IP: %lu.%lu.%lu.%lu", SL_IPV4_BYTE(ed->ip, 3),
SL_IPV4_BYTE(ed->ip, 2), SL_IPV4_BYTE(ed->ip, 1), SL_IPV4_BYTE(ed->ip, 2), SL_IPV4_BYTE(ed->ip, 1),
SL_IPV4_BYTE(ed->ip, 0))); SL_IPV4_BYTE(ed->ip, 0)));
GPIO_IF_LedOff(MCU_RED_LED_GPIO); GPIO_IF_LedToggle(MCU_RED_LED_GPIO);
} }
} }
...@@ -86,7 +86,7 @@ struct temp_data { ...@@ -86,7 +86,7 @@ struct temp_data {
static struct temp_data s_temp_data; static struct temp_data s_temp_data;
static void ev_handler(struct mg_connection *nc, int ev, void *p) { static void mg_ev_handler(struct mg_connection *nc, int ev, void *p) {
LOG(LL_DEBUG, ("Ev: %d", ev)); LOG(LL_DEBUG, ("Ev: %d", ev));
switch (ev) { switch (ev) {
case MG_EV_ACCEPT: { case MG_EV_ACCEPT: {
...@@ -282,7 +282,8 @@ static void data_ev_handler(struct mg_connection *nc, int ev, void *ev_data) { ...@@ -282,7 +282,8 @@ static void data_ev_handler(struct mg_connection *nc, int ev, void *ev_data) {
} }
static void mg_task(void *arg) { static void mg_task(void *arg) {
LOG(LL_INFO, ("Hello, world!")); LOG(LL_INFO, ("MG task running"));
GPIO_IF_LedToggle(MCU_RED_LED_GPIO);
osi_MsgQCreate(&s_v7_q, "V7", sizeof(struct sj_event), 32 /* len */); osi_MsgQCreate(&s_v7_q, "V7", sizeof(struct sj_event), 32 /* len */);
...@@ -329,7 +330,7 @@ static void mg_task(void *arg) { ...@@ -329,7 +330,7 @@ static void mg_task(void *arg) {
memset(&opts, 0, sizeof(opts)); memset(&opts, 0, sizeof(opts));
opts.error_string = &err; opts.error_string = &err;
struct mg_connection *nc = mg_bind(&mg_mgr, "80", ev_handler); struct mg_connection *nc = mg_bind(&mg_mgr, "80", mg_ev_handler);
if (nc != NULL) { if (nc != NULL) {
mg_set_protocol_http_websocket(nc); mg_set_protocol_http_websocket(nc);
nc->ev_timer_time = mg_time(); /* Start data collection */ nc->ev_timer_time = mg_time(); /* Start data collection */
...@@ -344,11 +345,15 @@ static void mg_task(void *arg) { ...@@ -344,11 +345,15 @@ static void mg_task(void *arg) {
} }
} }
#ifndef USE_TIRTOS
/* Int vector table, defined in startup_gcc.c */ /* Int vector table, defined in startup_gcc.c */
extern void (*const g_pfnVectors[])(void); extern void (*const g_pfnVectors[])(void);
#endif
int main() { int main() {
#ifndef USE_TIRTOS
MAP_IntVTableBaseSet((unsigned long) &g_pfnVectors[0]); MAP_IntVTableBaseSet((unsigned long) &g_pfnVectors[0]);
#endif
MAP_IntEnable(FAULT_SYSTICK); MAP_IntEnable(FAULT_SYSTICK);
MAP_IntMasterEnable(); MAP_IntMasterEnable();
PRCMCC3200MCUInit(); PRCMCC3200MCUInit();
...@@ -364,10 +369,11 @@ int main() { ...@@ -364,10 +369,11 @@ int main() {
MAP_UARTFIFOLevelSet(CONSOLE_UART, UART_FIFO_TX1_8, UART_FIFO_RX4_8); MAP_UARTFIFOLevelSet(CONSOLE_UART, UART_FIFO_TX1_8, UART_FIFO_RX4_8);
MAP_UARTFIFOEnable(CONSOLE_UART); MAP_UARTFIFOEnable(CONSOLE_UART);
setvbuf(stdout, NULL, _IONBF, 0); setvbuf(stdout, NULL, _IOLBF, 0);
setvbuf(stderr, NULL, _IONBF, 0); setvbuf(stderr, NULL, _IOLBF, 0);
cs_log_set_file(stdout);
cs_log_set_level(LL_INFO); cs_log_set_level(LL_INFO);
cs_log_set_file(stdout);
LOG(LL_INFO, ("Hello, world!"));
MAP_PinTypeI2C(PIN_01, PIN_MODE_1); /* SDA */ MAP_PinTypeI2C(PIN_01, PIN_MODE_1); /* SDA */
MAP_PinTypeI2C(PIN_02, PIN_MODE_1); /* SCL */ MAP_PinTypeI2C(PIN_02, PIN_MODE_1); /* SCL */
...@@ -379,10 +385,15 @@ int main() { ...@@ -379,10 +385,15 @@ int main() {
MAP_PinTypeGPIO(PIN_64, PIN_MODE_0, false); MAP_PinTypeGPIO(PIN_64, PIN_MODE_0, false);
MAP_GPIODirModeSet(GPIOA1_BASE, 0x2, GPIO_DIR_MODE_OUT); MAP_GPIODirModeSet(GPIOA1_BASE, 0x2, GPIO_DIR_MODE_OUT);
GPIO_IF_LedConfigure(LED1); GPIO_IF_LedConfigure(LED1);
GPIO_IF_LedOn(MCU_RED_LED_GPIO); GPIO_IF_LedToggle(MCU_RED_LED_GPIO);
if (VStartSimpleLinkSpawnTask(8) != 0) {
LOG(LL_ERROR, ("Failed to create SL task"));
}
if (osi_TaskCreate(mg_task, (const signed char *) "mg", MG_TASK_STACK_SIZE, NULL, 3, NULL) != 0) {
LOG(LL_ERROR, ("Failed to create MG task"));
}
VStartSimpleLinkSpawnTask(8);
osi_TaskCreate(mg_task, (const signed char *) "mg", 8192, NULL, 3, NULL);
osi_start(); osi_start();
return 0; return 0;
......
...@@ -1472,19 +1472,18 @@ size_t mbuf_insert(struct mbuf *a, size_t off, const void *buf, size_t len) { ...@@ -1472,19 +1472,18 @@ size_t mbuf_insert(struct mbuf *a, size_t off, const void *buf, size_t len) {
memcpy(a->buf + off, buf, len); memcpy(a->buf + off, buf, len);
} }
a->len += len; a->len += len;
} else if ((p = (char *) MBUF_REALLOC( } else {
a->buf, (size_t)((a->len + len) * MBUF_SIZE_MULTIPLIER))) != size_t new_size = (a->len + len) * MBUF_SIZE_MULTIPLIER;
NULL) { if ((p = (char *) MBUF_REALLOC(a->buf, new_size)) != NULL) {
a->buf = p; a->buf = p;
memmove(a->buf + off + len, a->buf + off, a->len - off); memmove(a->buf + off + len, a->buf + off, a->len - off);
if (buf != NULL) { if (buf != NULL) memcpy(a->buf + off, buf, len);
memcpy(a->buf + off, buf, len);
}
a->len += len; a->len += len;
a->size = (size_t)(a->len * MBUF_SIZE_MULTIPLIER); a->size = new_size;
} else { } else {
len = 0; len = 0;
} }
}
return len; return len;
} }
...@@ -3158,7 +3157,6 @@ void mg_if_tcp_send(struct mg_connection *nc, const void *buf, size_t len) { ...@@ -3158,7 +3157,6 @@ void mg_if_tcp_send(struct mg_connection *nc, const void *buf, size_t len) {
} }
void mg_if_udp_send(struct mg_connection *nc, const void *buf, size_t len) { void mg_if_udp_send(struct mg_connection *nc, const void *buf, size_t len) {
DBG(("%p %d %d", nc, (int) len, (int) nc->send_mbuf.len));
mbuf_append(&nc->send_mbuf, buf, len); mbuf_append(&nc->send_mbuf, buf, len);
} }
...@@ -5601,6 +5599,9 @@ void mg_send_response_line(struct mg_connection *nc, int status_code, ...@@ -5601,6 +5599,9 @@ void mg_send_response_line(struct mg_connection *nc, int status_code,
case 418: case 418:
status_message = "I'm a teapot"; status_message = "I'm a teapot";
break; break;
case 500:
status_message = "Internal Server Error";
break;
} }
mg_printf(nc, "HTTP/1.1 %d %s\r\n", status_code, status_message); mg_printf(nc, "HTTP/1.1 %d %s\r\n", status_code, status_message);
if (extra_headers != NULL) { if (extra_headers != NULL) {
...@@ -5625,10 +5626,14 @@ void mg_serve_http(struct mg_connection *nc, struct http_message *hm, ...@@ -5625,10 +5626,14 @@ void mg_serve_http(struct mg_connection *nc, struct http_message *hm,
mg_send_head(nc, 501, 0, NULL); mg_send_head(nc, 501, 0, NULL);
} }
#else #else
static void mg_http_send_http_error(struct mg_connection *nc, int code, static void mg_http_send_error(struct mg_connection *nc, int code,
const char *reason) { const char *reason) {
(void) reason; if (!reason) reason = "";
mg_send_head(nc, code, 0, NULL); DBG(("%p %d %s", nc, code, reason));
mg_send_head(nc, code, strlen(reason),
"Content-Type: text/plain\r\nConnection: close");
mg_send(nc, reason, strlen(reason));
nc->flags |= MG_F_SEND_AND_CLOSE;
} }
#ifndef MG_DISABLE_SSI #ifndef MG_DISABLE_SSI
static void mg_send_ssi_file(struct mg_connection *, const char *, FILE *, int, static void mg_send_ssi_file(struct mg_connection *, const char *, FILE *, int,
...@@ -5791,7 +5796,7 @@ static void mg_handle_ssi_request(struct mg_connection *nc, const char *path, ...@@ -5791,7 +5796,7 @@ static void mg_handle_ssi_request(struct mg_connection *nc, const char *path,
struct mg_str mime_type; struct mg_str mime_type;
if ((fp = fopen(path, "rb")) == NULL) { if ((fp = fopen(path, "rb")) == NULL) {
mg_http_send_http_error(nc, 404, NULL); mg_http_send_error(nc, 404, NULL);
} else { } else {
mg_set_close_on_exec(fileno(fp)); mg_set_close_on_exec(fileno(fp));
...@@ -5811,7 +5816,7 @@ static void mg_handle_ssi_request(struct mg_connection *nc, const char *path, ...@@ -5811,7 +5816,7 @@ static void mg_handle_ssi_request(struct mg_connection *nc, const char *path,
const struct mg_serve_http_opts *opts) { const struct mg_serve_http_opts *opts) {
(void) path; (void) path;
(void) opts; (void) opts;
mg_http_send_http_error(nc, 500, "SSI disabled"); mg_http_send_error(nc, 500, "SSI disabled");
} }
#endif /* MG_DISABLE_SSI */ #endif /* MG_DISABLE_SSI */
...@@ -5860,7 +5865,7 @@ static void mg_http_send_file2(struct mg_connection *nc, const char *path, ...@@ -5860,7 +5865,7 @@ static void mg_http_send_file2(struct mg_connection *nc, const char *path,
default: default:
code = 500; code = 500;
}; };
mg_http_send_http_error(nc, code, "Open failed"); mg_http_send_error(nc, code, "Open failed");
} else if (mg_match_prefix(opts->ssi_pattern, strlen(opts->ssi_pattern), } else if (mg_match_prefix(opts->ssi_pattern, strlen(opts->ssi_pattern),
path) > 0) { path) > 0) {
mg_handle_ssi_request(nc, path, opts); mg_handle_ssi_request(nc, path, opts);
...@@ -6503,7 +6508,7 @@ static void mg_handle_mkcol(struct mg_connection *nc, const char *path, ...@@ -6503,7 +6508,7 @@ static void mg_handle_mkcol(struct mg_connection *nc, const char *path,
} else { } else {
status_code = 500; status_code = 500;
} }
mg_http_send_http_error(nc, status_code, NULL); mg_http_send_error(nc, status_code, NULL);
} }
static int mg_remove_directory(const struct mg_serve_http_opts *opts, static int mg_remove_directory(const struct mg_serve_http_opts *opts,
...@@ -6538,7 +6543,7 @@ static void mg_handle_move(struct mg_connection *c, ...@@ -6538,7 +6543,7 @@ static void mg_handle_move(struct mg_connection *c,
const char *path, struct http_message *hm) { const char *path, struct http_message *hm) {
const struct mg_str *dest = mg_get_http_header(hm, "Destination"); const struct mg_str *dest = mg_get_http_header(hm, "Destination");
if (dest == NULL) { if (dest == NULL) {
mg_http_send_http_error(c, 411, NULL); mg_http_send_error(c, 411, NULL);
} else { } else {
const char *p = (char *) memchr(dest->p, '/', dest->len); const char *p = (char *) memchr(dest->p, '/', dest->len);
if (p != NULL && p[1] == '/' && if (p != NULL && p[1] == '/' &&
...@@ -6547,12 +6552,12 @@ static void mg_handle_move(struct mg_connection *c, ...@@ -6547,12 +6552,12 @@ static void mg_handle_move(struct mg_connection *c,
snprintf(buf, sizeof(buf), "%s%.*s", opts->dav_document_root, snprintf(buf, sizeof(buf), "%s%.*s", opts->dav_document_root,
(int) (dest->p + dest->len - p), p); (int) (dest->p + dest->len - p), p);
if (rename(path, buf) == 0) { if (rename(path, buf) == 0) {
mg_http_send_http_error(c, 200, NULL); mg_http_send_error(c, 200, NULL);
} else { } else {
mg_http_send_http_error(c, 418, NULL); mg_http_send_error(c, 418, NULL);
} }
} else { } else {
mg_http_send_http_error(c, 500, NULL); mg_http_send_error(c, 500, NULL);
} }
} }
} }
...@@ -6562,14 +6567,14 @@ static void mg_handle_delete(struct mg_connection *nc, ...@@ -6562,14 +6567,14 @@ static void mg_handle_delete(struct mg_connection *nc,
const char *path) { const char *path) {
cs_stat_t st; cs_stat_t st;
if (mg_stat(path, &st) != 0) { if (mg_stat(path, &st) != 0) {
mg_http_send_http_error(nc, 404, NULL); mg_http_send_error(nc, 404, NULL);
} else if (S_ISDIR(st.st_mode)) { } else if (S_ISDIR(st.st_mode)) {
mg_remove_directory(opts, path); mg_remove_directory(opts, path);
mg_http_send_http_error(nc, 204, NULL); mg_http_send_error(nc, 204, NULL);
} else if (remove(path) == 0) { } else if (remove(path) == 0) {
mg_http_send_http_error(nc, 204, NULL); mg_http_send_error(nc, 204, NULL);
} else { } else {
mg_http_send_http_error(nc, 423, NULL); mg_http_send_error(nc, 423, NULL);
} }
} }
...@@ -6604,11 +6609,11 @@ static void mg_handle_put(struct mg_connection *nc, const char *path, ...@@ -6604,11 +6609,11 @@ static void mg_handle_put(struct mg_connection *nc, const char *path,
if ((rc = mg_create_itermediate_directories(path)) == 0) { if ((rc = mg_create_itermediate_directories(path)) == 0) {
mg_printf(nc, "HTTP/1.1 %d OK\r\nContent-Length: 0\r\n\r\n", status_code); mg_printf(nc, "HTTP/1.1 %d OK\r\nContent-Length: 0\r\n\r\n", status_code);
} else if (rc == -1) { } else if (rc == -1) {
mg_http_send_http_error(nc, 500, NULL); mg_http_send_error(nc, 500, NULL);
} else if (cl_hdr == NULL) { } else if (cl_hdr == NULL) {
mg_http_send_http_error(nc, 411, NULL); mg_http_send_error(nc, 411, NULL);
} else if ((pd->file.fp = fopen(path, "w+b")) == NULL) { } else if ((pd->file.fp = fopen(path, "w+b")) == NULL) {
mg_http_send_http_error(nc, 500, NULL); mg_http_send_error(nc, 500, NULL);
} else { } else {
const struct mg_str *range_hdr = mg_get_http_header(hm, "Content-Range"); const struct mg_str *range_hdr = mg_get_http_header(hm, "Content-Range");
int64_t r1 = 0, r2 = 0; int64_t r1 = 0, r2 = 0;
...@@ -7224,7 +7229,7 @@ static void mg_cgi_ev_handler(struct mg_connection *cgi_nc, int ev, ...@@ -7224,7 +7229,7 @@ static void mg_cgi_ev_handler(struct mg_connection *cgi_nc, int ev,
if (len == 0) break; if (len == 0) break;
if (len < 0 || io->len > MG_MAX_HTTP_REQUEST_SIZE) { if (len < 0 || io->len > MG_MAX_HTTP_REQUEST_SIZE) {
cgi_nc->flags |= MG_F_CLOSE_IMMEDIATELY; cgi_nc->flags |= MG_F_CLOSE_IMMEDIATELY;
mg_http_send_http_error(nc, 500, "Bad headers"); mg_http_send_error(nc, 500, "Bad headers");
} else { } else {
struct http_message hm; struct http_message hm;
struct mg_str *h; struct mg_str *h;
...@@ -7298,7 +7303,7 @@ static void mg_handle_cgi(struct mg_connection *nc, const char *prog, ...@@ -7298,7 +7303,7 @@ static void mg_handle_cgi(struct mg_connection *nc, const char *prog,
mbuf_remove(&nc->recv_mbuf, nc->recv_mbuf.len); mbuf_remove(&nc->recv_mbuf, nc->recv_mbuf.len);
} else { } else {
closesocket(fds[0]); closesocket(fds[0]);
mg_http_send_http_error(nc, 500, "CGI failure"); mg_http_send_error(nc, 500, "CGI failure");
} }
#ifndef _WIN32 #ifndef _WIN32
...@@ -7419,13 +7424,13 @@ MG_INTERNAL void mg_send_http_file(struct mg_connection *nc, char *path, ...@@ -7419,13 +7424,13 @@ MG_INTERNAL void mg_send_http_file(struct mg_connection *nc, char *path,
/* If we have path_info, the only way to handle it is CGI. */ /* If we have path_info, the only way to handle it is CGI. */
if (path_info->len > 0 && !is_cgi) { if (path_info->len > 0 && !is_cgi) {
mg_http_send_http_error(nc, 501, NULL); mg_http_send_error(nc, 501, NULL);
MG_FREE(index_file); MG_FREE(index_file);
return; return;
} }
if (is_dav && opts->dav_document_root == NULL) { if (is_dav && opts->dav_document_root == NULL) {
mg_http_send_http_error(nc, 501, NULL); mg_http_send_error(nc, 501, NULL);
} else if (!mg_is_authorized(hm, path, is_directory, opts->auth_domain, } else if (!mg_is_authorized(hm, path, is_directory, opts->auth_domain,
opts->global_auth_file, 1) || opts->global_auth_file, 1) ||
!mg_is_authorized(hm, path, is_directory, opts->auth_domain, !mg_is_authorized(hm, path, is_directory, opts->auth_domain,
...@@ -7435,12 +7440,12 @@ MG_INTERNAL void mg_send_http_file(struct mg_connection *nc, char *path, ...@@ -7435,12 +7440,12 @@ MG_INTERNAL void mg_send_http_file(struct mg_connection *nc, char *path,
#if !defined(MG_DISABLE_CGI) #if !defined(MG_DISABLE_CGI)
mg_handle_cgi(nc, index_file ? index_file : path, path_info, hm, opts); mg_handle_cgi(nc, index_file ? index_file : path, path_info, hm, opts);
#else #else
mg_http_send_http_error(nc, 501, NULL); mg_http_send_error(nc, 501, NULL);
#endif /* MG_DISABLE_CGI */ #endif /* MG_DISABLE_CGI */
} else if ((!exists || } else if ((!exists ||
mg_is_file_hidden(path, opts, 0 /* specials are ok */)) && mg_is_file_hidden(path, opts, 0 /* specials are ok */)) &&
!mg_is_creation_request(hm)) { !mg_is_creation_request(hm)) {
mg_http_send_http_error(nc, 404, NULL); mg_http_send_error(nc, 404, NULL);
#ifndef MG_DISABLE_DAV #ifndef MG_DISABLE_DAV
} else if (!mg_vcmp(&hm->method, "PROPFIND")) { } else if (!mg_vcmp(&hm->method, "PROPFIND")) {
mg_handle_propfind(nc, path, &st, hm, opts); mg_handle_propfind(nc, path, &st, hm, opts);
...@@ -7472,13 +7477,13 @@ MG_INTERNAL void mg_send_http_file(struct mg_connection *nc, char *path, ...@@ -7472,13 +7477,13 @@ MG_INTERNAL void mg_send_http_file(struct mg_connection *nc, char *path,
if (strcmp(opts->enable_directory_listing, "yes") == 0) { if (strcmp(opts->enable_directory_listing, "yes") == 0) {
mg_send_directory_listing(nc, path, hm, opts); mg_send_directory_listing(nc, path, hm, opts);
} else { } else {
mg_http_send_http_error(nc, 403, NULL); mg_http_send_error(nc, 403, NULL);
} }
#else #else
mg_http_send_http_error(nc, 501, NULL); mg_http_send_error(nc, 501, NULL);
#endif #endif
} else if (mg_is_not_modified(hm, &st)) { } else if (mg_is_not_modified(hm, &st)) {
mg_http_send_http_error(nc, 304, "Not Modified"); mg_http_send_error(nc, 304, "Not Modified");
} else { } else {
mg_http_send_file2(nc, index_file ? index_file : path, &st, hm, opts); mg_http_send_file2(nc, index_file ? index_file : path, &st, hm, opts);
} }
...@@ -7493,7 +7498,7 @@ void mg_serve_http(struct mg_connection *nc, struct http_message *hm, ...@@ -7493,7 +7498,7 @@ void mg_serve_http(struct mg_connection *nc, struct http_message *hm,
if (mg_check_ip_acl(opts.ip_acl, remote_ip) != 1) { if (mg_check_ip_acl(opts.ip_acl, remote_ip) != 1) {
/* Not allowed to connect */ /* Not allowed to connect */
mg_http_send_http_error(nc, 403, NULL); mg_http_send_error(nc, 403, NULL);
nc->flags |= MG_F_SEND_AND_CLOSE; nc->flags |= MG_F_SEND_AND_CLOSE;
return; return;
} }
...@@ -7522,11 +7527,11 @@ void mg_serve_http(struct mg_connection *nc, struct http_message *hm, ...@@ -7522,11 +7527,11 @@ void mg_serve_http(struct mg_connection *nc, struct http_message *hm,
} }
/* Normalize path - resolve "." and ".." (in-place). */ /* Normalize path - resolve "." and ".." (in-place). */
if (!mg_normalize_uri_path(&hm->uri, &hm->uri)) { if (!mg_normalize_uri_path(&hm->uri, &hm->uri)) {
mg_http_send_http_error(nc, 400, NULL); mg_http_send_error(nc, 400, NULL);
return; return;
} }
if (mg_uri_to_local_path(hm, &opts, &path, &path_info) == 0) { if (mg_uri_to_local_path(hm, &opts, &path, &path_info) == 0) {
mg_http_send_http_error(nc, 404, NULL); mg_http_send_error(nc, 404, NULL);
return; return;
} }
mg_send_http_file(nc, path, &path_info, hm, &opts); mg_send_http_file(nc, path, &path_info, hm, &opts);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment