Define constants for ALTSVC frame parsing
This commit is contained in:
parent
6d942dc0a6
commit
2aa84019c7
|
@ -196,8 +196,7 @@ void nghttp2_frame_altsvc_init(nghttp2_altsvc *frame, int32_t stream_id,
|
|||
{
|
||||
size_t payloadlen;
|
||||
|
||||
/* 8 for Max-Age, Port, Reserved and PID_LEN. 1 for HOST_LEN. */
|
||||
payloadlen = 8 + protocol_id_len + 1 + host_len + origin_len;
|
||||
payloadlen = NGHTTP2_ALTSVC_MINLEN + protocol_id_len + host_len + origin_len;
|
||||
|
||||
frame_set_hd(&frame->hd, payloadlen, NGHTTP2_ALTSVC, NGHTTP2_FLAG_NONE,
|
||||
stream_id);
|
||||
|
|
|
@ -60,6 +60,16 @@
|
|||
/* The maximum header table size in SETTINGS_HEADER_TABLE_SIZE */
|
||||
#define NGHTTP2_MAX_HEADER_TABLE_SIZE ((1u << 31) - 1)
|
||||
|
||||
|
||||
/* Length of fixed part in ALTSVC frame, that is the sum of fields of
|
||||
Max-Age, Port, Reserved and PID_LEN. */
|
||||
#define NGHTTP2_ALTSVC_FIXED_PARTLEN 8
|
||||
|
||||
/* Minimum length of ALTSVC frame. NGHTTP2_ALTSVC_FIXED_PARTLEN +
|
||||
HOST_LEN. */
|
||||
#define NGHTTP2_ALTSVC_MINLEN 9
|
||||
|
||||
|
||||
/* Category of frames. */
|
||||
typedef enum {
|
||||
/* non-DATA frame */
|
||||
|
|
|
@ -4490,7 +4490,7 @@ ssize_t nghttp2_session_mem_recv(nghttp2_session *session,
|
|||
break;
|
||||
}
|
||||
|
||||
if(iframe->payloadleft < 9) {
|
||||
if(iframe->payloadleft < NGHTTP2_ALTSVC_MINLEN) {
|
||||
busy = 1;
|
||||
|
||||
iframe->state = NGHTTP2_IB_FRAME_SIZE_ERROR;
|
||||
|
@ -4499,7 +4499,7 @@ ssize_t nghttp2_session_mem_recv(nghttp2_session *session,
|
|||
}
|
||||
|
||||
iframe->state = NGHTTP2_IB_READ_NBYTE;
|
||||
inbound_frame_set_mark(iframe, 8);
|
||||
inbound_frame_set_mark(iframe, NGHTTP2_ALTSVC_FIXED_PARTLEN);
|
||||
|
||||
break;
|
||||
case NGHTTP2_BLOCKED:
|
||||
|
@ -4711,7 +4711,7 @@ ssize_t nghttp2_session_mem_recv(nghttp2_session *session,
|
|||
case NGHTTP2_ALTSVC: {
|
||||
size_t varlen;
|
||||
|
||||
varlen = iframe->frame.hd.length - 8;
|
||||
varlen = iframe->frame.hd.length - NGHTTP2_ALTSVC_FIXED_PARTLEN;
|
||||
|
||||
if(varlen > 0) {
|
||||
iframe->raw_lbuf = malloc(varlen);
|
||||
|
|
Loading…
Reference in New Issue