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.
This commit is contained in:
parent
2e5c7f598f
commit
9683f88e6a
|
@ -159,6 +159,12 @@ typedef struct {
|
||||||
*/
|
*/
|
||||||
#define NGHTTP2_MAX_HEADER_TABLE_SIZE (1 << 28)
|
#define NGHTTP2_MAX_HEADER_TABLE_SIZE (1 << 28)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @macro
|
||||||
|
*
|
||||||
|
* The default header table size.
|
||||||
|
*/
|
||||||
|
#define NGHTTP2_DEFAULT_HEADER_TABLE_SIZE (1 << 12)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @macro
|
* @macro
|
||||||
|
|
|
@ -34,7 +34,7 @@
|
||||||
#include "nghttp2_hd_huffman.h"
|
#include "nghttp2_hd_huffman.h"
|
||||||
#include "nghttp2_buf.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
|
#define NGHTTP2_HD_ENTRY_OVERHEAD 32
|
||||||
|
|
||||||
/* The maximum value length of name/value pair. This is not specified
|
/* 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_PROTO_VERSION_ID[]
|
||||||
const char NGHTTP2_CLIENT_CONNECTION_PREFACE[]
|
const char NGHTTP2_CLIENT_CONNECTION_PREFACE[]
|
||||||
const size_t NGHTTP2_INITIAL_WINDOW_SIZE
|
const size_t NGHTTP2_INITIAL_WINDOW_SIZE
|
||||||
|
const size_t NGHTTP2_DEFAULT_HEADER_TABLE_SIZE
|
||||||
|
|
||||||
ctypedef struct nghttp2_session:
|
ctypedef struct nghttp2_session:
|
||||||
pass
|
pass
|
||||||
|
|
|
@ -26,7 +26,7 @@ result in less bits on the wire.'''
|
||||||
cases = []
|
cases = []
|
||||||
deflater = nghttp2.HDDeflater(deflate_table_size)
|
deflater = nghttp2.HDDeflater(deflate_table_size)
|
||||||
|
|
||||||
if table_size != 4096:
|
if table_size != nghttp2.DEFAULT_HEADER_TABLE_SIZE:
|
||||||
deflater.change_table_size(table_size)
|
deflater.change_table_size(table_size)
|
||||||
|
|
||||||
for casenum, item in enumerate(testdata['cases']):
|
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')
|
outitem['wire'] = b2a_hex(deflater.deflate(hdrs)).decode('utf-8')
|
||||||
cases.append(outitem)
|
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
|
cases[0]['header_table_size'] = table_size
|
||||||
|
|
||||||
res['cases'] = cases
|
res['cases'] = cases
|
||||||
|
@ -53,10 +53,10 @@ if __name__ == '__main__':
|
||||||
ap = argparse.ArgumentParser(description='HPACK test case generator')
|
ap = argparse.ArgumentParser(description='HPACK test case generator')
|
||||||
ap.add_argument('-d', '--dir', help='output directory', default='out')
|
ap.add_argument('-d', '--dir', help='output directory', default='out')
|
||||||
ap.add_argument('-s', '--table-size', help='max header table size',
|
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',
|
ap.add_argument('-S', '--deflate-table-size',
|
||||||
help='max header table size for deflater',
|
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')
|
ap.add_argument('file', nargs='*', help='input file')
|
||||||
args = ap.parse_args()
|
args = ap.parse_args()
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -26,7 +26,8 @@ from libc.stdlib cimport malloc, free
|
||||||
from libc.string cimport memcpy, memset
|
from libc.string cimport memcpy, memset
|
||||||
from libc.stdint cimport uint8_t, uint16_t, uint32_t, int32_t
|
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
|
HD_ENTRY_OVERHEAD = cnghttp2.NGHTTP2_HD_ENTRY_OVERHEAD
|
||||||
|
|
||||||
|
@ -83,8 +84,7 @@ cdef class HDDeflater:
|
||||||
|
|
||||||
cdef cnghttp2.nghttp2_hd_deflater _deflater
|
cdef cnghttp2.nghttp2_hd_deflater _deflater
|
||||||
|
|
||||||
def __cinit__(self,
|
def __cinit__(self, hd_table_bufsize_max = DEFLATE_MAX_HEADER_TABLE_SIZE):
|
||||||
hd_table_bufsize_max = HD_DEFLATE_HD_TABLE_BUFSIZE_MAX):
|
|
||||||
rv = cnghttp2.nghttp2_hd_deflate_init2(&self._deflater,
|
rv = cnghttp2.nghttp2_hd_deflate_init2(&self._deflater,
|
||||||
hd_table_bufsize_max)
|
hd_table_bufsize_max)
|
||||||
if rv != 0:
|
if rv != 0:
|
||||||
|
|
Loading…
Reference in New Issue