aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Green <andy@warmcat.com>2023-10-27 05:50:26 +0100
committerAndy Green <andy@warmcat.com>2023-10-27 06:15:42 +0100
commit816544f1d6d05cfa5d9fa5875f38e218c56285b3 (patch)
tree6a574500bce306be228ff098ada9a291e4eac838
parentd4c9158d88502041d0e9375cd51ad109ca8ff35d (diff)
downloadlibwebsockets-816544f1d6d05cfa5d9fa5875f38e218c56285b3.tar.gz
ss: http: support PATCH
https://github.com/warmcat/libwebsockets/issues/2989
-rw-r--r--lib/secure-streams/protocols/ss-h1.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/lib/secure-streams/protocols/ss-h1.c b/lib/secure-streams/protocols/ss-h1.c
index 8bf622b0..ac760be6 100644
--- a/lib/secure-streams/protocols/ss-h1.c
+++ b/lib/secure-streams/protocols/ss-h1.c
@@ -248,12 +248,13 @@ lws_apply_metadata(lws_ss_handle_t *h, struct lws *wsi, uint8_t *buf,
}
/*
- * Content-length on POST / PUT if we have the length information
+ * Content-length on POST / PUT / PATCH if we have the length information
*/
if (h->policy->u.http.method && (
(!strcmp(h->policy->u.http.method, "POST") ||
- !strcmp(h->policy->u.http.method, "PUT"))) &&
+ !strcmp(h->policy->u.http.method, "PATCH") ||
+ !strcmp(h->policy->u.http.method, "PUT"))) &&
wsi->http.writeable_len) {
if (!(h->policy->flags &
LWSSSPOLF_HTTP_NO_CONTENT_LENGTH)) {
@@ -840,6 +841,7 @@ malformed:
h->policy->protocol == LWSSSP_H2) &&
h->being_serialized && (
!strcmp(h->policy->u.http.method, "PUT") ||
+ !strcmp(h->policy->u.http.method, "PATCH") ||
!strcmp(h->policy->u.http.method, "POST"))) {
wsi->client_suppress_CONNECTION_ERROR = 1;
@@ -1105,6 +1107,16 @@ malformed:
return -1;
if (lws_ss_alloc_set_metadata(h, "method", "POST", 4))
return -1;
+ } else {
+ m = lws_hdr_total_length(wsi, WSI_TOKEN_PATCH_URI);
+ if (m) {
+ if (lws_ss_alloc_set_metadata(h, "path",
+ lws_hdr_simple_ptr(wsi,
+ WSI_TOKEN_PATCH_URI), (unsigned int)m))
+ return -1;
+ if (lws_ss_alloc_set_metadata(h, "method", "PATCH", 5))
+ return -1;
+ }
}
}
}