diff --git a/CMakeLists.txt b/CMakeLists.txt
index cd731345a3b4a7d718298c95bea8653331cab669..826827f370aeb16b0c8c72fe5c357c1d450b5c4c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -669,7 +669,7 @@ if (LWS_WITH_LIBUV)
CHECK_INCLUDE_FILE(uv-version.h LWS_HAVE_UV_VERSION_H)
# libuv changed the location in 1.21.0. Retain both
# checks temporarily to ensure a smooth transition.
- if(NOT LWS_HAVE_UV_VERSION_H)
+ if (NOT LWS_HAVE_UV_VERSION_H)
CHECK_INCLUDE_FILE(uv/version.h LWS_HAVE_NEW_UV_VERSION_H)
endif()
endif()
@@ -1795,6 +1795,9 @@ if ((LWS_ROLE_H1 OR LWS_ROLE_H2) AND NOT LWS_WITHOUT_TESTAPPS)
INSTALL_DATADIR="${CMAKE_INSTALL_PREFIX}/plugins"
)
+ SET_TARGET_PROPERTIES(${PLUGIN_NAME}
+ PROPERTIES COMPILE_FLAGS ${CMAKE_C_FLAGS})
+
# set_target_properties(${PLUGIN_NAME}
# PROPERTIES
# OUTPUT_NAME ${PLUGIN_NAME})
diff --git a/lib/core/libwebsockets.c b/lib/core/libwebsockets.c
index ffdcffc43542c45d87f70607d8a5cbd6d54c51b1..0104fbc6c2a4c1ba440ea50430e4eb1f0a78c4d5 100644
--- a/lib/core/libwebsockets.c
+++ b/lib/core/libwebsockets.c
@@ -2733,6 +2733,27 @@ lws_json_purify(char *escaped, const char *string, int len)
}
while (*p && len-- > 6) {
+ if (*p == '\t') {
+ p++;
+ *q++ = '\\';
+ *q++ = 't';
+ continue;
+ }
+
+ if (*p == '\n') {
+ p++;
+ *q++ = '\\';
+ *q++ = 'n';
+ continue;
+ }
+
+ if (*p == '\r') {
+ p++;
+ *q++ = '\\';
+ *q++ = 'r';
+ continue;
+ }
+
if (*p == '\"' || *p == '\\' || *p < 0x20) {
*q++ = '\\';
*q++ = 'u';
diff --git a/lib/core/private.h b/lib/core/private.h
index fd69e3023a5c4bc4ae6c4ad805259f7942831d81..28b310c1590fa2a1996668309e14ce73867c3e21 100644
--- a/lib/core/private.h
+++ b/lib/core/private.h
@@ -1320,7 +1320,7 @@ lws_handshake_server(struct lws *wsi, unsigned char **buf, size_t len);
LWS_EXTERN int
lws_access_log(struct lws *wsi);
LWS_EXTERN void
-lws_prepare_access_log_info(struct lws *wsi, char *uri_ptr, int meth);
+lws_prepare_access_log_info(struct lws *wsi, char *uri_ptr, int len, int meth);
#else
#define lws_access_log(_a)
#endif
diff --git a/lib/event-libs/libuv/libuv.c b/lib/event-libs/libuv/libuv.c
index 502dd18866552f6fec9ddecf8956159ce05bbf48..ec37e09e8568fb57e829721fd058e0953dd90417 100644
--- a/lib/event-libs/libuv/libuv.c
+++ b/lib/event-libs/libuv/libuv.c
@@ -442,6 +442,8 @@ lws_plat_plugins_destroy(struct lws_context *context)
void *v;
int m;
+// return 0;
+
#if defined(__MINGW32__) || !defined(WIN32)
pofs = 3;
#endif
diff --git a/lib/libwebsockets.h b/lib/libwebsockets.h
index b1abe0ce80c28b07749b4e566dec2a8924fa4aab..ad074ec3022231a72dc165e0479ebcdf6df55fbb 100644
--- a/lib/libwebsockets.h
+++ b/lib/libwebsockets.h
@@ -4101,7 +4101,7 @@ LWS_VISIBLE LWS_EXTERN int LWS_WARN_UNUSED_RESULT
lws_hdr_fragment_length(struct lws *wsi, enum lws_token_indexes h, int frag_idx);
/**
- * lws_hdr_copy() - copy a single fragment of the given header to a buffer
+ * lws_hdr_copy() - copy all fragments of the given header to a buffer
* The buffer length len must include space for an additional
* terminating '\0', or it will fail returning -1.
*
@@ -4111,7 +4111,8 @@ lws_hdr_fragment_length(struct lws *wsi, enum lws_token_indexes h, int frag_idx)
* \param h: which header index we are interested in
*
* copies the whole, aggregated header, even if it was delivered in
- * several actual headers piece by piece
+ * several actual headers piece by piece. Returns -1 or length of the whole
+ * header.
*/
LWS_VISIBLE LWS_EXTERN int
lws_hdr_copy(struct lws *wsi, char *dest, int len, enum lws_token_indexes h);
diff --git a/lib/roles/h2/http2.c b/lib/roles/h2/http2.c
index 4e71adc45c586220b0b14d728f9b4c90eb988790..5ade1c7f333912d49be0725eddae4891e63ef233 100644
--- a/lib/roles/h2/http2.c
+++ b/lib/roles/h2/http2.c
@@ -2073,7 +2073,7 @@ lws_h2_client_handshake(struct lws *wsi)
if (lws_add_http_header_by_token(wsi,
WSI_TOKEN_HTTP_COLON_SCHEME,
- (unsigned char *)"http", 4,
+ (unsigned char *)"https", 4,
&p, end))
goto fail_length;
diff --git a/lib/roles/http/client/client-handshake.c b/lib/roles/http/client/client-handshake.c
index b84dac1d6b6b1d9d2eb38d462869cefe8f0614df..bc951378726b37f5e0f3a07986e06db491bb9830 100644
--- a/lib/roles/http/client/client-handshake.c
+++ b/lib/roles/http/client/client-handshake.c
@@ -319,7 +319,7 @@ create_new_conn:
}
#endif
} else {
- lwsl_err("getaddrinfo failed\n");
+ lwsl_err("getaddrinfo failed: %d\n", n);
cce = "getaddrinfo failed";
goto oom4;
}
diff --git a/lib/roles/http/server/access-log.c b/lib/roles/http/server/access-log.c
index 0e75309d7ae154442b6555d277e90d2506a065e2..dc016a5be754637ba9163574c7ba103b6602b4de 100644
--- a/lib/roles/http/server/access-log.c
+++ b/lib/roles/http/server/access-log.c
@@ -38,14 +38,14 @@ static const char * const hver[] = {
};
void
-lws_prepare_access_log_info(struct lws *wsi, char *uri_ptr, int meth)
+lws_prepare_access_log_info(struct lws *wsi, char *uri_ptr, int uri_len, int meth)
{
#ifdef LWS_WITH_IPV6
char ads[INET6_ADDRSTRLEN];
#else
char ads[INET_ADDRSTRLEN];
#endif
- char da[64];
+ char da[64], uri[256];
const char *pa, *me;
struct tm *tmp;
time_t t = time(NULL);
@@ -81,11 +81,20 @@ lws_prepare_access_log_info(struct lws *wsi, char *uri_ptr, int meth)
if (!me)
me = "(null)";
+ m = uri_len;
+ if (m > (int)sizeof(uri) - 1)
+ m = sizeof(uri) - 1;
+
+ strncpy(uri, uri_ptr, m);
+ uri[m] = '\0';
+
lws_snprintf(wsi->http.access_log.header_log, l,
"%s - - [%s] \"%s %s %s\"",
- pa, da, me, uri_ptr,
+ pa, da, me, uri,
hver[wsi->http.request_version]);
+ lwsl_notice("%s\n", wsi->http.access_log.header_log);
+
l = lws_hdr_total_length(wsi, WSI_TOKEN_HTTP_USER_AGENT);
if (l) {
wsi->http.access_log.user_agent = lws_malloc(l + 2, "access log");
diff --git a/lib/roles/http/server/parsers.c b/lib/roles/http/server/parsers.c
index 82cf5ba76699cb6491c06da860e535b7f71ae541..62778b8a04f3a6c4b38ffc2f8392ce596ad0d438 100644
--- a/lib/roles/http/server/parsers.c
+++ b/lib/roles/http/server/parsers.c
@@ -599,7 +599,8 @@ issue_char(struct lws *wsi, unsigned char c)
* If we haven't hit the token limit, just copy the character into
* the header
*/
- if (frag_len < wsi->http.ah->current_token_limit) {
+ if (!wsi->http.ah->current_token_limit ||
+ frag_len < wsi->http.ah->current_token_limit) {
wsi->http.ah->data[wsi->http.ah->pos++] = c;
if (c)
wsi->http.ah->frags[wsi->http.ah->nfrag].len++;
diff --git a/lib/roles/http/server/server.c b/lib/roles/http/server/server.c
index 9377f18bb5316ae409733c661f51867a6e1459a3..147d0d6d61413bcba86ec4be5b86de1c0e9a446e 100644
--- a/lib/roles/http/server/server.c
+++ b/lib/roles/http/server/server.c
@@ -1001,7 +1001,7 @@ lws_http_action(struct lws *wsi)
#endif
#ifdef LWS_WITH_ACCESS_LOG
- lws_prepare_access_log_info(wsi, uri_ptr, meth);
+ lws_prepare_access_log_info(wsi, uri_ptr, uri_len, meth);
#endif
/* can we serve it from the mount list? */
@@ -1292,7 +1292,7 @@ lws_http_action(struct lws *wsi)
}
#endif
- n = (int)strlen(s);
+ n = uri_len - (s - uri_ptr); // (int)strlen(s);
if (s[0] == '\0' || (n == 1 && s[n - 1] == '/'))
s = (char *)hit->def;
if (!s)
@@ -1548,7 +1548,7 @@ raw_transition:
&uri_ptr, &uri_len);
if (meth >= 0)
lws_prepare_access_log_info(wsi,
- uri_ptr, meth);
+ uri_ptr, uri_len, meth);
/* wsi close will do the log */
#endif
@@ -1714,7 +1714,7 @@ lws_http_transaction_completed(struct lws *wsi)
/* if we can't go back to accept new headers, drop the connection */
if (wsi->http2_substream)
- return 0;
+ return 1;
if (wsi->seen_zero_length_recv)
return 1;
diff --git a/lwsws/main.c b/lwsws/main.c
index fba948ef61aaf499d8cbb7d2ec5f7eb5dfcf2431..2055d774b70273f6e2fe13c9ff428dae38af2870 100644
--- a/lwsws/main.c
+++ b/lwsws/main.c
@@ -208,7 +208,7 @@ reload_handler(int signum)
int main(int argc, char **argv)
{
- int n = 0, budget = 100, debug_level = 7;
+ int n = 0, budget = 100, debug_level = 1024 + 7;
#ifndef _WIN32
int m;
int status, syslog_options = LOG_PID | LOG_PERROR;
diff --git a/plugins/protocol_lws_sshd_demo.c b/plugins/protocol_lws_sshd_demo.c
index 1590416f43052899829c74159ad8ebb9fc0c2498..bca536bb8a41e9dd919fed7079643496c76b0e7d 100644
--- a/plugins/protocol_lws_sshd_demo.c
+++ b/plugins/protocol_lws_sshd_demo.c
@@ -415,6 +415,9 @@ callback_lws_sshd_demo(struct lws *wsi, enum lws_callback_reasons reason,
case LWS_CALLBACK_VHOST_CERT_AGING:
break;
+ case LWS_CALLBACK_EVENT_WAIT_CANCELLED:
+ break;
+
default:
if (!vhd->ssh_base_protocol) {
vhd->ssh_base_protocol = lws_vhost_name_to_protocol(
diff --git a/test-apps/.gitignore b/test-apps/.gitignore
deleted file mode 100644
index 53ba6cb408c82bb06a746048d614b4a1431d194d..0000000000000000000000000000000000000000
--- a/test-apps/.gitignore
+++ /dev/null
@@ -1,9 +0,0 @@
-#Ignore build files
-libwebsockets-test-*
-Makefile
-*.o
-*.lo
-*.la
-.libs
-.deps
-