Define constant for the length of priority related fields

This commit is contained in:
Tatsuhiro Tsujikawa 2014-05-22 21:41:43 +09:00
parent 2aa84019c7
commit 78a55935ac
3 changed files with 9 additions and 7 deletions

View File

@ -91,8 +91,8 @@ void nghttp2_frame_headers_free(nghttp2_headers *frame)
void nghttp2_frame_priority_init(nghttp2_priority *frame, int32_t stream_id, void nghttp2_frame_priority_init(nghttp2_priority *frame, int32_t stream_id,
const nghttp2_priority_spec *pri_spec) const nghttp2_priority_spec *pri_spec)
{ {
frame_set_hd(&frame->hd, 5, NGHTTP2_PRIORITY, NGHTTP2_FLAG_NONE, frame_set_hd(&frame->hd, NGHTTP2_PRIORITY_SPECLEN, NGHTTP2_PRIORITY,
stream_id); NGHTTP2_FLAG_NONE, stream_id);
frame->pri_spec = *pri_spec; 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) size_t nghttp2_frame_priority_len(uint8_t flags)
{ {
if(flags & NGHTTP2_FLAG_PRIORITY) { if(flags & NGHTTP2_FLAG_PRIORITY) {
return 5; return NGHTTP2_PRIORITY_SPECLEN;
} }
return 0; return 0;
@ -436,7 +436,7 @@ int nghttp2_frame_pack_priority(nghttp2_bufs *bufs, nghttp2_priority *frame)
buf = &bufs->head->buf; buf = &bufs->head->buf;
assert(nghttp2_buf_avail(buf) >= 5); assert(nghttp2_buf_avail(buf) >= NGHTTP2_PRIORITY_SPECLEN);
buf->pos -= NGHTTP2_FRAME_HDLEN; 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); nghttp2_frame_pack_priority_spec(buf->last, &frame->pri_spec);
buf->last += 5; buf->last += NGHTTP2_PRIORITY_SPECLEN;
return 0; return 0;
} }

View File

@ -60,6 +60,8 @@
/* The maximum header table size in SETTINGS_HEADER_TABLE_SIZE */ /* The maximum header table size in SETTINGS_HEADER_TABLE_SIZE */
#define NGHTTP2_MAX_HEADER_TABLE_SIZE ((1u << 31) - 1) #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 /* Length of fixed part in ALTSVC frame, that is the sum of fields of
Max-Age, Port, Reserved and PID_LEN. */ Max-Age, Port, Reserved and PID_LEN. */

View File

@ -4342,7 +4342,7 @@ ssize_t nghttp2_session_mem_recv(nghttp2_session *session,
iframe->frame.hd.flags = NGHTTP2_FLAG_NONE; iframe->frame.hd.flags = NGHTTP2_FLAG_NONE;
if(iframe->payloadleft != 5) { if(iframe->payloadleft != NGHTTP2_PRIORITY_SPECLEN) {
busy = 1; busy = 1;
iframe->state = NGHTTP2_IB_FRAME_SIZE_ERROR; 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; iframe->state = NGHTTP2_IB_READ_NBYTE;
inbound_frame_set_mark(iframe, 5); inbound_frame_set_mark(iframe, NGHTTP2_PRIORITY_SPECLEN);
break; break;
case NGHTTP2_RST_STREAM: case NGHTTP2_RST_STREAM: