#!/bin/sh
#
# Written by Dridi Boukelmoune <dridi.boukelmoune@gmail.com>
#
# This file is in the public domain.
#
# 8.1.2.  HTTP Header Fields
#
#    HTTP header fields carry information as a series of key-value pairs.
#    For a listing of registered HTTP headers, see the "Message Header
#    Field" registry maintained at <https://www.iana.org/assignments/
#    message-headers>.
#
#    Just as in HTTP/1.x, header field names are strings of ASCII
#    characters that are compared in a case-insensitive fashion.  However,
#    header field names MUST be converted to lowercase prior to their
#    encoding in HTTP/2.  A request or response containing uppercase
#    header field names MUST be treated as malformed (Section 8.1.2.6).
#
# 8.1.2.1.  Pseudo-Header Fields
#
#    While HTTP/1.x used the message start-line (see [RFC7230],
#    Section 3.1) to convey the target URI, the method of the request, and
#    the status code for the response, HTTP/2 uses special pseudo-header
#    fields beginning with ':' character (ASCII 0x3a) for this purpose.
#
#    [...]

. "$(dirname "$0")"/common.sh

_ -----------------------------------
_ Allow headers starting with a colon
_ -----------------------------------

mk_hex <<EOF
0005 3a70 6174 6801 2f                  | ..:path./
EOF

mk_msg <<EOF
:path: /
EOF

mk_tbl </dev/null

mk_enc <<EOF
literal str :path str /
EOF

tst_decode
tst_encode

_ ----------------------
_ Capitalized field name
_ ----------------------

mk_hex <<EOF
0004 4e61 6d65 0576 616c 7565           | ..Name.value
EOF

mk_enc <<EOF
literal str Name str value
EOF

HDECODE=hdecode # XXX: nghttp2 1.7.1 fails this test
tst_decode --expect-error CHR
tst_encode --expect-error CHR
