Commit 9683f88e authored by Tatsuhiro Tsujikawa's avatar Tatsuhiro Tsujikawa

Add NGHTTP2_DEFAULT_HEADER_TABLE_SIZE macro

Use this macro in Python sources.  Python module constant
HD_DEFLATE_HD_TABLE_BUFSIZE_MAX was renamed as
DEFLATE_MAX_HEADER_TABLE_SIZE since the previous name was awkward.
parent 2e5c7f59
......@@ -159,6 +159,12 @@ typedef struct {
*/
#define NGHTTP2_MAX_HEADER_TABLE_SIZE (1 << 28)
/**
* @macro
*
* The default header table size.
*/
#define NGHTTP2_DEFAULT_HEADER_TABLE_SIZE (1 << 12)
/**
* @macro
......
......@@ -34,7 +34,7 @@
#include "nghttp2_hd_huffman.h"
#include "nghttp2_buf.h"
#define NGHTTP2_HD_DEFAULT_MAX_BUFFER_SIZE (1 << 12)
#define NGHTTP2_HD_DEFAULT_MAX_BUFFER_SIZE NGHTTP2_DEFAULT_HEADER_TABLE_SIZE
#define NGHTTP2_HD_ENTRY_OVERHEAD 32
/* The maximum value length of name/value pair. This is not specified
......
......@@ -27,6 +27,7 @@ cdef extern from 'nghttp2/nghttp2.h':
const char NGHTTP2_PROTO_VERSION_ID[]
const char NGHTTP2_CLIENT_CONNECTION_PREFACE[]
const size_t NGHTTP2_INITIAL_WINDOW_SIZE
const size_t NGHTTP2_DEFAULT_HEADER_TABLE_SIZE
ctypedef struct nghttp2_session:
pass
......
......@@ -26,7 +26,7 @@ result in less bits on the wire.'''
cases = []
deflater = nghttp2.HDDeflater(deflate_table_size)
if table_size != 4096:
if table_size != nghttp2.DEFAULT_HEADER_TABLE_SIZE:
deflater.change_table_size(table_size)
for casenum, item in enumerate(testdata['cases']):
......@@ -41,7 +41,7 @@ result in less bits on the wire.'''
outitem['wire'] = b2a_hex(deflater.deflate(hdrs)).decode('utf-8')
cases.append(outitem)
if cases and table_size != 4096:
if cases and table_size != nghttp2.DEFAULT_HEADER_TABLE_SIZE:
cases[0]['header_table_size'] = table_size
res['cases'] = cases
......@@ -53,10 +53,10 @@ if __name__ == '__main__':
ap = argparse.ArgumentParser(description='HPACK test case generator')
ap.add_argument('-d', '--dir', help='output directory', default='out')
ap.add_argument('-s', '--table-size', help='max header table size',
type=int, default=4096)
type=int, default=nghttp2.DEFAULT_HEADER_TABLE_SIZE)
ap.add_argument('-S', '--deflate-table-size',
help='max header table size for deflater',
type=int, default=4096)
type=int, default=nghttp2.DEFLATE_MAX_HEADER_TABLE_SIZE)
ap.add_argument('file', nargs='*', help='input file')
args = ap.parse_args()
try:
......
......@@ -26,7 +26,8 @@ from libc.stdlib cimport malloc, free
from libc.string cimport memcpy, memset
from libc.stdint cimport uint8_t, uint16_t, uint32_t, int32_t
HD_DEFLATE_HD_TABLE_BUFSIZE_MAX = 4096
DEFAULT_HEADER_TABLE_SIZE = cnghttp2.NGHTTP2_DEFAULT_HEADER_TABLE_SIZE
DEFLATE_MAX_HEADER_TABLE_SIZE = 4096
HD_ENTRY_OVERHEAD = cnghttp2.NGHTTP2_HD_ENTRY_OVERHEAD
......@@ -83,8 +84,7 @@ cdef class HDDeflater:
cdef cnghttp2.nghttp2_hd_deflater _deflater
def __cinit__(self,
hd_table_bufsize_max = HD_DEFLATE_HD_TABLE_BUFSIZE_MAX):
def __cinit__(self, hd_table_bufsize_max = DEFLATE_MAX_HEADER_TABLE_SIZE):
rv = cnghttp2.nghttp2_hd_deflate_init2(&self._deflater,
hd_table_bufsize_max)
if rv != 0:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment