Estimate header block size after predicate function succeeds

This commit is contained in:
Tatsuhiro Tsujikawa 2017-04-26 22:15:53 +09:00
parent 963e220a1c
commit 66baa7dc25
1 changed files with 15 additions and 23 deletions

View File

@ -2068,14 +2068,6 @@ static int session_prep_frame(nghttp2_session *session,
/* We don't call nghttp2_session_adjust_closed_stream() here, /* We don't call nghttp2_session_adjust_closed_stream() here,
since we don't keep closed stream in client side */ since we don't keep closed stream in client side */
estimated_payloadlen = session_estimate_headers_payload(
session, frame->headers.nva, frame->headers.nvlen,
NGHTTP2_PRIORITY_SPECLEN);
if (estimated_payloadlen > session->max_send_header_block_length) {
return NGHTTP2_ERR_FRAME_SIZE_ERROR;
}
rv = session_predicate_request_headers_send(session, item); rv = session_predicate_request_headers_send(session, item);
if (rv != 0) { if (rv != 0) {
return rv; return rv;
@ -2087,14 +2079,6 @@ static int session_prep_frame(nghttp2_session *session,
} else { } else {
nghttp2_stream *stream; nghttp2_stream *stream;
estimated_payloadlen = session_estimate_headers_payload(
session, frame->headers.nva, frame->headers.nvlen,
NGHTTP2_PRIORITY_SPECLEN);
if (estimated_payloadlen > session->max_send_header_block_length) {
return NGHTTP2_ERR_FRAME_SIZE_ERROR;
}
stream = nghttp2_session_get_stream(session, frame->hd.stream_id); stream = nghttp2_session_get_stream(session, frame->hd.stream_id);
if (stream && stream->state == NGHTTP2_STREAM_RESERVED) { if (stream && stream->state == NGHTTP2_STREAM_RESERVED) {
@ -2121,6 +2105,14 @@ static int session_prep_frame(nghttp2_session *session,
} }
} }
estimated_payloadlen = session_estimate_headers_payload(
session, frame->headers.nva, frame->headers.nvlen,
NGHTTP2_PRIORITY_SPECLEN);
if (estimated_payloadlen > session->max_send_header_block_length) {
return NGHTTP2_ERR_FRAME_SIZE_ERROR;
}
rv = nghttp2_frame_pack_headers(&session->aob.framebufs, &frame->headers, rv = nghttp2_frame_pack_headers(&session->aob.framebufs, &frame->headers,
&session->hd_deflater); &session->hd_deflater);
@ -2190,13 +2182,6 @@ static int session_prep_frame(nghttp2_session *session,
nghttp2_stream *stream; nghttp2_stream *stream;
size_t estimated_payloadlen; size_t estimated_payloadlen;
estimated_payloadlen = session_estimate_headers_payload(
session, frame->push_promise.nva, frame->push_promise.nvlen, 0);
if (estimated_payloadlen > session->max_send_header_block_length) {
return NGHTTP2_ERR_FRAME_SIZE_ERROR;
}
/* stream could be NULL if associated stream was already /* stream could be NULL if associated stream was already
closed. */ closed. */
stream = nghttp2_session_get_stream(session, frame->hd.stream_id); stream = nghttp2_session_get_stream(session, frame->hd.stream_id);
@ -2209,6 +2194,13 @@ static int session_prep_frame(nghttp2_session *session,
assert(stream); assert(stream);
estimated_payloadlen = session_estimate_headers_payload(
session, frame->push_promise.nva, frame->push_promise.nvlen, 0);
if (estimated_payloadlen > session->max_send_header_block_length) {
return NGHTTP2_ERR_FRAME_SIZE_ERROR;
}
rv = nghttp2_frame_pack_push_promise( rv = nghttp2_frame_pack_push_promise(
&session->aob.framebufs, &frame->push_promise, &session->hd_deflater); &session->aob.framebufs, &frame->push_promise, &session->hd_deflater);
if (rv != 0) { if (rv != 0) {