1
0
Fork 0
mirror of https://github.com/warmcat/libwebsockets.git synced 2025-03-09 00:00:04 +01:00

Allow all HTTP method to be pipelined

Signed-off-by: stropee <simon@sirocha.fr>
This commit is contained in:
stropee 2024-10-20 15:18:04 +02:00
parent 6b950e8666
commit efa6221216
3 changed files with 22 additions and 13 deletions

View file

@ -196,10 +196,8 @@ lws_client_connect_2_dnsreq(struct lws *wsi)
}
/* only pipeline things we associate with being a stream */
if (meth && strcmp(meth, "RAW") && strcmp(meth, "GET") &&
strcmp(meth, "POST") && strcmp(meth, "PUT") &&
strcmp(meth, "UDP") && strcmp(meth, "MQTT"))
if(meth && !is_http_method(meth) && strcmp(meth, "RAW") &&
strcmp(meth, "UDP") && strcmp(meth, "MQTT"))
goto solo;
if (!adsin)
@ -252,8 +250,7 @@ solo:
* piggyback on our transaction queue
*/
if (meth && (!strcmp(meth, "RAW") || !strcmp(meth, "GET") ||
!strcmp(meth, "POST") || !strcmp(meth, "PUT") ||
if (meth && (!strcmp(meth, "RAW") || is_http_method(meth) ||
!strcmp(meth, "MQTT")) &&
lws_dll2_is_detached(&wsi->dll2_cli_txn_queue) &&
lws_dll2_is_detached(&wsi->dll_cli_active_conns)) {

View file

@ -971,11 +971,24 @@ static const char * const http_methods[] = {
"GET", "POST", "OPTIONS", "HEAD", "PUT", "PATCH", "DELETE", "CONNECT"
};
int
is_http_method(const char *method)
{
int n = 0;
if(NULL == method)
return 0;
for (n = 0; n < (int)LWS_ARRAY_SIZE(http_methods); n++)
if (!strcmp(method, http_methods[n]))
return 1;
return 0;
}
static int
rops_client_bind_h1(struct lws *wsi, const struct lws_client_connect_info *i)
{
int n;
if (!i) {
/* we are finalizing an already-selected role */
@ -1046,10 +1059,8 @@ rops_client_bind_h1(struct lws *wsi, const struct lws_client_connect_info *i)
}
/* if a recognized http method, bind to it */
for (n = 0; n < (int)LWS_ARRAY_SIZE(http_methods); n++)
if (!strcmp(i->method, http_methods[n]))
goto bind_h1;
if(is_http_method(i->method))
goto bind_h1;
/* other roles may bind to it */

View file

@ -25,6 +25,7 @@
*
* Most of the h1 business is defined in the h1 / h2 common roles/http dir
*/
int
is_http_method(const char *method);
extern const struct lws_role_ops role_ops_h1;
#define lwsi_role_h1(wsi) (wsi->role_ops == &role_ops_h1)