Skip to content

Commit f7c171f

Browse files
committed
protocol: fix request path for h2
1 parent 8302039 commit f7c171f

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

src/protocol.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -236,8 +236,12 @@ int callback_tty(struct lws *wsi, enum lws_callback_reasons reason, void *user,
236236
lwsl_warn("refuse to serve WS client due to the --max-clients option.\n");
237237
return 1;
238238
}
239-
if (lws_hdr_copy(wsi, buf, sizeof(buf), WSI_TOKEN_GET_URI) <= 0 ||
240-
strcmp(buf, endpoints.ws) != 0) {
239+
240+
n = lws_hdr_copy(wsi, pss->path, sizeof(pss->path), WSI_TOKEN_GET_URI);
241+
#if defined(LWS_ROLE_H2)
242+
if (n <= 0) n = lws_hdr_copy(wsi, pss->path, sizeof(pss->path), WSI_TOKEN_HTTP_COLON_PATH);
243+
#endif
244+
if (strncmp(pss->path, endpoints.ws, n) != 0) {
241245
lwsl_warn("refuse to serve WS client for illegal ws path: %s\n", buf);
242246
return 1;
243247
}
@@ -276,16 +280,14 @@ int callback_tty(struct lws *wsi, enum lws_callback_reasons reason, void *user,
276280
LIST_INSERT_HEAD(&server->procs, proc, entry);
277281
server->client_count++;
278282

279-
lws_hdr_copy(wsi, buf, sizeof(buf), WSI_TOKEN_GET_URI);
280-
281283
#if LWS_LIBRARY_VERSION_NUMBER >= 2004000
282284
lws_get_peer_simple(lws_get_network_wsi(wsi), pss->address, sizeof(pss->address));
283285
#else
284286
char name[100];
285287
lws_get_peer_addresses(wsi, lws_get_socket_fd(wsi), name, sizeof(name), pss->address,
286288
sizeof(pss->address));
287289
#endif
288-
lwsl_notice("WS %s - %s, clients: %d\n", buf, pss->address, server->client_count);
290+
lwsl_notice("WS %s - %s, clients: %d\n", pss->path, pss->address, server->client_count);
289291
break;
290292

291293
case LWS_CALLBACK_SERVER_WRITEABLE:

src/server.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ struct pss_tty {
5757
int initial_cmd_index;
5858
bool authenticated;
5959
char address[50];
60+
char path[20];
6061

6162
struct lws *wsi;
6263
char *buffer;

0 commit comments

Comments
 (0)