diff --git a/lib/nghttp2_frame.c b/lib/nghttp2_frame.c index 1595c49a..1c0e9bcc 100644 --- a/lib/nghttp2_frame.c +++ b/lib/nghttp2_frame.c @@ -91,8 +91,8 @@ void nghttp2_frame_headers_free(nghttp2_headers *frame) void nghttp2_frame_priority_init(nghttp2_priority *frame, int32_t stream_id, const nghttp2_priority_spec *pri_spec) { - frame_set_hd(&frame->hd, 5, NGHTTP2_PRIORITY, NGHTTP2_FLAG_NONE, - stream_id); + frame_set_hd(&frame->hd, NGHTTP2_PRIORITY_SPECLEN, NGHTTP2_PRIORITY, + NGHTTP2_FLAG_NONE, stream_id); frame->pri_spec = *pri_spec; } @@ -262,7 +262,7 @@ void nghttp2_frame_private_data_free(nghttp2_private_data *frame) size_t nghttp2_frame_priority_len(uint8_t flags) { if(flags & NGHTTP2_FLAG_PRIORITY) { - return 5; + return NGHTTP2_PRIORITY_SPECLEN; } return 0; @@ -436,7 +436,7 @@ int nghttp2_frame_pack_priority(nghttp2_bufs *bufs, nghttp2_priority *frame) buf = &bufs->head->buf; - assert(nghttp2_buf_avail(buf) >= 5); + assert(nghttp2_buf_avail(buf) >= NGHTTP2_PRIORITY_SPECLEN); buf->pos -= NGHTTP2_FRAME_HDLEN; @@ -444,7 +444,7 @@ int nghttp2_frame_pack_priority(nghttp2_bufs *bufs, nghttp2_priority *frame) nghttp2_frame_pack_priority_spec(buf->last, &frame->pri_spec); - buf->last += 5; + buf->last += NGHTTP2_PRIORITY_SPECLEN; return 0; } diff --git a/lib/nghttp2_frame.h b/lib/nghttp2_frame.h index a9f9abb2..cf8e667a 100644 --- a/lib/nghttp2_frame.h +++ b/lib/nghttp2_frame.h @@ -60,6 +60,8 @@ /* The maximum header table size in SETTINGS_HEADER_TABLE_SIZE */ #define NGHTTP2_MAX_HEADER_TABLE_SIZE ((1u << 31) - 1) +/* Length of priority related fields in HEADERS/PRIORITY frames */ +#define NGHTTP2_PRIORITY_SPECLEN 5 /* Length of fixed part in ALTSVC frame, that is the sum of fields of Max-Age, Port, Reserved and PID_LEN. */ diff --git a/lib/nghttp2_session.c b/lib/nghttp2_session.c index 6c309dbf..91356d2e 100644 --- a/lib/nghttp2_session.c +++ b/lib/nghttp2_session.c @@ -4342,7 +4342,7 @@ ssize_t nghttp2_session_mem_recv(nghttp2_session *session, iframe->frame.hd.flags = NGHTTP2_FLAG_NONE; - if(iframe->payloadleft != 5) { + if(iframe->payloadleft != NGHTTP2_PRIORITY_SPECLEN) { busy = 1; iframe->state = NGHTTP2_IB_FRAME_SIZE_ERROR; @@ -4352,7 +4352,7 @@ ssize_t nghttp2_session_mem_recv(nghttp2_session *session, iframe->state = NGHTTP2_IB_READ_NBYTE; - inbound_frame_set_mark(iframe, 5); + inbound_frame_set_mark(iframe, NGHTTP2_PRIORITY_SPECLEN); break; case NGHTTP2_RST_STREAM: