diff --git a/python/hpackmake.py b/python/hpackmake.py index e3c8cc6c..bf1f62c8 100755 --- a/python/hpackmake.py +++ b/python/hpackmake.py @@ -15,7 +15,7 @@ import nghttp2 def testsuite(testdata, filename, outdir, table_size, deflate_table_size): res = { - 'draft':5, 'context': testdata['context'], + 'draft':6, 'description': '''\ Encoded by nghttp2. The basic encoding strategy is described in \ http://lists.w3.org/Archives/Public/ietf-http-wg/2013JulSep/1135.html \ @@ -28,7 +28,6 @@ result in less bits on the wire.''' deflater.change_table_size(table_size) for casenum, item in enumerate(testdata['cases']): outitem = { - 'header_table_size': table_size, 'headers': item['headers'] } casenum += 1 @@ -37,6 +36,10 @@ result in less bits on the wire.''' for x in item['headers']] outitem['wire'] = b2a_hex(deflater.deflate(hdrs)).decode('utf-8') cases.append(outitem) + + if cases: + cases[0]['header_table_size'] = table_size + res['cases'] = cases jsonstr = json.dumps(res, indent=2) with open(os.path.join(outdir, filename), 'w') as f: diff --git a/src/deflatehd.c b/src/deflatehd.c index cefa7118..ca2d6e2c 100644 --- a/src/deflatehd.c +++ b/src/deflatehd.c @@ -95,8 +95,11 @@ static void output_to_json(nghttp2_hd_deflater *deflater, json_object_set_new(obj, "wire", json_pack("s#", hex, len * 2)); } json_object_set_new(obj, "headers", dump_headers(nva, nvlen)); - json_object_set_new(obj, "header_table_size", - json_integer(config.table_size)); + if(seq == 0) { + /* We only change the header table size only once at the beginning */ + json_object_set_new(obj, "header_table_size", + json_integer(config.table_size)); + } if(config.dump_header_table) { json_object_set_new(obj, "header_table", dump_header_table(&deflater->ctx)); diff --git a/src/inflatehd.c b/src/inflatehd.c index 5fcf319d..2bdec0e8 100644 --- a/src/inflatehd.c +++ b/src/inflatehd.c @@ -67,7 +67,8 @@ static void decode_hex(uint8_t *dest, const char *src, size_t len) } static void to_json(nghttp2_hd_inflater *inflater, - json_t *headers, json_t *wire, int seq) + json_t *headers, json_t *wire, int seq, + size_t old_settings_table_size) { json_t *obj; @@ -75,8 +76,10 @@ static void to_json(nghttp2_hd_inflater *inflater, json_object_set_new(obj, "seq", json_integer(seq)); json_object_set(obj, "wire", wire); json_object_set(obj, "headers", headers); - json_object_set_new(obj, "header_table_size", - json_integer(inflater->ctx.hd_table_bufsize_max)); + if(old_settings_table_size != inflater->settings_hd_table_bufsize_max) { + json_object_set_new(obj, "header_table_size", + json_integer(inflater->settings_hd_table_bufsize_max)); + } if(config.dump_header_table) { json_object_set_new(obj, "header_table", dump_header_table(&inflater->ctx)); @@ -95,6 +98,7 @@ static int inflate_hd(json_t *obj, nghttp2_hd_inflater *inflater, int seq) ssize_t rv; nghttp2_nv nv; int inflate_flags; + size_t old_settings_table_size = inflater->settings_hd_table_bufsize_max; wire = json_object_get(obj, "wire"); if(wire == NULL) { @@ -149,7 +153,7 @@ static int inflate_hd(json_t *obj, nghttp2_hd_inflater *inflater, int seq) } assert(buflen == 0); nghttp2_hd_inflate_end_headers(inflater); - to_json(inflater, headers, wire, seq); + to_json(inflater, headers, wire, seq, old_settings_table_size); json_decref(headers); free(buf); return 0;