Fix SPDY/3 priority pack and unpack handling
This commit is contained in:
parent
87c1f07013
commit
5adfd07e7c
|
@ -44,11 +44,6 @@ size_t spdylay_frame_get_len_size(uint16_t version)
|
|||
}
|
||||
}
|
||||
|
||||
static uint8_t spdylay_unpack_pri(const uint8_t *data)
|
||||
{
|
||||
return (data[0] >> 6) & 0x3;
|
||||
}
|
||||
|
||||
static uint8_t* spdylay_pack_str(uint8_t *buf, const char *str, size_t len,
|
||||
size_t len_size)
|
||||
{
|
||||
|
@ -669,9 +664,11 @@ ssize_t spdylay_frame_pack_syn_stream(uint8_t **buf_ptr,
|
|||
spdylay_frame_pack_ctrl_hd(*buf_ptr, &frame->hd);
|
||||
spdylay_put_uint32be(&(*buf_ptr)[8], frame->stream_id);
|
||||
spdylay_put_uint32be(&(*buf_ptr)[12], frame->assoc_stream_id);
|
||||
(*buf_ptr)[16] = (frame->pri << 6);
|
||||
if(frame->hd.version == SPDYLAY_PROTO_SPDY3) {
|
||||
(*buf_ptr)[16] = (frame->pri << 5);
|
||||
(*buf_ptr)[17] = frame->slot;
|
||||
} else {
|
||||
(*buf_ptr)[16] = (frame->pri << 6);
|
||||
}
|
||||
return framelen;
|
||||
}
|
||||
|
@ -708,10 +705,11 @@ int spdylay_frame_unpack_syn_stream_without_nv(spdylay_syn_stream *frame,
|
|||
frame->stream_id = spdylay_get_uint32(payload) & SPDYLAY_STREAM_ID_MASK;
|
||||
frame->assoc_stream_id =
|
||||
spdylay_get_uint32(payload+4) & SPDYLAY_STREAM_ID_MASK;
|
||||
frame->pri = spdylay_unpack_pri(payload+8);
|
||||
if(frame->hd.version == SPDYLAY_PROTO_SPDY3) {
|
||||
frame->pri = (*(payload+8) >> 5);
|
||||
frame->slot = payload[9];
|
||||
} else {
|
||||
frame->pri = (*(payload+8) >> 6);
|
||||
frame->slot = 0;
|
||||
}
|
||||
frame->nv = NULL;
|
||||
|
|
|
@ -304,11 +304,16 @@ static void test_spdylay_frame_pack_syn_stream_version(uint16_t version)
|
|||
uint8_t *buf = NULL, *nvbuf = NULL;
|
||||
size_t buflen = 0, nvbuflen = 0;
|
||||
ssize_t framelen;
|
||||
|
||||
uint8_t pri;
|
||||
if(version == SPDYLAY_PROTO_SPDY2) {
|
||||
pri = 3;
|
||||
} else {
|
||||
pri = 7;
|
||||
}
|
||||
spdylay_zlib_deflate_hd_init(&deflater, 1, version);
|
||||
spdylay_zlib_inflate_hd_init(&inflater, version);
|
||||
spdylay_frame_syn_stream_init(&frame.syn_stream, version,
|
||||
SPDYLAY_CTRL_FLAG_FIN, 65536, 1000000007, 3,
|
||||
SPDYLAY_CTRL_FLAG_FIN, 65536, 1000000007, pri,
|
||||
spdylay_frame_nv_copy(headers));
|
||||
framelen = spdylay_frame_pack_syn_stream(&buf, &buflen,
|
||||
&nvbuf, &nvbuflen,
|
||||
|
@ -324,6 +329,7 @@ static void test_spdylay_frame_pack_syn_stream_version(uint16_t version)
|
|||
CU_ASSERT(version == oframe.syn_stream.hd.version);
|
||||
CU_ASSERT(SPDYLAY_SYN_STREAM == oframe.syn_stream.hd.type);
|
||||
CU_ASSERT(SPDYLAY_CTRL_FLAG_FIN == oframe.syn_stream.hd.flags);
|
||||
CU_ASSERT(pri == oframe.syn_stream.pri);
|
||||
CU_ASSERT(framelen-SPDYLAY_FRAME_HEAD_LENGTH == oframe.syn_stream.hd.length);
|
||||
CU_ASSERT(strcmp("method", oframe.syn_stream.nv[0]) == 0);
|
||||
CU_ASSERT(strcmp("GET", oframe.syn_stream.nv[1]) == 0);
|
||||
|
|
Loading…
Reference in New Issue