mirror of
https://github.com/apple/swift-http-structured-headers
synced 2026-11-24 04:37:50 +00:00
114 lines
3.3 KiB
JSON
114 lines
3.3 KiB
JSON
[
|
|
{
|
|
"name": "basic parameterised dict",
|
|
"raw": ["abc=123;a=1;b=2, def=456, ghi=789;q=9;r=\"+w\""],
|
|
"header_type": "dictionary",
|
|
"expected": {
|
|
"abc": [123, {"a": 1, "b": 2}],
|
|
"def": [456, {}],
|
|
"ghi": [789, {"q": 9, "r": "+w"}]
|
|
}
|
|
},
|
|
{
|
|
"name": "single item parameterised dict",
|
|
"raw": ["a=b; q=1.0"],
|
|
"header_type": "dictionary",
|
|
"expected": {
|
|
"a": [{"__type": "token", "value": "b"}, {"q": 1.0}]
|
|
},
|
|
"canonical": ["a=b;q=1.0"]
|
|
},
|
|
{
|
|
"name": "list item parameterised dictionary",
|
|
"raw": ["a=(1 2); q=1.0"],
|
|
"header_type": "dictionary",
|
|
"expected": {"a": [[[1, {}], [2, {}]], {"q": 1.0}]},
|
|
"canonical": ["a=(1 2);q=1.0"]
|
|
},
|
|
{
|
|
"name": "missing parameter value parameterised dict",
|
|
"raw": ["a=3;c;d=5"],
|
|
"header_type": "dictionary",
|
|
"expected": {
|
|
"a": [3, {"c": true, "d": 5}]
|
|
}
|
|
},
|
|
{
|
|
"name": "terminal missing parameter value parameterised dict",
|
|
"raw": ["a=3;c=5;d"],
|
|
"header_type": "dictionary",
|
|
"expected": {
|
|
"a": [3, {"c": 5, "d": true}]
|
|
}
|
|
},
|
|
{
|
|
"name": "no whitespace parameterised dict",
|
|
"raw": ["a=b;c=1,d=e;f=2"],
|
|
"header_type": "dictionary",
|
|
"expected": {
|
|
"a": [{"__type": "token", "value": "b"}, {"c": 1}],
|
|
"d": [{"__type": "token", "value": "e"}, {"f": 2}]
|
|
},
|
|
"canonical": ["a=b;c=1, d=e;f=2"]
|
|
},
|
|
{
|
|
"name": "whitespace before = parameterised dict",
|
|
"raw": ["a=b;q =0.5"],
|
|
"header_type": "dictionary",
|
|
"must_fail": true
|
|
},
|
|
{
|
|
"name": "whitespace after = parameterised dict",
|
|
"raw": ["a=b;q= 0.5"],
|
|
"header_type": "dictionary",
|
|
"must_fail": true
|
|
},
|
|
{
|
|
"name": "whitespace before ; parameterised dict",
|
|
"raw": ["a=b ;q=0.5"],
|
|
"header_type": "dictionary",
|
|
"must_fail": true
|
|
},
|
|
{
|
|
"name": "whitespace after ; parameterised dict",
|
|
"raw": ["a=b; q=0.5"],
|
|
"header_type": "dictionary",
|
|
"expected": {
|
|
"a": [{"__type": "token", "value": "b"}, {"q": 0.5}]
|
|
},
|
|
"canonical": ["a=b;q=0.5"]
|
|
},
|
|
{
|
|
"name": "extra whitespace parameterised dict",
|
|
"raw": ["a=b; c=1 , d=e; f=2; g=3"],
|
|
"header_type": "dictionary",
|
|
"expected": {
|
|
"a": [{"__type": "token", "value": "b"}, {"c": 1}],
|
|
"d": [{"__type": "token", "value": "e"}, {"f": 2, "g": 3}]
|
|
},
|
|
"canonical": ["a=b;c=1, d=e;f=2;g=3"]
|
|
},
|
|
{
|
|
"name": "two lines parameterised list",
|
|
"raw": ["a=b;c=1", "d=e;f=2"],
|
|
"header_type": "dictionary",
|
|
"expected": {
|
|
"a": [{"__type": "token", "value": "b"}, {"c": 1}],
|
|
"d": [{"__type": "token", "value": "e"}, {"f": 2}]
|
|
},
|
|
"canonical": ["a=b;c=1, d=e;f=2"]
|
|
},
|
|
{
|
|
"name": "trailing comma parameterised list",
|
|
"raw": ["a=b; q=1.0,"],
|
|
"header_type": "dictionary",
|
|
"must_fail": true
|
|
},
|
|
{
|
|
"name": "empty item parameterised list",
|
|
"raw": ["a=b; q=1.0,,c=d"],
|
|
"header_type": "dictionary",
|
|
"must_fail": true
|
|
}
|
|
]
|