Skip to content

Commit

Permalink
http: pipeline: enable for more methods
Browse files Browse the repository at this point in the history
Signed-off-by: stropee <simon@sirocha.fr>
  • Loading branch information
simon0356 authored and lws-team committed Nov 3, 2024
1 parent 8263a68 commit ea00ad2
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 13 deletions.
9 changes: 3 additions & 6 deletions lib/core-net/client/connect2.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -252,8 +250,7 @@ lws_client_connect_2_dnsreq(struct lws *wsi)
* 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)) {
Expand Down
19 changes: 13 additions & 6 deletions lib/roles/h1/ops-h1.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */

Expand Down Expand Up @@ -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 */

Expand Down
3 changes: 2 additions & 1 deletion lib/roles/h1/private-lib-roles-h1.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit ea00ad2

Please sign in to comment.