mirror of
https://github.com/warmcat/libwebsockets.git
synced 2025-03-30 00:00:16 +01:00
ss: http: support PATCH
https://github.com/warmcat/libwebsockets/issues/2989
This commit is contained in:
parent
d4c9158d88
commit
816544f1d6
1 changed files with 14 additions and 2 deletions
|
@ -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 && (
|
if (h->policy->u.http.method && (
|
||||||
(!strcmp(h->policy->u.http.method, "POST") ||
|
(!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) {
|
wsi->http.writeable_len) {
|
||||||
if (!(h->policy->flags &
|
if (!(h->policy->flags &
|
||||||
LWSSSPOLF_HTTP_NO_CONTENT_LENGTH)) {
|
LWSSSPOLF_HTTP_NO_CONTENT_LENGTH)) {
|
||||||
|
@ -840,6 +841,7 @@ malformed:
|
||||||
h->policy->protocol == LWSSSP_H2) &&
|
h->policy->protocol == LWSSSP_H2) &&
|
||||||
h->being_serialized && (
|
h->being_serialized && (
|
||||||
!strcmp(h->policy->u.http.method, "PUT") ||
|
!strcmp(h->policy->u.http.method, "PUT") ||
|
||||||
|
!strcmp(h->policy->u.http.method, "PATCH") ||
|
||||||
!strcmp(h->policy->u.http.method, "POST"))) {
|
!strcmp(h->policy->u.http.method, "POST"))) {
|
||||||
|
|
||||||
wsi->client_suppress_CONNECTION_ERROR = 1;
|
wsi->client_suppress_CONNECTION_ERROR = 1;
|
||||||
|
@ -1105,6 +1107,16 @@ malformed:
|
||||||
return -1;
|
return -1;
|
||||||
if (lws_ss_alloc_set_metadata(h, "method", "POST", 4))
|
if (lws_ss_alloc_set_metadata(h, "method", "POST", 4))
|
||||||
return -1;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue