Replace NGHTTP2_MAX_FRAME_LENGTH with NGHTTP2_MAX_PAYLOADLEN

This commit is contained in:
Tatsuhiro Tsujikawa 2014-03-11 02:01:08 +09:00
parent e803c6b65e
commit 74f899fc01
4 changed files with 33 additions and 33 deletions

View File

@ -264,13 +264,13 @@ ssize_t nghttp2_frame_pack_headers(nghttp2_buf *buf,
frame */
memset(buf->pos, 0, NGHTTP2_FRAME_HDLEN);
/* pack ctrl header after length is determined */
if(NGHTTP2_MAX_FRAME_LENGTH < frame->hd.length) {
/* pack frame header after length is determined */
if(NGHTTP2_MAX_PAYLOADLEN < frame->hd.length) {
/* Needs CONTINUATION */
nghttp2_frame_hd hd = frame->hd;
hd.flags &= ~NGHTTP2_FLAG_END_HEADERS;
hd.length = NGHTTP2_MAX_FRAME_LENGTH;
hd.length = NGHTTP2_MAX_PAYLOADLEN;
nghttp2_frame_pack_frame_hd(buf->pos, &hd);
} else {
@ -473,13 +473,13 @@ ssize_t nghttp2_frame_pack_push_promise(nghttp2_buf *buf,
frame */
memset(buf->pos, 0, NGHTTP2_FRAME_HDLEN);
/* pack ctrl header after length is determined */
if(NGHTTP2_MAX_FRAME_LENGTH < frame->hd.length) {
/* pack frame header after length is determined */
if(NGHTTP2_MAX_PAYLOADLEN < frame->hd.length) {
/* Needs CONTINUATION */
nghttp2_frame_hd hd = frame->hd;
hd.flags &= ~NGHTTP2_FLAG_END_HEADERS;
hd.length = NGHTTP2_MAX_FRAME_LENGTH;
hd.length = NGHTTP2_MAX_PAYLOADLEN;
nghttp2_frame_pack_frame_hd(buf->pos, &hd);
} else {

View File

@ -42,7 +42,7 @@
/* The maximum payload length of a frame TODO: Must be renamed as
NGHTTP2_MAX_PAYLOAD_LENGTH */
#define NGHTTP2_MAX_FRAME_LENGTH ((1 << 14) - 1)
#define NGHTTP2_MAX_PAYLOADLEN ((1 << 14) - 1)
/* The maximum length of DATA frame payload. To fit entire DATA frame
into 4096K buffer, we use subtract header size (8 bytes) + 2 bytes
@ -111,9 +111,9 @@ size_t nghttp2_frame_headers_payload_nv_offset(nghttp2_headers *frame);
*
* frame->hd.length is assigned after length is determined during
* packing process. If payload length is strictly larger than
* NGHTTP2_MAX_FRAME_LENGTH, payload data is still serialized as is,
* but frame->hd.length is set to NGHTTP2_MAX_FRAME_LENGTH and
* NGHTTP2_FLAG_END_HEADERS flag is cleared from frame->hd.flags.
* NGHTTP2_MAX_PAYLOADLEN, payload data is still serialized as is, but
* serialized header's payload length is set to NGHTTP2_MAX_PAYLOADLEN
* and NGHTTP2_FLAG_END_HEADERS flag is cleared.
*
* This function returns the size of packed frame (which equals to
* nghttp2_buf_len(buf)) if it succeeds, or returns one of the
@ -254,9 +254,9 @@ int nghttp2_frame_unpack_settings_payload2(nghttp2_settings_entry **iv_ptr,
*
* frame->hd.length is assigned after length is determined during
* packing process. If payload length is strictly larger than
* NGHTTP2_MAX_FRAME_LENGTH, payload data is still serialized as is,
* but frame->hd.length is set to NGHTTP2_MAX_FRAME_LENGTH and
* NGHTTP2_FLAG_END_HEADERS flag is cleared from frame->hd.flags.
* NGHTTP2_MAX_PAYLOADLEN, payload data is still serialized as is, but
* serialized header's payload length is set to NGHTTP2_MAX_PAYLOADLEN
* and NGHTTP2_FLAG_END_HEADERS flag is cleared.
*
* This function returns the size of packed frame (which equals to
* nghttp2_buf_len(buf)) if it succeeds, or returns one of the

View File

@ -1178,15 +1178,15 @@ static ssize_t session_headers_add_pad(nghttp2_session *session,
DEBUGF(fprintf(stderr, "padding selected: payloadlen=%zu, padlen=%zu\n",
frame->hd.length, frame->headers.padlen));
if(frame->hd.length > NGHTTP2_MAX_FRAME_LENGTH) {
if(frame->hd.length > NGHTTP2_MAX_PAYLOADLEN) {
nghttp2_frame_hd hd = frame->hd;
hd.flags &= ~NGHTTP2_FLAG_END_HEADERS;
hd.length = NGHTTP2_MAX_FRAME_LENGTH;
hd.length = NGHTTP2_MAX_PAYLOADLEN;
if(NGHTTP2_MAX_FRAME_LENGTH > frame->hd.length - frame->headers.padlen) {
if(NGHTTP2_MAX_PAYLOADLEN > frame->hd.length - frame->headers.padlen) {
size_t padlen;
padlen = NGHTTP2_MAX_FRAME_LENGTH -
padlen = NGHTTP2_MAX_PAYLOADLEN -
(frame->hd.length - frame->headers.padlen);
DEBUGF(fprintf(stderr, "padding across 2 frames\n"));
@ -1608,7 +1608,7 @@ static int nghttp2_session_after_frame_sent(nghttp2_session *session)
nghttp2_frame_hd cont_hd;
cont_hd.length = nghttp2_min(framebuf->last - framebuf->mark,
NGHTTP2_MAX_FRAME_LENGTH);
NGHTTP2_MAX_PAYLOADLEN);
cont_hd.type = NGHTTP2_CONTINUATION;
cont_hd.stream_id = frame->hd.stream_id;
cont_hd.flags = NGHTTP2_FLAG_NONE;
@ -1970,7 +1970,7 @@ ssize_t nghttp2_session_mem_send(nghttp2_session *session,
/* We have to get frame size from headers, because
frame->hd.length does not always shows the actual frame
size, especially for HEADERS size >
NGHTTP2_MAX_FRAME_LENGTH */
NGHTTP2_MAX_PAYLOADLEN */
frame = nghttp2_outbound_item_get_ctrl_frame(item);
framebuf->mark = framebuf->pos + NGHTTP2_FRAME_HDLEN +

View File

@ -3628,19 +3628,19 @@ void test_nghttp2_session_flow_control_data_recv(void)
NGHTTP2_PRI_DEFAULT,
NGHTTP2_STREAM_OPENED, NULL);
session->local_window_size = NGHTTP2_MAX_FRAME_LENGTH;
stream->local_window_size = NGHTTP2_MAX_FRAME_LENGTH;
session->local_window_size = NGHTTP2_MAX_PAYLOADLEN;
stream->local_window_size = NGHTTP2_MAX_PAYLOADLEN;
/* Create DATA frame */
memset(data, 0, sizeof(data));
hd.length = NGHTTP2_MAX_FRAME_LENGTH;
hd.length = NGHTTP2_MAX_PAYLOADLEN;
hd.type = NGHTTP2_DATA;
hd.flags = NGHTTP2_FLAG_END_STREAM;
hd.stream_id = 1;
nghttp2_frame_pack_frame_hd(data, &hd);
CU_ASSERT(NGHTTP2_MAX_FRAME_LENGTH+NGHTTP2_FRAME_HDLEN ==
CU_ASSERT(NGHTTP2_MAX_PAYLOADLEN+NGHTTP2_FRAME_HDLEN ==
nghttp2_session_mem_recv(session, data,
NGHTTP2_MAX_FRAME_LENGTH +
NGHTTP2_MAX_PAYLOADLEN +
NGHTTP2_FRAME_HDLEN));
item = nghttp2_session_get_next_ob_item(session);
@ -3648,7 +3648,7 @@ void test_nghttp2_session_flow_control_data_recv(void)
issued, but connection-level does. */
CU_ASSERT(NGHTTP2_WINDOW_UPDATE == OB_CTRL_TYPE(item));
CU_ASSERT(0 == OB_CTRL(item)->hd.stream_id);
CU_ASSERT(NGHTTP2_MAX_FRAME_LENGTH ==
CU_ASSERT(NGHTTP2_MAX_PAYLOADLEN ==
OB_CTRL(item)->window_update.window_size_increment);
CU_ASSERT(0 == nghttp2_session_send(session));
@ -3658,15 +3658,15 @@ void test_nghttp2_session_flow_control_data_recv(void)
RST_STREAM is issued by the remote, but the local side keeps
sending DATA frames. Without calculating connection-level window,
the subsequent flow control gets confused. */
CU_ASSERT(NGHTTP2_MAX_FRAME_LENGTH+NGHTTP2_FRAME_HDLEN ==
CU_ASSERT(NGHTTP2_MAX_PAYLOADLEN+NGHTTP2_FRAME_HDLEN ==
nghttp2_session_mem_recv(session, data,
NGHTTP2_MAX_FRAME_LENGTH +
NGHTTP2_MAX_PAYLOADLEN +
NGHTTP2_FRAME_HDLEN));
item = nghttp2_session_get_next_ob_item(session);
CU_ASSERT(NGHTTP2_WINDOW_UPDATE == OB_CTRL_TYPE(item));
CU_ASSERT(0 == OB_CTRL(item)->hd.stream_id);
CU_ASSERT(NGHTTP2_MAX_FRAME_LENGTH ==
CU_ASSERT(NGHTTP2_MAX_PAYLOADLEN ==
OB_CTRL(item)->window_update.window_size_increment);
nghttp2_session_del(session);
@ -4199,7 +4199,7 @@ void test_nghttp2_session_pack_headers_with_padding(void)
nva, ARRLEN(nva), NULL, NULL));
CU_ASSERT(0 == nghttp2_session_send(session));
CU_ASSERT(acc.length > NGHTTP2_MAX_FRAME_LENGTH);
CU_ASSERT(acc.length > NGHTTP2_MAX_PAYLOADLEN);
ud.frame_recv_cb_called = 0;
CU_ASSERT((ssize_t)acc.length ==
nghttp2_session_mem_recv(sv_session, acc.buf, acc.length));
@ -4213,7 +4213,7 @@ void test_nghttp2_session_pack_headers_with_padding(void)
acc.length = 0;
CU_ASSERT(0 == nghttp2_session_send(sv_session));
CU_ASSERT(acc.length > NGHTTP2_MAX_FRAME_LENGTH);
CU_ASSERT(acc.length > NGHTTP2_MAX_PAYLOADLEN);
ud.frame_recv_cb_called = 0;
CU_ASSERT((ssize_t)acc.length ==
nghttp2_session_mem_recv(session, acc.buf, acc.length));
@ -4261,7 +4261,7 @@ void test_nghttp2_session_pack_headers_with_padding2(void)
nva, ARRLEN(nva), NULL, NULL));
CU_ASSERT(0 == nghttp2_session_send(session));
CU_ASSERT(acc.length > NGHTTP2_MAX_FRAME_LENGTH);
CU_ASSERT(acc.length > NGHTTP2_MAX_PAYLOADLEN);
ud.frame_recv_cb_called = 0;
CU_ASSERT((ssize_t)acc.length ==
@ -4310,7 +4310,7 @@ void test_nghttp2_session_pack_headers_with_padding3(void)
nva, ARRLEN(nva), NULL, NULL));
CU_ASSERT(0 == nghttp2_session_send(session));
CU_ASSERT(acc.length > NGHTTP2_MAX_FRAME_LENGTH);
CU_ASSERT(acc.length > NGHTTP2_MAX_PAYLOADLEN);
ud.frame_recv_cb_called = 0;
CU_ASSERT((ssize_t)acc.length ==
nghttp2_session_mem_recv(sv_session, acc.buf, acc.length));
@ -4354,7 +4354,7 @@ void test_nghttp2_session_pack_headers_with_padding4(void)
nva, ARRLEN(nva), NULL, NULL));
CU_ASSERT(0 == nghttp2_session_send(session));
CU_ASSERT(acc.length < NGHTTP2_MAX_FRAME_LENGTH);
CU_ASSERT(acc.length < NGHTTP2_MAX_PAYLOADLEN);
ud.frame_recv_cb_called = 0;
CU_ASSERT((ssize_t)acc.length ==
nghttp2_session_mem_recv(sv_session, acc.buf, acc.length));