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

h2: server: file serving chunk restricted to max frame size from SETTINGS

This commit is contained in:
Yucong Sun 2021-07-20 10:13:26 +01:00 committed by Andy Green
parent d1db1d7b3f
commit 1f99c206ab

View file

@ -2870,6 +2870,9 @@ int lws_serve_http_file_fragment(struct lws *wsi)
unsigned char *p, *pstart;
#if defined(LWS_WITH_RANGES)
unsigned char finished = 0;
#endif
#if defined(LWS_ROLE_H2)
struct lws *nwsi;
#endif
int n, m;
@ -3014,6 +3017,18 @@ int lws_serve_http_file_fragment(struct lws *wsi)
else
n = lws_ptr_diff(p, pstart) + (int)amount;
#if defined(LWS_ROLE_H2)
/*
* If it's h2, restrict any lump that we are sending to the
* max h2 frame size the peer indicated he could handle in
* his SETTINGS
*/
nwsi = lws_get_network_wsi(wsi);
if (nwsi->h2.h2n &&
n > (int)nwsi->h2.h2n->peer_set.s[H2SET_MAX_FRAME_SIZE])
n = (int)nwsi->h2.h2n->peer_set.s[H2SET_MAX_FRAME_SIZE];
#endif
lwsl_debug("%s: sending %d\n", __func__, n);
if (n) {