diff --git a/lib/nghttp2_frame.h b/lib/nghttp2_frame.h index 5f6152b7..ecc1e3ba 100644 --- a/lib/nghttp2_frame.h +++ b/lib/nghttp2_frame.h @@ -53,7 +53,7 @@ (NGHTTP2_FRAME_HDLEN + 1 + NGHTTP2_MAX_PAYLOADLEN) /* The default length of DATA frame payload. */ -#define NGHTTP2_DATA_PAYLOADLEN NGHTTP2_MAX_FRAME_SIZE_MIN +#define NGHTTP2_DATA_PAYLOADLEN 256*1024 /* Maximum headers block size to send, calculated using nghttp2_hd_deflate_bound(). This is the default value, and can be diff --git a/lib/nghttp2_session.c b/lib/nghttp2_session.c index 93f3f07c..5a4222fa 100644 --- a/lib/nghttp2_session.c +++ b/lib/nghttp2_session.c @@ -7748,6 +7748,21 @@ int nghttp2_session_pack_data(nghttp2_session *session, nghttp2_bufs *bufs, datamax = (size_t)payloadlen; } + if ((size_t)datamax > nghttp2_buf_avail(buf)) { + /* Resize the current buffer(s). The reason why we do +1 for + buffer size is for possible padding field. */ + rv = nghttp2_bufs_realloc(&session->aob.framebufs, + (size_t)(NGHTTP2_FRAME_HDLEN + 1 + datamax)); + + if (rv != 0) { + DEBUGF("send: realloc buffer failed rv=%d", rv); + } else { + assert(&session->aob.framebufs == bufs); + + buf = &bufs->cur->buf; + } + } + /* Current max DATA length is less then buffer chunk size */ assert(nghttp2_buf_avail(buf) >= datamax); diff --git a/src/HttpServer.h b/src/HttpServer.h index cde34798..69155808 100644 --- a/src/HttpServer.h +++ b/src/HttpServer.h @@ -205,7 +205,7 @@ public: struct ev_loop *get_loop() const; - using WriteBuf = Buffer<64_k>; + using WriteBuf = Buffer<512_k>; // This needs to be >= largest frame sent, or frame is not sent WriteBuf *get_wb();