Update doc
This commit is contained in:
parent
da9bbb58fb
commit
fd07247a48
751
README.rst
751
README.rst
|
@ -152,56 +152,56 @@ output from ``nghttp`` client::
|
||||||
|
|
||||||
$ src/nghttp -vn https://localhost:8443
|
$ src/nghttp -vn https://localhost:8443
|
||||||
[ 0.003] NPN select next protocol: the remote server offers:
|
[ 0.003] NPN select next protocol: the remote server offers:
|
||||||
* HTTP-draft-09/2.0
|
* HTTP-draft-09/2.0
|
||||||
* spdy/3
|
* spdy/3
|
||||||
* spdy/2
|
* spdy/2
|
||||||
* http/1.1
|
* http/1.1
|
||||||
NPN selected the protocol: HTTP-draft-09/2.0
|
NPN selected the protocol: HTTP-draft-09/2.0
|
||||||
[ 0.005] send SETTINGS frame <length=16, flags=0x00, stream_id=0>
|
[ 0.005] send SETTINGS frame <length=16, flags=0x00, stream_id=0>
|
||||||
(niv=2)
|
(niv=2)
|
||||||
[SETTINGS_MAX_CONCURRENT_STREAMS(4):100]
|
[SETTINGS_MAX_CONCURRENT_STREAMS(4):100]
|
||||||
[SETTINGS_INITIAL_WINDOW_SIZE(7):65535]
|
[SETTINGS_INITIAL_WINDOW_SIZE(7):65535]
|
||||||
[ 0.006] send HEADERS frame <length=47, flags=0x05, stream_id=1>
|
[ 0.006] send HEADERS frame <length=47, flags=0x05, stream_id=1>
|
||||||
; END_STREAM | END_HEADERS
|
; END_STREAM | END_HEADERS
|
||||||
; Open new stream
|
; Open new stream
|
||||||
:authority: localhost:8443
|
:authority: localhost:8443
|
||||||
:method: GET
|
:method: GET
|
||||||
:path: /
|
:path: /
|
||||||
:scheme: https
|
:scheme: https
|
||||||
accept: */*
|
accept: */*
|
||||||
accept-encoding: gzip, deflate
|
accept-encoding: gzip, deflate
|
||||||
user-agent: nghttp2/0.1.0-DEV
|
user-agent: nghttp2/0.1.0-DEV
|
||||||
[ 0.006] recv SETTINGS frame <length=16, flags=0x00, stream_id=0>
|
[ 0.006] recv SETTINGS frame <length=16, flags=0x00, stream_id=0>
|
||||||
(niv=2)
|
(niv=2)
|
||||||
[SETTINGS_MAX_CONCURRENT_STREAMS(4):100]
|
[SETTINGS_MAX_CONCURRENT_STREAMS(4):100]
|
||||||
[SETTINGS_INITIAL_WINDOW_SIZE(7):65535]
|
[SETTINGS_INITIAL_WINDOW_SIZE(7):65535]
|
||||||
[ 0.006] send SETTINGS frame <length=0, flags=0x01, stream_id=0>
|
[ 0.006] send SETTINGS frame <length=0, flags=0x01, stream_id=0>
|
||||||
; ACK
|
; ACK
|
||||||
(niv=0)
|
(niv=0)
|
||||||
[ 0.006] recv WINDOW_UPDATE frame <length=4, flags=0x00, stream_id=0>
|
[ 0.006] recv WINDOW_UPDATE frame <length=4, flags=0x00, stream_id=0>
|
||||||
(window_size_increment=1000000007)
|
(window_size_increment=1000000007)
|
||||||
[ 0.006] recv SETTINGS frame <length=0, flags=0x01, stream_id=0>
|
[ 0.006] recv SETTINGS frame <length=0, flags=0x01, stream_id=0>
|
||||||
; ACK
|
; ACK
|
||||||
(niv=0)
|
(niv=0)
|
||||||
[ 0.006] recv HEADERS frame <length=132, flags=0x04, stream_id=1>
|
[ 0.006] recv HEADERS frame <length=132, flags=0x04, stream_id=1>
|
||||||
; END_HEADERS
|
; END_HEADERS
|
||||||
; First response header
|
; First response header
|
||||||
:status: 200
|
:status: 200
|
||||||
accept-ranges: bytes
|
accept-ranges: bytes
|
||||||
content-encoding: gzip
|
content-encoding: gzip
|
||||||
content-length: 146
|
content-length: 146
|
||||||
content-type: text/html
|
content-type: text/html
|
||||||
date: Sun, 27 Oct 2013 14:23:54 GMT
|
date: Sun, 27 Oct 2013 14:23:54 GMT
|
||||||
etag: "b1-4e5535a027780-gzip"
|
etag: "b1-4e5535a027780-gzip"
|
||||||
last-modified: Sun, 01 Sep 2013 14:34:22 GMT
|
last-modified: Sun, 01 Sep 2013 14:34:22 GMT
|
||||||
server: Apache/2.4.6 (Debian)
|
server: Apache/2.4.6 (Debian)
|
||||||
vary: Accept-Encoding
|
vary: Accept-Encoding
|
||||||
via: 1.1 nghttpx
|
via: 1.1 nghttpx
|
||||||
[ 0.006] recv DATA frame <length=146, flags=0x00, stream_id=1>
|
[ 0.006] recv DATA frame <length=146, flags=0x00, stream_id=1>
|
||||||
[ 0.006] recv DATA frame <length=0, flags=0x01, stream_id=1>
|
[ 0.006] recv DATA frame <length=0, flags=0x01, stream_id=1>
|
||||||
; END_STREAM
|
; END_STREAM
|
||||||
[ 0.007] send GOAWAY frame <length=8, flags=0x00, stream_id=0>
|
[ 0.007] send GOAWAY frame <length=8, flags=0x00, stream_id=0>
|
||||||
(last_stream_id=0, error_code=NO_ERROR(0), opaque_data(0)=[])
|
(last_stream_id=0, error_code=NO_ERROR(0), opaque_data(0)=[])
|
||||||
|
|
||||||
The HTTP Upgrade is performed like this::
|
The HTTP Upgrade is performed like this::
|
||||||
|
|
||||||
|
@ -224,39 +224,39 @@ The HTTP Upgrade is performed like this::
|
||||||
|
|
||||||
[ 0.001] HTTP Upgrade success
|
[ 0.001] HTTP Upgrade success
|
||||||
[ 0.001] send SETTINGS frame <length=16, flags=0x00, stream_id=0>
|
[ 0.001] send SETTINGS frame <length=16, flags=0x00, stream_id=0>
|
||||||
(niv=2)
|
(niv=2)
|
||||||
[SETTINGS_MAX_CONCURRENT_STREAMS(4):100]
|
[SETTINGS_MAX_CONCURRENT_STREAMS(4):100]
|
||||||
[SETTINGS_INITIAL_WINDOW_SIZE(7):65535]
|
[SETTINGS_INITIAL_WINDOW_SIZE(7):65535]
|
||||||
[ 0.001] recv SETTINGS frame <length=16, flags=0x00, stream_id=0>
|
[ 0.001] recv SETTINGS frame <length=16, flags=0x00, stream_id=0>
|
||||||
(niv=2)
|
(niv=2)
|
||||||
[SETTINGS_MAX_CONCURRENT_STREAMS(4):100]
|
[SETTINGS_MAX_CONCURRENT_STREAMS(4):100]
|
||||||
[SETTINGS_INITIAL_WINDOW_SIZE(7):65535]
|
[SETTINGS_INITIAL_WINDOW_SIZE(7):65535]
|
||||||
[ 0.001] recv WINDOW_UPDATE frame <length=4, flags=0x00, stream_id=0>
|
[ 0.001] recv WINDOW_UPDATE frame <length=4, flags=0x00, stream_id=0>
|
||||||
(window_size_increment=1000000007)
|
(window_size_increment=1000000007)
|
||||||
[ 0.001] recv HEADERS frame <length=121, flags=0x04, stream_id=1>
|
[ 0.001] recv HEADERS frame <length=121, flags=0x04, stream_id=1>
|
||||||
; END_HEADERS
|
; END_HEADERS
|
||||||
; First response header
|
; First response header
|
||||||
:status: 200
|
:status: 200
|
||||||
accept-ranges: bytes
|
accept-ranges: bytes
|
||||||
content-length: 177
|
content-length: 177
|
||||||
content-type: text/html
|
content-type: text/html
|
||||||
date: Sun, 27 Oct 2013 14:26:04 GMT
|
date: Sun, 27 Oct 2013 14:26:04 GMT
|
||||||
etag: "b1-4e5535a027780"
|
etag: "b1-4e5535a027780"
|
||||||
last-modified: Sun, 01 Sep 2013 14:34:22 GMT
|
last-modified: Sun, 01 Sep 2013 14:34:22 GMT
|
||||||
server: Apache/2.4.6 (Debian)
|
server: Apache/2.4.6 (Debian)
|
||||||
vary: Accept-Encoding
|
vary: Accept-Encoding
|
||||||
via: 1.1 nghttpx
|
via: 1.1 nghttpx
|
||||||
[ 0.001] recv DATA frame <length=177, flags=0x00, stream_id=1>
|
[ 0.001] recv DATA frame <length=177, flags=0x00, stream_id=1>
|
||||||
[ 0.001] recv DATA frame <length=0, flags=0x01, stream_id=1>
|
[ 0.001] recv DATA frame <length=0, flags=0x01, stream_id=1>
|
||||||
; END_STREAM
|
; END_STREAM
|
||||||
[ 0.001] send SETTINGS frame <length=0, flags=0x01, stream_id=0>
|
[ 0.001] send SETTINGS frame <length=0, flags=0x01, stream_id=0>
|
||||||
; ACK
|
; ACK
|
||||||
(niv=0)
|
(niv=0)
|
||||||
[ 0.001] send GOAWAY frame <length=8, flags=0x00, stream_id=0>
|
[ 0.001] send GOAWAY frame <length=8, flags=0x00, stream_id=0>
|
||||||
(last_stream_id=0, error_code=NO_ERROR(0), opaque_data(0)=[])
|
(last_stream_id=0, error_code=NO_ERROR(0), opaque_data(0)=[])
|
||||||
[ 0.001] recv SETTINGS frame <length=0, flags=0x01, stream_id=0>
|
[ 0.001] recv SETTINGS frame <length=0, flags=0x01, stream_id=0>
|
||||||
; ACK
|
; ACK
|
||||||
(niv=0)
|
(niv=0)
|
||||||
|
|
||||||
nghttpd - server
|
nghttpd - server
|
||||||
++++++++++++++++
|
++++++++++++++++
|
||||||
|
@ -279,42 +279,42 @@ information. Here is sample output from ``nghttpd`` server::
|
||||||
IPv4: listen on port 8080
|
IPv4: listen on port 8080
|
||||||
IPv6: listen on port 8080
|
IPv6: listen on port 8080
|
||||||
[id=1] [ 1.189] send SETTINGS frame <length=8, flags=0x00, stream_id=0>
|
[id=1] [ 1.189] send SETTINGS frame <length=8, flags=0x00, stream_id=0>
|
||||||
(niv=1)
|
(niv=1)
|
||||||
[SETTINGS_MAX_CONCURRENT_STREAMS(4):100]
|
[SETTINGS_MAX_CONCURRENT_STREAMS(4):100]
|
||||||
[id=1] [ 1.191] recv SETTINGS frame <length=16, flags=0x00, stream_id=0>
|
[id=1] [ 1.191] recv SETTINGS frame <length=16, flags=0x00, stream_id=0>
|
||||||
(niv=2)
|
(niv=2)
|
||||||
[SETTINGS_MAX_CONCURRENT_STREAMS(4):100]
|
[SETTINGS_MAX_CONCURRENT_STREAMS(4):100]
|
||||||
[SETTINGS_INITIAL_WINDOW_SIZE(7):65535]
|
[SETTINGS_INITIAL_WINDOW_SIZE(7):65535]
|
||||||
[id=1] [ 1.191] recv HEADERS frame <length=47, flags=0x05, stream_id=1>
|
[id=1] [ 1.191] recv HEADERS frame <length=47, flags=0x05, stream_id=1>
|
||||||
; END_STREAM | END_HEADERS
|
; END_STREAM | END_HEADERS
|
||||||
; Open new stream
|
; Open new stream
|
||||||
:authority: localhost:8080
|
:authority: localhost:8080
|
||||||
:method: GET
|
:method: GET
|
||||||
:path: /
|
:path: /
|
||||||
:scheme: http
|
:scheme: http
|
||||||
accept: */*
|
accept: */*
|
||||||
accept-encoding: gzip, deflate
|
accept-encoding: gzip, deflate
|
||||||
user-agent: nghttp2/0.1.0-DEV
|
user-agent: nghttp2/0.1.0-DEV
|
||||||
[id=1] [ 1.192] send SETTINGS frame <length=0, flags=0x01, stream_id=0>
|
[id=1] [ 1.192] send SETTINGS frame <length=0, flags=0x01, stream_id=0>
|
||||||
; ACK
|
; ACK
|
||||||
(niv=0)
|
(niv=0)
|
||||||
[id=1] [ 1.192] send HEADERS frame <length=70, flags=0x04, stream_id=1>
|
[id=1] [ 1.192] send HEADERS frame <length=70, flags=0x04, stream_id=1>
|
||||||
; END_HEADERS
|
; END_HEADERS
|
||||||
; First response header
|
; First response header
|
||||||
:status: 404
|
:status: 404
|
||||||
content-encoding: gzip
|
content-encoding: gzip
|
||||||
content-type: text/html; charset=UTF-8
|
content-type: text/html; charset=UTF-8
|
||||||
date: Sun, 27 Oct 2013 14:27:53 GMT
|
date: Sun, 27 Oct 2013 14:27:53 GMT
|
||||||
server: nghttpd nghttp2/0.1.0-DEV
|
server: nghttpd nghttp2/0.1.0-DEV
|
||||||
[id=1] [ 1.192] send DATA frame <length=117, flags=0x00, stream_id=1>
|
[id=1] [ 1.192] send DATA frame <length=117, flags=0x00, stream_id=1>
|
||||||
[id=1] [ 1.192] send DATA frame <length=0, flags=0x01, stream_id=1>
|
[id=1] [ 1.192] send DATA frame <length=0, flags=0x01, stream_id=1>
|
||||||
; END_STREAM
|
; END_STREAM
|
||||||
[id=1] [ 1.192] stream_id=1 closed
|
[id=1] [ 1.192] stream_id=1 closed
|
||||||
[id=1] [ 1.192] recv SETTINGS frame <length=0, flags=0x01, stream_id=0>
|
[id=1] [ 1.192] recv SETTINGS frame <length=0, flags=0x01, stream_id=0>
|
||||||
; ACK
|
; ACK
|
||||||
(niv=0)
|
(niv=0)
|
||||||
[id=1] [ 1.192] recv GOAWAY frame <length=8, flags=0x00, stream_id=0>
|
[id=1] [ 1.192] recv GOAWAY frame <length=8, flags=0x00, stream_id=0>
|
||||||
(last_stream_id=0, error_code=NO_ERROR(0), opaque_data(0)=[])
|
(last_stream_id=0, error_code=NO_ERROR(0), opaque_data(0)=[])
|
||||||
[id=1] [ 1.192] closed
|
[id=1] [ 1.192] closed
|
||||||
|
|
||||||
nghttpx - proxy
|
nghttpx - proxy
|
||||||
|
@ -429,41 +429,45 @@ The ``src`` directory contains HPACK tools. The ``deflatehd`` is
|
||||||
command-line header compression tool. The ``inflatehd`` is
|
command-line header compression tool. The ``inflatehd`` is
|
||||||
command-line header decompression tool. Both tools read input from
|
command-line header decompression tool. Both tools read input from
|
||||||
stdin and write output to stdout. The errors are written to
|
stdin and write output to stdout. The errors are written to
|
||||||
stderr. They take JSON as input and output.
|
stderr. They take JSON as input and output. We use the same JSON data
|
||||||
|
format used in https://github.com/Jxck/hpack-test-case
|
||||||
|
|
||||||
deflatehd - header compressor
|
deflatehd - header compressor
|
||||||
+++++++++++++++++++++++++++++
|
+++++++++++++++++++++++++++++
|
||||||
|
|
||||||
The ``deflatehd`` reads JSON array or HTTP/1-style header fields from
|
The ``deflatehd`` reads JSON data or HTTP/1-style header fields from
|
||||||
stdin and outputs compressed header block in JSON array.
|
stdin and outputs compressed header block in JSON.
|
||||||
|
|
||||||
For the JSON input, the element of input array must be a JSON
|
For the JSON input, the root JSON object must contain ``context`` key,
|
||||||
object. Each object must have at least following key:
|
which indicates which compression context is used. If it is
|
||||||
|
``request``, request compression context is used. Otherwise, response
|
||||||
headers
|
compression context is used. The value of ``cases`` key contains the
|
||||||
A JSON array of name/value pairs. The each element is a JSON array
|
sequence of input header set. They share the same compression context
|
||||||
of 2 strings. The index 0 must contain header name and the index 1
|
and are processed in the order they appear. Each item in the sequence
|
||||||
must contain header value.
|
is a JSON object and it must have at least ``headers`` key. Its value
|
||||||
|
is an array of a JSON object containing exactly one name/value pair.
|
||||||
|
|
||||||
Example::
|
Example::
|
||||||
|
|
||||||
[
|
{
|
||||||
{
|
"context": "request",
|
||||||
"headers": [
|
"cases":
|
||||||
[ ":method", "GET" ],
|
[
|
||||||
[ ":path", "/" ]
|
{
|
||||||
]
|
"headers": [
|
||||||
},
|
{ ":method": "GET" },
|
||||||
{
|
{ ":path": "/" }
|
||||||
"headers": [
|
]
|
||||||
[ ":method", "POST" ],
|
},
|
||||||
[ ":path", "/" ]
|
{
|
||||||
]
|
"headers": [
|
||||||
}
|
{ ":method": "POST" },
|
||||||
]
|
{ ":path": "/" }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
These header sets are processed in the order they appear in the JSON
|
|
||||||
outer most array using same compression context.
|
|
||||||
|
|
||||||
With ``-t`` option, the program can accept more familiar HTTP/1 style
|
With ``-t`` option, the program can accept more familiar HTTP/1 style
|
||||||
header field block. Each header set is delimited by empty line:
|
header field block. Each header set is delimited by empty line:
|
||||||
|
@ -477,46 +481,97 @@ Example::
|
||||||
:method: POST
|
:method: POST
|
||||||
user-agent: nghttp2
|
user-agent: nghttp2
|
||||||
|
|
||||||
The output is a JSON array and each element is JSON object, which has
|
The output is JSON object. It contains ``context`` key and its value
|
||||||
at least following keys:
|
is ``request`` if the compression context is request, otherwise
|
||||||
|
``response``. The root JSON object also contains ``cases`` key and its
|
||||||
|
value is an array of JSON object, which has at least following keys:
|
||||||
|
|
||||||
seq
|
seq
|
||||||
The index of header set in the input.
|
The index of header set in the input.
|
||||||
|
|
||||||
inputLen
|
input_length
|
||||||
The sum of length of name/value pair in the input.
|
The sum of length of name/value pair in the input.
|
||||||
|
|
||||||
outputLength
|
output_length
|
||||||
The length of compressed header block.
|
The length of compressed header block.
|
||||||
|
|
||||||
percentageOfOriginalSize
|
percentage_of_original_size
|
||||||
inputLen / outputLength * 100
|
``input_length`` / ``output_length`` * 100
|
||||||
|
|
||||||
output
|
wire
|
||||||
The compressed header block in hex string.
|
The compressed header block in hex string.
|
||||||
|
|
||||||
|
headers
|
||||||
|
The input header set.
|
||||||
|
|
||||||
|
header_table_size
|
||||||
|
The header table size adjsuted before deflating header set.
|
||||||
|
|
||||||
Examples::
|
Examples::
|
||||||
|
|
||||||
[
|
{
|
||||||
{
|
"context": "request",
|
||||||
"seq": 0,
|
"cases":
|
||||||
"inputLen": 66,
|
[
|
||||||
"outputLength": 20,
|
{
|
||||||
"percentageOfOriginalSize": 30.303030303030305,
|
"seq": 0,
|
||||||
"output": "818703881f3468e5891afcbf863c856659c62e3f"
|
"input_length": 66,
|
||||||
},
|
"output_length": 20,
|
||||||
{
|
"percentage_of_original_size": 30.303030303030305,
|
||||||
"seq": 1,
|
"wire": "01881f3468e5891afcbf83868a3d856659c62e3f",
|
||||||
"inputLen": 74,
|
"headers": [
|
||||||
"outputLength": 10,
|
{
|
||||||
"percentageOfOriginalSize": 13.513513513513514,
|
":authority": "example.org"
|
||||||
"output": "87038504252dd5918386"
|
},
|
||||||
}
|
{
|
||||||
]
|
":method": "GET"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
":path": "/"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
":scheme": "https"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"user-agent": "nghttp2"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"header_table_size": 4096
|
||||||
|
}
|
||||||
|
,
|
||||||
|
{
|
||||||
|
"seq": 1,
|
||||||
|
"input_length": 74,
|
||||||
|
"output_length": 10,
|
||||||
|
"percentage_of_original_size": 13.513513513513514,
|
||||||
|
"wire": "88448504252dd5918485",
|
||||||
|
"headers": [
|
||||||
|
{
|
||||||
|
":authority": "example.org"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
":method": "POST"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
":path": "/account"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
":scheme": "https"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"user-agent": "nghttp2"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"header_table_size": 4096
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
The output can be used as the input for ``inflatehd``.
|
|
||||||
|
|
||||||
With ``-d`` option, the extra ``headerTable`` key is added and its
|
The output can be used as the input for ``inflatehd`` and
|
||||||
|
``deflatehd``.
|
||||||
|
|
||||||
|
With ``-d`` option, the extra ``header_table`` key is added and its
|
||||||
associated value contains the state of dyanmic header table after the
|
associated value contains the state of dyanmic header table after the
|
||||||
corresponding header set was processed. The value contains following
|
corresponding header set was processed. The value contains following
|
||||||
keys:
|
keys:
|
||||||
|
@ -535,196 +590,276 @@ size
|
||||||
The sum of the spaces entries occupied, this includes the
|
The sum of the spaces entries occupied, this includes the
|
||||||
entry overhead.
|
entry overhead.
|
||||||
|
|
||||||
maxSize
|
max_size
|
||||||
The maximum header table size.
|
The maximum header table size.
|
||||||
|
|
||||||
deflateSize
|
deflate_size
|
||||||
The sum of the spaces entries occupied within ``maxDeflateSize``.
|
The sum of the spaces entries occupied within
|
||||||
|
``max_deflate_size``.
|
||||||
|
|
||||||
maxDeflateSize
|
max_deflate_size
|
||||||
The maximum header table size encoder uses. This can be smaller
|
The maximum header table size encoder uses. This can be smaller
|
||||||
than ``maxSize``. In this case, encoder only uses up to first
|
than ``max_size``. In this case, encoder only uses up to first
|
||||||
``maxDeflateSize`` buffer. Since the header table size is still
|
``max_deflate_size`` buffer. Since the header table size is still
|
||||||
``maxSize``, the encoder has to keep track of entries ouside the
|
``max_size``, the encoder has to keep track of entries ouside the
|
||||||
``maxDeflateSize`` but inside the ``maxSize`` and make sure that
|
``max_deflate_size`` but inside the ``max_size`` and make sure
|
||||||
they are no longer referenced.
|
that they are no longer referenced.
|
||||||
|
|
||||||
Example::
|
Example::
|
||||||
|
|
||||||
[
|
{
|
||||||
{
|
"context": "request",
|
||||||
"seq": 0,
|
"cases":
|
||||||
"inputLen": 66,
|
[
|
||||||
"outputLength": 20,
|
{
|
||||||
"percentageOfOriginalSize": 30.303030303030305,
|
"seq": 0,
|
||||||
"output": "818703881f3468e5891afcbf863c856659c62e3f",
|
"input_length": 66,
|
||||||
"headerTable": {
|
"output_length": 20,
|
||||||
"entries": [
|
"percentage_of_original_size": 30.303030303030305,
|
||||||
{
|
"wire": "01881f3468e5891afcbf83868a3d856659c62e3f",
|
||||||
"index": 0,
|
"headers": [
|
||||||
"name": "user-agent",
|
{
|
||||||
"value": "nghttp2",
|
":authority": "example.org"
|
||||||
"referenced": true,
|
},
|
||||||
"size": 49
|
{
|
||||||
},
|
":method": "GET"
|
||||||
{
|
},
|
||||||
"index": 1,
|
{
|
||||||
"name": ":path",
|
":path": "/"
|
||||||
"value": "/",
|
},
|
||||||
"referenced": true,
|
{
|
||||||
"size": 38
|
":scheme": "https"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"index": 2,
|
"user-agent": "nghttp2"
|
||||||
"name": ":authority",
|
}
|
||||||
"value": "example.org",
|
],
|
||||||
"referenced": true,
|
"header_table_size": 4096,
|
||||||
"size": 53
|
"header_table": {
|
||||||
},
|
"entries": [
|
||||||
{
|
{
|
||||||
"index": 3,
|
"index": 1,
|
||||||
"name": ":scheme",
|
"name": "user-agent",
|
||||||
"value": "https",
|
"value": "nghttp2",
|
||||||
"referenced": true,
|
"referenced": true,
|
||||||
"size": 44
|
"size": 49
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"index": 4,
|
"index": 2,
|
||||||
"name": ":method",
|
"name": ":scheme",
|
||||||
"value": "GET",
|
"value": "https",
|
||||||
"referenced": true,
|
"referenced": true,
|
||||||
"size": 42
|
"size": 44
|
||||||
}
|
},
|
||||||
],
|
{
|
||||||
"size": 226,
|
"index": 3,
|
||||||
"maxSize": 4096,
|
"name": ":path",
|
||||||
"deflateSize": 226,
|
"value": "/",
|
||||||
"maxDeflateSize": 4096
|
"referenced": true,
|
||||||
}
|
"size": 38
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"seq": 1,
|
"index": 4,
|
||||||
"inputLen": 74,
|
"name": ":method",
|
||||||
"outputLength": 10,
|
"value": "GET",
|
||||||
"percentageOfOriginalSize": 13.513513513513514,
|
"referenced": true,
|
||||||
"output": "87038504252dd5918386",
|
"size": 42
|
||||||
"headerTable": {
|
},
|
||||||
"entries": [
|
{
|
||||||
{
|
"index": 5,
|
||||||
"index": 0,
|
"name": ":authority",
|
||||||
"name": ":path",
|
"value": "example.org",
|
||||||
"value": "/account",
|
"referenced": true,
|
||||||
"referenced": true,
|
"size": 53
|
||||||
"size": 45
|
}
|
||||||
},
|
],
|
||||||
{
|
"size": 226,
|
||||||
"index": 1,
|
"max_size": 4096,
|
||||||
"name": ":method",
|
"deflate_size": 226,
|
||||||
"value": "POST",
|
"max_deflate_size": 4096
|
||||||
"referenced": true,
|
}
|
||||||
"size": 43
|
}
|
||||||
},
|
,
|
||||||
{
|
{
|
||||||
"index": 2,
|
"seq": 1,
|
||||||
"name": "user-agent",
|
"input_length": 74,
|
||||||
"value": "nghttp2",
|
"output_length": 10,
|
||||||
"referenced": true,
|
"percentage_of_original_size": 13.513513513513514,
|
||||||
"size": 49
|
"wire": "88448504252dd5918485",
|
||||||
},
|
"headers": [
|
||||||
{
|
{
|
||||||
"index": 3,
|
":authority": "example.org"
|
||||||
"name": ":path",
|
},
|
||||||
"value": "/",
|
{
|
||||||
"referenced": false,
|
":method": "POST"
|
||||||
"size": 38
|
},
|
||||||
},
|
{
|
||||||
{
|
":path": "/account"
|
||||||
"index": 4,
|
},
|
||||||
"name": ":authority",
|
{
|
||||||
"value": "example.org",
|
":scheme": "https"
|
||||||
"referenced": true,
|
},
|
||||||
"size": 53
|
{
|
||||||
},
|
"user-agent": "nghttp2"
|
||||||
{
|
}
|
||||||
"index": 5,
|
],
|
||||||
"name": ":scheme",
|
"header_table_size": 4096,
|
||||||
"value": "https",
|
"header_table": {
|
||||||
"referenced": true,
|
"entries": [
|
||||||
"size": 44
|
{
|
||||||
},
|
"index": 1,
|
||||||
{
|
"name": ":method",
|
||||||
"index": 6,
|
"value": "POST",
|
||||||
"name": ":method",
|
"referenced": true,
|
||||||
"value": "GET",
|
"size": 43
|
||||||
"referenced": false,
|
},
|
||||||
"size": 42
|
{
|
||||||
}
|
"index": 2,
|
||||||
],
|
"name": "user-agent",
|
||||||
"size": 314,
|
"value": "nghttp2",
|
||||||
"maxSize": 4096,
|
"referenced": true,
|
||||||
"deflateSize": 314,
|
"size": 49
|
||||||
"maxDeflateSize": 4096
|
},
|
||||||
}
|
{
|
||||||
}
|
"index": 3,
|
||||||
]
|
"name": ":scheme",
|
||||||
|
"value": "https",
|
||||||
|
"referenced": true,
|
||||||
|
"size": 44
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"index": 4,
|
||||||
|
"name": ":path",
|
||||||
|
"value": "/",
|
||||||
|
"referenced": false,
|
||||||
|
"size": 38
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"index": 5,
|
||||||
|
"name": ":method",
|
||||||
|
"value": "GET",
|
||||||
|
"referenced": false,
|
||||||
|
"size": 42
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"index": 6,
|
||||||
|
"name": ":authority",
|
||||||
|
"value": "example.org",
|
||||||
|
"referenced": true,
|
||||||
|
"size": 53
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"size": 269,
|
||||||
|
"max_size": 4096,
|
||||||
|
"deflate_size": 269,
|
||||||
|
"max_deflate_size": 4096
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
inflatehd - header decompressor
|
inflatehd - header decompressor
|
||||||
+++++++++++++++++++++++++++++++
|
+++++++++++++++++++++++++++++++
|
||||||
|
|
||||||
The ``inflatehd`` reads JSON array from stdin and outputs decompressed
|
The ``inflatehd`` reads JSON data from stdin and outputs decompressed
|
||||||
name/value pairs in JSON array. The element of input array must be a
|
name/value pairs in JSON.
|
||||||
JSON object. Each object must have at least following key:
|
|
||||||
|
|
||||||
output
|
The root JSON object must contain ``context`` key, which indicates
|
||||||
compressed header block in hex string.
|
which compression context is used. If it is ``request``, request
|
||||||
|
compression context is used. Otherwise, response compression context
|
||||||
|
is used. The value of ``cases`` key contains the sequence of
|
||||||
|
compressed header block. They share the same compression context and
|
||||||
|
are processed in the order they appear. Each item in the sequence is a
|
||||||
|
JSON object and it must have at least ``wire`` key. Its value is a
|
||||||
|
string containing compressed header block in hex string.
|
||||||
|
|
||||||
Example::
|
Example::
|
||||||
|
|
||||||
[
|
{
|
||||||
{ "output": "0284f77778ff" },
|
"context": "request",
|
||||||
{ "output": "0185fafd3c3c7f81" }
|
"cases":
|
||||||
]
|
[
|
||||||
|
{ "wire": "8285" },
|
||||||
|
{ "wire": "8583" }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
The output is a JSON array and each element is JSON object, which has
|
The output is JSON object. It contains ``context`` key and its value
|
||||||
at least following keys:
|
is ``request`` if the compression context is request, otherwise
|
||||||
|
``response``. The root JSON object also contains ``cases`` key and its
|
||||||
|
value is an array of JSON object, which has at least following keys:
|
||||||
|
|
||||||
seq
|
seq
|
||||||
The index of header set in the input.
|
The index of header set in the input.
|
||||||
|
|
||||||
headers
|
headers
|
||||||
The JSON array contains decompressed name/value pairs. Each
|
The JSON array contains decompressed name/value pairs.
|
||||||
element is JSON aray having 2 elements. The index 0 of the array
|
|
||||||
contains the header field name. The index 1 contains the header
|
wire
|
||||||
field value.
|
The compressed header block in hex string.
|
||||||
|
|
||||||
|
header_table_size
|
||||||
|
The header table size adjsuted before inflating compressed header
|
||||||
|
block.
|
||||||
|
|
||||||
Example::
|
Example::
|
||||||
|
|
||||||
[
|
{
|
||||||
{
|
"context": "request",
|
||||||
"seq": 0,
|
"cases":
|
||||||
"headers": [
|
[
|
||||||
[":authority", "example.org"],
|
{
|
||||||
[":method", "GET"],
|
"seq": 0,
|
||||||
[":path", "/"],
|
"wire": "01881f3468e5891afcbf83868a3d856659c62e3f",
|
||||||
[":scheme", "https"],
|
"headers": [
|
||||||
["user-agent", "nghttp2"]
|
{
|
||||||
]
|
":authority": "example.org"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"seq": 1,
|
":method": "GET"
|
||||||
"headers": [
|
},
|
||||||
[":authority", "example.org"],
|
{
|
||||||
[":method", "POST"],
|
":path": "/"
|
||||||
[":path", "/account"],
|
},
|
||||||
[":scheme", "https"],
|
{
|
||||||
["user-agent", "nghttp2"]
|
":scheme": "https"
|
||||||
]
|
},
|
||||||
}
|
{
|
||||||
]
|
"user-agent": "nghttp2"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"header_table_size": 4096
|
||||||
|
}
|
||||||
|
,
|
||||||
|
{
|
||||||
|
"seq": 1,
|
||||||
|
"wire": "88448504252dd5918485",
|
||||||
|
"headers": [
|
||||||
|
{
|
||||||
|
":method": "POST"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
":path": "/account"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"user-agent": "nghttp2"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
":scheme": "https"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
":authority": "example.org"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"header_table_size": 4096
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
The output can be used as the input for ``deflatehd``.
|
The output can be used as the input for ``deflatehd`` and
|
||||||
|
``inflatehd``.
|
||||||
|
|
||||||
With ``-d`` option, the extra ``headerTable`` key is added and its
|
With ``-d`` option, the extra ``header_table`` key is added and its
|
||||||
associated value contains the state of dyanmic header table after the
|
associated value contains the state of dyanmic header table after the
|
||||||
corresponding header set was processed. The format is the same as
|
corresponding header set was processed. The format is the same as
|
||||||
``deflatehd``.
|
``deflatehd``.
|
||||||
|
@ -759,7 +894,7 @@ and decompressor in Python:
|
||||||
inflater = nghttp2.HDInflater(nghttp2.HD_SIDE_REQUEST)
|
inflater = nghttp2.HDInflater(nghttp2.HD_SIDE_REQUEST)
|
||||||
|
|
||||||
data = deflater.deflate([(b'foo', b'bar'),
|
data = deflater.deflate([(b'foo', b'bar'),
|
||||||
(b'baz', b'buz')])
|
(b'baz', b'buz')])
|
||||||
print(binascii.b2a_hex(data))
|
print(binascii.b2a_hex(data))
|
||||||
|
|
||||||
hdrs = inflater.inflate(data)
|
hdrs = inflater.inflate(data)
|
||||||
|
|
Loading…
Reference in New Issue