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;
|
size_t payloadlen;
|
||||||
|
|
||||||
/* 8 for Max-Age, Port, Reserved and PID_LEN. 1 for HOST_LEN. */
|
payloadlen = NGHTTP2_ALTSVC_MINLEN + protocol_id_len + host_len + origin_len;
|
||||||
payloadlen = 8 + protocol_id_len + 1 + host_len + origin_len;
|
|
||||||
|
|
||||||
frame_set_hd(&frame->hd, payloadlen, NGHTTP2_ALTSVC, NGHTTP2_FLAG_NONE,
|
frame_set_hd(&frame->hd, payloadlen, NGHTTP2_ALTSVC, NGHTTP2_FLAG_NONE,
|
||||||
stream_id);
|
stream_id);
|
||||||
|
|
|
@ -60,6 +60,16 @@
|
||||||
/* 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 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. */
|
/* Category of frames. */
|
||||||
typedef enum {
|
typedef enum {
|
||||||
/* non-DATA frame */
|
/* non-DATA frame */
|
||||||
|
|
|
@ -4490,7 +4490,7 @@ ssize_t nghttp2_session_mem_recv(nghttp2_session *session,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(iframe->payloadleft < 9) {
|
if(iframe->payloadleft < NGHTTP2_ALTSVC_MINLEN) {
|
||||||
busy = 1;
|
busy = 1;
|
||||||
|
|
||||||
iframe->state = NGHTTP2_IB_FRAME_SIZE_ERROR;
|
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;
|
iframe->state = NGHTTP2_IB_READ_NBYTE;
|
||||||
inbound_frame_set_mark(iframe, 8);
|
inbound_frame_set_mark(iframe, NGHTTP2_ALTSVC_FIXED_PARTLEN);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case NGHTTP2_BLOCKED:
|
case NGHTTP2_BLOCKED:
|
||||||
|
@ -4711,7 +4711,7 @@ ssize_t nghttp2_session_mem_recv(nghttp2_session *session,
|
||||||
case NGHTTP2_ALTSVC: {
|
case NGHTTP2_ALTSVC: {
|
||||||
size_t varlen;
|
size_t varlen;
|
||||||
|
|
||||||
varlen = iframe->frame.hd.length - 8;
|
varlen = iframe->frame.hd.length - NGHTTP2_ALTSVC_FIXED_PARTLEN;
|
||||||
|
|
||||||
if(varlen > 0) {
|
if(varlen > 0) {
|
||||||
iframe->raw_lbuf = malloc(varlen);
|
iframe->raw_lbuf = malloc(varlen);
|
||||||
|
|
Loading…
Reference in New Issue