From bc7918b4798e0dccf9812bf00801fdf7af5a46f3 Mon Sep 17 00:00:00 2001 From: zogodo <742782908@qq.com> Date: Wed, 19 Feb 2020 21:00:58 +0800 Subject: [PATCH] =?UTF-8?q?=E8=8E=B7=E5=8F=96=20jquery=20=E5=92=8C=20angul?= =?UTF-8?q?ar?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- TC1/http_server/app_httpd.c | 27 ++++-- TC1/http_server/app_httpd.h | 1 + TC1/http_server/index.html | 2 + TC1/http_server/jquery.min.html | 4 + TC1/http_server/test.html | 166 -------------------------------- TC1/http_server/web_data.c | 6 +- 6 files changed, 31 insertions(+), 175 deletions(-) create mode 100644 TC1/http_server/jquery.min.html delete mode 100644 TC1/http_server/test.html diff --git a/TC1/http_server/app_httpd.c b/TC1/http_server/app_httpd.c index 496b534..545c3b4 100644 --- a/TC1/http_server/app_httpd.c +++ b/TC1/http_server/app_httpd.c @@ -103,14 +103,28 @@ exit: return err; } -static int HttpGetTestPage(httpd_request_t *req) +static int HttpGetJs(httpd_request_t *req) { OSStatus err = kNoErr; - int total_sz = sizeof(test_html); - err = httpd_send_all_header(req, HTTP_RES_200, total_sz, HTTP_CONTENT_HTML_ZIP); + char* js_name = strstr(req->filename, "?name="); + http_log("HttpDelTask url[%s] js_name[%s]", req->filename, js_name); + + int total_sz = sizeof(jquery_min_html); + const unsigned char* js_data = jquery_min_html; + if (strcmp(js_name + 6, "angular") == 0) + { + total_sz = sizeof(angular_min_html); + js_data = angular_min_html; + } + + err = httpd_send_all_header(req, HTTP_RES_200, total_sz, HTTP_CONTENT_JS_ZIP); require_noerr_action(err, exit, http_log("ERROR: Unable to send http testpage headers.")); + err = httpd_send_body(req->sock, js_data, total_sz); + require_noerr_action(err, exit, http_log("ERROR: Unable to send http wifisetting body.")); + + /* int i = 0; int chunk_sz = 1000; for (; i < total_sz; i += chunk_sz) @@ -119,12 +133,13 @@ static int HttpGetTestPage(httpd_request_t *req) { chunk_sz = total_sz - i; } - err = httpd_send_chunk(req->sock, (const char*)(test_html + i), chunk_sz); + err = httpd_send_chunk(req->sock, (const char*)(angular_min_html + i), chunk_sz); require_noerr_action(err, exit, http_log("ERROR: Unable to send http testpage body. i[%d] chunk_sz[%d] total_sz[%d]", i, chunk_sz, total_sz)); } err = httpd_send_chunk(req->sock, NULL, 0); require_noerr_action(err, exit, http_log("ERROR: Unable to send http testpage end.")); http_log("httpd_send_chunk total_sz[%d] i[%d]", total_sz, i); + */ exit: return err; @@ -373,7 +388,7 @@ exit: struct httpd_wsgi_call g_app_handlers[] = { { "/", HTTPD_HDR_DEFORT, 0, HttpGetIndexPage, NULL, NULL, NULL }, - { "/test", HTTPD_HDR_DEFORT, 0, HttpGetTestPage, NULL, NULL, NULL }, + { "/js", HTTPD_HDR_DEFORT, 0, HttpGetJs, NULL, NULL, NULL }, { "/socket", HTTPD_HDR_DEFORT, 0, NULL, HttpSetSocketStatus, NULL, NULL }, { "/status", HTTPD_HDR_DEFORT, 0, HttpGetTc1Status, NULL, NULL, NULL }, { "/power", HTTPD_HDR_DEFORT, 0, NULL, HttpGetPowerInfo, NULL, NULL }, @@ -400,7 +415,7 @@ static int _AppHttpdStart() { OSStatus err = kNoErr; http_log("initializing web-services"); - http_log("sizeof(angular_min_html) = %d sizeof(test_html) = %d", sizeof(angular_min_html), sizeof(test_html)); + http_log("sizeof(angular_min_html) = %d sizeof(test_html) = %d", sizeof(angular_min_html), sizeof(jquery_min_html)); /*Initialize HTTPD*/ if(is_http_init == false) { diff --git a/TC1/http_server/app_httpd.h b/TC1/http_server/app_httpd.h index db732d5..4b7db54 100644 --- a/TC1/http_server/app_httpd.h +++ b/TC1/http_server/app_httpd.h @@ -33,6 +33,7 @@ #include "http_server/web_log.h" #define HTTP_CONTENT_HTML_ZIP "text/html\r\nContent-Encoding: gzip" +#define HTTP_CONTENT_JS_ZIP "text/javascript\r\nContent-Encoding: gzip" #define HTTPD_HDR_DEFORT (HTTPD_HDR_ADD_SERVER|HTTPD_HDR_ADD_CONN_CLOSE|HTTPD_HDR_ADD_PRAGMA_NO_CACHE) diff --git a/TC1/http_server/index.html b/TC1/http_server/index.html index 921b013..4969a0b 100644 --- a/TC1/http_server/index.html +++ b/TC1/http_server/index.html @@ -237,6 +237,8 @@

power by github/zTC1

+ +