diff --git a/lib/core-net/client/connect2.c b/lib/core-net/client/connect2.c index cb5d5d043..fdb349930 100644 --- a/lib/core-net/client/connect2.c +++ b/lib/core-net/client/connect2.c @@ -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 && !_lws_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") || _lws_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)) { diff --git a/lib/roles/h1/ops-h1.c b/lib/roles/h1/ops-h1.c index 769490fe7..9f97916c6 100644 --- a/lib/roles/h1/ops-h1.c +++ b/lib/roles/h1/ops-h1.c @@ -971,11 +971,20 @@ static const char * const http_methods[] = { "GET", "POST", "OPTIONS", "HEAD", "PUT", "PATCH", "DELETE", "CONNECT" }; +int +_lws_is_http_method(const char *method) +{ + if (method) + for (int 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 +1055,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 (_lws_is_http_method(i->method)) + goto bind_h1; /* other roles may bind to it */ diff --git a/lib/roles/h1/private-lib-roles-h1.h b/lib/roles/h1/private-lib-roles-h1.h index f58ce7e8b..1845ee504 100644 --- a/lib/roles/h1/private-lib-roles-h1.h +++ b/lib/roles/h1/private-lib-roles-h1.h @@ -25,6 +25,7 @@ * * Most of the h1 business is defined in the h1 / h2 common roles/http dir */ - +int +_lws_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)