summaryrefslogtreecommitdiff
path: root/testdata.json
blob: 0aafd05c6b480402457b2d47bf608280886d622a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
{
    "parse_media_range": [
        ["application/xml;q=1", ["application", "xml", {"q": "1"}]],
        ["application/xml", ["application", "xml", {"q": "1"}]],
        ["application/xml;q=",["application", "xml", {"q": "1"}]],
        ["application/xml ;q=",["application", "xml", {"q": "1"}]],
        ["application/xml ;q=-1",["application", "xml", {"q": "1"}]],
        ["application/xml ; q=1;b=other",["application", "xml", {"q": "1", "b":"other"}]],
        ["application/xml ; q=2;b=other",["application", "xml", {"q": "1", "b":"other"}]],
        ["application/xml ; q=0",["application", "xml", {"q": "0"}]],
        ["application/xml ; q=foo", ["application", "xml", {"q": "1"}]],
        ["application/xml ; Q=0.6", ["application", "xml", {"q": "0.6"}]],
        [" *; q=.2", ["*", "*", {"q": ".2"}]]
    ],

    "quality": [
        [
            [
                "text/html;level=1",
                "text/*;q=0.3, text/html;q=0.7, text/html;level=1, text/html;level=2;q=0.4, */*;q=0.5"
            ],
            1
        ],
        [
            [
                "text/html",
                "text/*;q=0.3, text/html;q=0.7, text/html;level=1, text/html;level=2;q=0.4, */*;q=0.5"
            ],
            0.7
        ],
        [
            [
                "text/plain",
                "text/*;q=0.3, text/html;q=0.7, text/html;level=1, text/html;level=2;q=0.4, */*;q=0.5"
            ],
            0.3
        ],
        [
            [
                "image/jpeg",
                "text/*;q=0.3, text/html;q=0.7, text/html;level=1, text/html;level=2;q=0.4, */*;q=0.5"
            ],
            0.5
        ],
        [
            [
                "text/html;level=2",
                "text/*;q=0.3, text/html;q=0.7, text/html;level=1, text/html;level=2;q=0.4, */*;q=0.5"
            ],
            0.4
        ],
        [
            [
                "text/html;level=3",
                "text/*;q=0.3, text/html;q=0.7, text/html;level=1, text/html;level=2;q=0.4, */*;q=0.5"
            ],
            0.7
        ],
        [
            [
                "text/plain",
                "text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2"
            ],
            0.2
        ]
    ],

    "best_match": [
        [
            [
                ["application/json", "text/html"],
                "application/json, text/javascript, */*"
            ],
            "application/json",
            "common AJAX scenario"
        ],
        [
            [
                ["application/xbel+xml", "application/xml"],
                "application/xbel+xml"
            ],
            "application/xbel+xml",
            "direct match"
        ],
        [
            [
                ["application/xbel+xml", "application/xml"],
                "application/xbel+xml; q=1"
            ],
            "application/xbel+xml",
            "direct match with a q parameter"
        ],
        [
            [
                ["application/xbel+xml", "application/xml"],
                "application/xml; q=1"
            ],
            "application/xml",
            "direct match of our second choice with a q parameter"
        ],
        [
            [
                ["application/xbel+xml", "application/xml"],
                "application/*; q=1"
            ],
            "application/xml",
            "match using a subtype wildcard"
        ],
        [
            [
                ["application/xbel+xml", "application/xml"],
                "*/*"
            ],
            "application/xml",
            "match using a type wildcard"
        ],
        [
            [
                ["application/xbel+xml", "text/xml"],
                "text/*;q=0.5,*/*; q=0.1"
            ],
            "text/xml",
            "match using a type versus a lower weighted subtype"
        ],
        [
            [
                ["application/xbel+xml", "text/xml"],
                "text/html,application/atom+xml; q=0.9"
            ],
            "",
            "fail to match anything"
        ],
        [
            [
                ["application/json", "text/html"],
                "application/json, text/html;q=0.9"
            ],
            "application/json",
            "verify fitness ordering"
        ],
        [
            [
                ["image/*", "application/xml"],
                "image/png"
            ],
            "image/*",
            "match using a type wildcard"
        ],
        [
            [
                ["image/*", "application/xml"],
                "image/*"
            ],
            "image/*",
            "match using a wildcard for both requested and supported"
        ],
        [
            [
                ["image/jpeg", "text/plain"],
                "text/*;q=0.3, text/html;q=0.7, text/html;level=1, text/html;level=2;q=0.4, */*;q=0.5"
            ],
            "image/jpeg",
            "media type with highest associated quality factor should win, not necessarily most specific"
        ],
        [
            [
                ["text/html", "application/rdf+xml"],
                "text/html, application/rdf+xml"
            ],
            "application/rdf+xml",
            "match should use highest order of supported when there is a tie"
        ],
        [
            [
                ["text/plain", "text/plain;format=flowed", "text/html"],
                "text/*, text/plain, text/plain;format=flowed, */*"
            ],
            "text/plain;format=flowed",
            "most specific reference has precedence"
        ],
        [
            [
                ["application/rdf+xml", "text/html"],
                "text/html, application/rdf+xml"
            ],
            "text/html",
            "match should use highest order of supported when there is a tie"
        ],
        [
            [
                ["application/json;q=1.0", "text/html;q=0.9", "text/plain;q=0.1"],
                "*/*"
            ],
            "application/json;q=1.0",
            "*/* match should pick an acceptable type with the highest quality"
        ],
        [
            [
                ["application/json", "text/html"],
                "text"
            ],
            null,
            "match should use the default if an invalid Accept header is passed"
        ]
    ],

    "parse_mime_type": [
        [
            "application/xhtml;q=0.5",
            ["application", "xhtml", {"q": "0.5"}]
        ],
        [
            "application/xhtml;q=0.5;ver=1.2",
            ["application", "xhtml", {"q": "0.5", "ver": "1.2"}]
        ],
        [
            "application/xhtml;q=0.5;foo=\"bar quux\"",
            ["application", "xhtml", {"q": "0.5", "foo": "bar quux"}]],
        [
            "text", null
        ],
        [
            "text/something/invalid", null
        ]
    ]
}