| 178 | |
| 179 | @composite |
| 180 | def h2_headers(draw): |
| 181 | required_headers = [ |
| 182 | [":path", "/"], |
| 183 | [":scheme", draw(sampled_from(["http", "https"]))], |
| 184 | [":method", draw(sampled_from(["GET", "POST", "CONNECT"]))], |
| 185 | ] |
| 186 | optional_headers = [ |
| 187 | [":authority", draw(sampled_from(["example.com:443", "example.com"]))], |
| 188 | ["cookie", "foobaz"], |
| 189 | ["host", "example.com"], |
| 190 | ["content-length", "42"], |
| 191 | ] |
| 192 | headers = required_headers + draw(lists(sampled_from(optional_headers), max_size=3)) |
| 193 | |
| 194 | i = draw(integers(0, len(headers))) |
| 195 | p = int(draw(booleans())) |
| 196 | r = draw(text()) |
| 197 | if i > 0: |
| 198 | headers[i - 1][p - 1] = r |
| 199 | return headers |
| 200 | |
| 201 | |
| 202 | @composite |