| 1 |
|
| #include "EXTERN.h" |
| 2 |
|
| #include "perl.h" |
| 3 |
|
| #include "XSUB.h" |
| 4 |
|
| #include "uniform_http_fastpath.h" |
| 5 |
|
| #include "lib/Unblock/HTTP3/NativeABI/unblock_http3_consumer.h" |
| 6 |
|
| |
| 7 |
|
| #include <nghttp3/nghttp3.h> |
| 8 |
|
| |
| 9 |
|
| #include <inttypes.h> |
| 10 |
|
| #include <string.h> |
| 11 |
|
| |
| 12 |
|
| #define UNBLOCK_HTTP3_MAX_VARINT UINT64_C(0x3fffffffffffffff) |
| 13 |
|
| |
| 14 |
|
| typedef struct { |
| 15 |
|
| uhttp_native_api uniform_api; |
| 16 |
|
| } my_cxt_t; |
| 17 |
|
| |
| 18 |
|
| START_MY_CXT |
| 19 |
|
| |
| 20 |
|
| typedef struct unblock_http3_body_chunk { |
| 21 |
|
| SV *storage; |
| 22 |
|
| uint8_t *data; |
| 23 |
|
| size_t len; |
| 24 |
|
| size_t acked; |
| 25 |
|
| int supplied; |
| 26 |
|
| struct unblock_http3_body_chunk *next; |
| 27 |
|
| } unblock_http3_body_chunk; |
| 28 |
|
| |
| 29 |
|
| typedef struct unblock_http3_body { |
| 30 |
|
| int64_t stream_id; |
| 31 |
|
| int streaming; |
| 32 |
|
| int eof; |
| 33 |
|
| uint64_t discarded_unacked; |
| 34 |
|
| size_t retained_bytes; |
| 35 |
|
| unblock_http3_body_chunk *head; |
| 36 |
|
| unblock_http3_body_chunk *tail; |
| 37 |
|
| struct unblock_http3_body *next; |
| 38 |
|
| } unblock_http3_body; |
| 39 |
|
| |
| 40 |
|
| typedef struct { |
| 41 |
|
| uint8_t *name; |
| 42 |
|
| size_t namelen; |
| 43 |
|
| uint8_t *value; |
| 44 |
|
| size_t valuelen; |
| 45 |
|
| } unblock_http3_captured_field; |
| 46 |
|
| |
| 47 |
|
| typedef struct unblock_http3_header_block { |
| 48 |
|
| int64_t stream_id; |
| 49 |
|
| unblock_http3_captured_field *fields; |
| 50 |
|
| size_t count; |
| 51 |
|
| size_t capacity; |
| 52 |
|
| size_t field_section_size; |
| 53 |
|
| struct unblock_http3_header_block *next; |
| 54 |
|
| } unblock_http3_header_block; |
| 55 |
|
| |
| 56 |
|
| typedef struct { |
| 57 |
|
| nghttp3_conn *conn; |
| 58 |
|
| AV *events; |
| 59 |
|
| uint8_t *origin_list_data; |
| 60 |
|
| nghttp3_vec origin_list; |
| 61 |
|
| unblock_http3_body *bodies; |
| 62 |
|
| unblock_http3_header_block *header_blocks; |
| 63 |
|
| size_t streaming_retained_bytes; |
| 64 |
|
| int is_server; |
| 65 |
|
| int fatal; |
| 66 |
|
| } unblock_http3_native_conn; |
| 67 |
|
| |
| 68 |
|
| |
| 69 |
|
| static void |
| 70 |
79 |
| unblock_http3_header_block_free(unblock_http3_header_block *block) |
| 71 |
|
| { |
| 72 |
|
| size_t i; |
| 73 |
|
| |
| 74 |
79 |
▶ | if (block == NULL) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (block == NULL) { |
8 |
71 |
79 |
|
| 75 |
8 |
| return; |
| 76 |
|
| } |
| 77 |
|
| |
| 78 |
71 |
▶ | if (block->fields != NULL) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (block->fields != NULL) { |
71 |
0 |
71 |
|
| 79 |
284 |
▶ | for (i = 0; i < block->count; ++i) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (i = 0; i < block->count; ++i) { |
213 |
71 |
284 |
|
| 80 |
213 |
▶ | if (block->fields[i].name != NULL) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (block->fields[i].name != NULL) { |
213 |
0 |
213 |
|
| 81 |
213 |
| Safefree(block->fields[i].name); |
| 82 |
|
| } |
| 83 |
213 |
▶ | if (block->fields[i].value != NULL) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (block->fields[i].value != NULL) { |
213 |
0 |
213 |
|
| 84 |
213 |
| Safefree(block->fields[i].value); |
| 85 |
|
| } |
| 86 |
|
| } |
| 87 |
|
| |
| 88 |
71 |
| Safefree(block->fields); |
| 89 |
|
| } |
| 90 |
|
| |
| 91 |
71 |
| Safefree(block); |
| 92 |
|
| } |
| 93 |
|
| |
| 94 |
|
| static unblock_http3_header_block * |
| 95 |
706 |
| unblock_http3_header_block_find( |
| 96 |
|
| unblock_http3_native_conn *native, |
| 97 |
|
| int64_t stream_id |
| 98 |
|
| ) |
| 99 |
|
| { |
| 100 |
|
| unblock_http3_header_block *block; |
| 101 |
|
| |
| 102 |
706 |
| for ( |
| 103 |
706 |
| block = native->header_blocks; |
| 104 |
706 |
▶ | block != NULL; |
Branch: 1 branch
| Branch | True | False | Total |
| block != NULL; |
635 |
71 |
706 |
|
| 105 |
0 |
| block = block->next |
| 106 |
|
| ) { |
| 107 |
635 |
▶ | if (block->stream_id == stream_id) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (block->stream_id == stream_id) { |
635 |
0 |
635 |
|
| 108 |
635 |
| return block; |
| 109 |
|
| } |
| 110 |
|
| } |
| 111 |
|
| |
| 112 |
71 |
| return NULL; |
| 113 |
|
| } |
| 114 |
|
| |
| 115 |
|
| static unblock_http3_header_block * |
| 116 |
71 |
| unblock_http3_header_block_create( |
| 117 |
|
| unblock_http3_native_conn *native, |
| 118 |
|
| int64_t stream_id |
| 119 |
|
| ) |
| 120 |
|
| { |
| 121 |
|
| unblock_http3_header_block *block; |
| 122 |
|
| |
| 123 |
71 |
▶ | if (unblock_http3_header_block_find(native, stream_id) != NULL) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (unblock_http3_header_block_find(native, stream_id) != NULL) { |
0 |
71 |
71 |
|
| 124 |
0 |
| croak("HTTP/3 stream already has an active header block"); |
| 125 |
|
| } |
| 126 |
|
| |
| 127 |
71 |
| Newxz(block, 1, unblock_http3_header_block); |
| 128 |
71 |
| block->stream_id = stream_id; |
| 129 |
71 |
| block->next = native->header_blocks; |
| 130 |
71 |
| native->header_blocks = block; |
| 131 |
|
| |
| 132 |
71 |
| return block; |
| 133 |
|
| } |
| 134 |
|
| |
| 135 |
|
| static void |
| 136 |
213 |
| unblock_http3_header_block_append( |
| 137 |
|
| unblock_http3_header_block *block, |
| 138 |
|
| const uint8_t *name, |
| 139 |
|
| size_t namelen, |
| 140 |
|
| const uint8_t *value, |
| 141 |
|
| size_t valuelen |
| 142 |
|
| ) |
| 143 |
|
| { |
| 144 |
|
| unblock_http3_captured_field *field; |
| 145 |
|
| size_t next_size; |
| 146 |
|
| |
| 147 |
213 |
▶ | if (block == NULL) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (block == NULL) { |
0 |
213 |
213 |
|
| 148 |
0 |
| croak("HTTP/3 header arrived without an active header block"); |
| 149 |
|
| } |
| 150 |
|
| |
| 151 |
213 |
▶ | if (block->count == block->capacity) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (block->count == block->capacity) { |
72 |
141 |
213 |
|
| 152 |
144 |
| size_t capacity = block->capacity == 0 |
| 153 |
|
| ? 8 |
| 154 |
72 |
▶ | : block->capacity * 2; |
Branch: 1 branch
| Branch | True | False | Total |
| : block->capacity * 2; |
1 |
71 |
72 |
|
| 155 |
|
| |
| 156 |
72 |
▶ | if (capacity < block->capacity) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (capacity < block->capacity) { |
0 |
72 |
72 |
|
| 157 |
0 |
| croak("HTTP/3 header block capacity overflow"); |
| 158 |
|
| } |
| 159 |
|
| |
| 160 |
72 |
▶ | if (block->fields == NULL) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (block->fields == NULL) { |
71 |
1 |
72 |
|
| 161 |
71 |
▶ | Newxz( |
Branch: 1 branch
| Branch | True | False | Total |
| Newxz( |
0 |
71 |
71 |
|
| 162 |
|
| block->fields, |
| 163 |
|
| capacity, |
| 164 |
|
| unblock_http3_captured_field |
| 165 |
|
| ); |
| 166 |
|
| } else { |
| 167 |
1 |
| size_t old_capacity = block->capacity; |
| 168 |
|
| |
| 169 |
1 |
▶ | Renew( |
Branch: 1 branch
| Branch | True | False | Total |
| Renew( |
0 |
1 |
1 |
|
| 170 |
|
| block->fields, |
| 171 |
|
| capacity, |
| 172 |
|
| unblock_http3_captured_field |
| 173 |
|
| ); |
| 174 |
1 |
▶ | Zero( |
Branch: 1 branch
| Branch | True | False | Total |
| Zero( |
0 |
1 |
1 |
|
| 175 |
|
| block->fields + old_capacity, |
| 176 |
|
| capacity - old_capacity, |
| 177 |
|
| unblock_http3_captured_field |
| 178 |
|
| ); |
| 179 |
|
| } |
| 180 |
|
| |
| 181 |
72 |
| block->capacity = capacity; |
| 182 |
|
| } |
| 183 |
|
| |
| 184 |
213 |
| field = &block->fields[block->count]; |
| 185 |
|
| |
| 186 |
213 |
▶ | Newx(field->name, namelen ? namelen : 1, uint8_t); |
Branch: 1 branch
| Branch | True | False | Total |
| Newx(field->name, namelen ? namelen : 1, uint8_t); |
213 |
0 |
213 |
|
| 187 |
213 |
▶ | Newx(field->value, valuelen ? valuelen : 1, uint8_t); |
Branch: 1 branch
| Branch | True | False | Total |
| Newx(field->value, valuelen ? valuelen : 1, uint8_t); |
213 |
0 |
213 |
|
| 188 |
|
| |
| 189 |
213 |
▶ | if (namelen) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (namelen) { |
213 |
0 |
213 |
|
| 190 |
213 |
| Copy(name, field->name, namelen, uint8_t); |
| 191 |
|
| } |
| 192 |
|
| |
| 193 |
213 |
▶ | if (valuelen) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (valuelen) { |
213 |
0 |
213 |
|
| 194 |
213 |
| Copy(value, field->value, valuelen, uint8_t); |
| 195 |
|
| } |
| 196 |
|
| |
| 197 |
213 |
| field->namelen = namelen; |
| 198 |
213 |
| field->valuelen = valuelen; |
| 199 |
213 |
| ++block->count; |
| 200 |
|
| |
| 201 |
213 |
| if ( |
| 202 |
213 |
▶ | block->field_section_size > (size_t)-1 - namelen |
Branch: 1 branch
| Branch | True | False | Total |
| block->field_section_size > (size_t)-1 - namelen |
213 |
0 |
213 |
|
| 203 |
213 |
▶ | || block->field_section_size + namelen > (size_t)-1 - valuelen |
Branch: 1 branch
| Branch | True | False | Total |
| || block->field_section_size + namelen > (size_t)-1 - valuelen |
213 |
0 |
213 |
|
| 204 |
213 |
▶ | || block->field_section_size + namelen + valuelen > (size_t)-1 - 32 |
Branch: 1 branch
| Branch | True | False | Total |
| || block->field_section_size + namelen + valuelen > (size_t)-1 - 32 |
0 |
213 |
213 |
|
| 205 |
|
| ) { |
| 206 |
0 |
| croak("HTTP/3 field section size overflow"); |
| 207 |
|
| } |
| 208 |
|
| |
| 209 |
213 |
| next_size = |
| 210 |
213 |
| block->field_section_size |
| 211 |
213 |
| + namelen |
| 212 |
213 |
| + valuelen |
| 213 |
|
| + 32; |
| 214 |
213 |
| block->field_section_size = next_size; |
| 215 |
213 |
| } |
| 216 |
|
| |
| 217 |
|
| static unblock_http3_header_block * |
| 218 |
76 |
| unblock_http3_header_block_remove( |
| 219 |
|
| unblock_http3_native_conn *native, |
| 220 |
|
| int64_t stream_id |
| 221 |
|
| ) |
| 222 |
|
| { |
| 223 |
76 |
| unblock_http3_header_block **link = &native->header_blocks; |
| 224 |
|
| |
| 225 |
76 |
▶ | while (*link != NULL) { |
Branch: 1 branch
| Branch | True | False | Total |
| while (*link != NULL) { |
68 |
8 |
76 |
|
| 226 |
68 |
| unblock_http3_header_block *block = *link; |
| 227 |
|
| |
| 228 |
68 |
▶ | if (block->stream_id != stream_id) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (block->stream_id != stream_id) { |
0 |
68 |
68 |
|
| 229 |
0 |
| link = &block->next; |
| 230 |
0 |
| continue; |
| 231 |
|
| } |
| 232 |
|
| |
| 233 |
68 |
| *link = block->next; |
| 234 |
68 |
| block->next = NULL; |
| 235 |
68 |
| return block; |
| 236 |
|
| } |
| 237 |
|
| |
| 238 |
8 |
| return NULL; |
| 239 |
|
| } |
| 240 |
|
| |
| 241 |
|
| static void |
| 242 |
63 |
| unblock_http3_header_block_free_all( |
| 243 |
|
| unblock_http3_native_conn *native |
| 244 |
|
| ) |
| 245 |
|
| { |
| 246 |
63 |
| unblock_http3_header_block *block = native->header_blocks; |
| 247 |
|
| |
| 248 |
66 |
▶ | while (block != NULL) { |
Branch: 1 branch
| Branch | True | False | Total |
| while (block != NULL) { |
3 |
63 |
66 |
|
| 249 |
3 |
| unblock_http3_header_block *next = block->next; |
| 250 |
3 |
| unblock_http3_header_block_free(block); |
| 251 |
3 |
| block = next; |
| 252 |
|
| } |
| 253 |
|
| |
| 254 |
63 |
| native->header_blocks = NULL; |
| 255 |
63 |
| } |
| 256 |
|
| |
| 257 |
|
| static int |
| 258 |
840 |
| unblock_http3_captured_name_equal( |
| 259 |
|
| const unblock_http3_captured_field *field, |
| 260 |
|
| const char *name, |
| 261 |
|
| size_t namelen |
| 262 |
|
| ) |
| 263 |
|
| { |
| 264 |
840 |
| return field->namelen == namelen |
| 265 |
840 |
▶ | && memcmp(field->name, name, namelen) == 0; |
Branch: 2 branches
| Branch | True | False | Total |
| && memcmp(field->name, name, namelen) == 0; |
253 |
587 |
840 |
| && memcmp(field->name, name, namelen) == 0; |
181 |
72 |
253 |
|
| 266 |
|
| } |
| 267 |
|
| |
| 268 |
|
| static int |
| 269 |
58 |
| unblock_http3_captured_name_equal_ci( |
| 270 |
|
| const unblock_http3_captured_field *field, |
| 271 |
|
| const char *name, |
| 272 |
|
| size_t namelen |
| 273 |
|
| ) |
| 274 |
|
| { |
| 275 |
|
| size_t i; |
| 276 |
|
| |
| 277 |
58 |
▶ | if (field->namelen != namelen) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (field->namelen != namelen) { |
40 |
18 |
58 |
|
| 278 |
40 |
| return 0; |
| 279 |
|
| } |
| 280 |
|
| |
| 281 |
144 |
▶ | for (i = 0; i < namelen; ++i) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (i = 0; i < namelen; ++i) { |
126 |
18 |
144 |
|
| 282 |
126 |
| uint8_t left = field->name[i]; |
| 283 |
126 |
| uint8_t right = (uint8_t)name[i]; |
| 284 |
|
| |
| 285 |
126 |
▶ | if (left >= 'A' && left <= 'Z') { |
Branch: 2 branches
| Branch | True | False | Total |
| if (left >= 'A' && left <= 'Z') { |
124 |
2 |
126 |
| if (left >= 'A' && left <= 'Z') { |
0 |
124 |
124 |
|
| 286 |
0 |
| left = (uint8_t)(left + ('a' - 'A')); |
| 287 |
|
| } |
| 288 |
|
| |
| 289 |
126 |
▶ | if (right >= 'A' && right <= 'Z') { |
Branch: 2 branches
| Branch | True | False | Total |
| if (right >= 'A' && right <= 'Z') { |
124 |
2 |
126 |
| if (right >= 'A' && right <= 'Z') { |
0 |
124 |
124 |
|
| 290 |
0 |
| right = (uint8_t)(right + ('a' - 'A')); |
| 291 |
|
| } |
| 292 |
|
| |
| 293 |
126 |
▶ | if (left != right) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (left != right) { |
0 |
126 |
126 |
|
| 294 |
0 |
| return 0; |
| 295 |
|
| } |
| 296 |
|
| } |
| 297 |
|
| |
| 298 |
18 |
| return 1; |
| 299 |
|
| } |
| 300 |
|
| |
| 301 |
|
| static const unblock_http3_captured_field * |
| 302 |
216 |
| unblock_http3_header_block_pseudo( |
| 303 |
|
| const unblock_http3_header_block *block, |
| 304 |
|
| const char *name, |
| 305 |
|
| size_t namelen |
| 306 |
|
| ) |
| 307 |
|
| { |
| 308 |
216 |
| const unblock_http3_captured_field *found = NULL; |
| 309 |
|
| size_t i; |
| 310 |
|
| |
| 311 |
1056 |
▶ | for (i = 0; i < block->count; ++i) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (i = 0; i < block->count; ++i) { |
840 |
216 |
1056 |
|
| 312 |
840 |
▶ | if ( |
Branch: 1 branch
| Branch | True | False | Total |
| if ( |
181 |
659 |
840 |
|
| 313 |
840 |
| unblock_http3_captured_name_equal( |
| 314 |
840 |
| &block->fields[i], |
| 315 |
|
| name, |
| 316 |
|
| namelen |
| 317 |
|
| ) |
| 318 |
|
| ) { |
| 319 |
181 |
| found = &block->fields[i]; |
| 320 |
|
| } |
| 321 |
|
| } |
| 322 |
|
| |
| 323 |
216 |
| return found; |
| 324 |
|
| } |
| 325 |
|
| |
| 326 |
|
| static size_t |
| 327 |
67 |
| unblock_http3_header_block_regular_count( |
| 328 |
|
| const unblock_http3_header_block *block |
| 329 |
|
| ) |
| 330 |
|
| { |
| 331 |
|
| size_t i; |
| 332 |
67 |
| size_t count = 0; |
| 333 |
|
| |
| 334 |
262 |
▶ | for (i = 0; i < block->count; ++i) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (i = 0; i < block->count; ++i) { |
195 |
67 |
262 |
|
| 335 |
195 |
| if ( |
| 336 |
195 |
▶ | block->fields[i].namelen == 0 |
Branch: 1 branch
| Branch | True | False | Total |
| block->fields[i].namelen == 0 |
195 |
0 |
195 |
|
| 337 |
195 |
▶ | || block->fields[i].name[0] != ':' |
Branch: 1 branch
| Branch | True | False | Total |
| || block->fields[i].name[0] != ':' |
18 |
177 |
195 |
|
| 338 |
|
| ) { |
| 339 |
18 |
| ++count; |
| 340 |
|
| } |
| 341 |
|
| } |
| 342 |
|
| |
| 343 |
67 |
| return count; |
| 344 |
|
| } |
| 345 |
|
| |
| 346 |
|
| static void |
| 347 |
67 |
| unblock_http3_header_block_uniform_fields( |
| 348 |
|
| pTHX_ const unblock_http3_header_block *block, |
| 349 |
|
| uhttp_native_field **pfields, |
| 350 |
|
| Size_t *pcount, |
| 351 |
|
| uint8_t **pcookie |
| 352 |
|
| ) |
| 353 |
|
| { |
| 354 |
|
| size_t regular_count = |
| 355 |
67 |
| unblock_http3_header_block_regular_count(block); |
| 356 |
67 |
| size_t cookie_count = 0; |
| 357 |
67 |
| size_t cookie_length = 0; |
| 358 |
67 |
| size_t first_cookie = (size_t)-1; |
| 359 |
|
| size_t i; |
| 360 |
67 |
| size_t out_index = 0; |
| 361 |
67 |
| uhttp_native_field *fields = NULL; |
| 362 |
67 |
| uint8_t *cookie = NULL; |
| 363 |
|
| |
| 364 |
262 |
▶ | for (i = 0; i < block->count; ++i) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (i = 0; i < block->count; ++i) { |
195 |
67 |
262 |
|
| 365 |
195 |
| const unblock_http3_captured_field *field = |
| 366 |
195 |
| &block->fields[i]; |
| 367 |
|
| |
| 368 |
195 |
| if ( |
| 369 |
195 |
▶ | field->namelen != 0 |
Branch: 1 branch
| Branch | True | False | Total |
| field->namelen != 0 |
195 |
0 |
195 |
|
| 370 |
195 |
▶ | && field->name[0] == ':' |
Branch: 1 branch
| Branch | True | False | Total |
| && field->name[0] == ':' |
177 |
18 |
195 |
|
| 371 |
|
| ) { |
| 372 |
177 |
| continue; |
| 373 |
|
| } |
| 374 |
|
| |
| 375 |
18 |
▶ | if ( |
Branch: 1 branch
| Branch | True | False | Total |
| if ( |
5 |
13 |
18 |
|
| 376 |
18 |
| unblock_http3_captured_name_equal_ci( |
| 377 |
|
| field, |
| 378 |
|
| "cookie", |
| 379 |
|
| 6 |
| 380 |
|
| ) |
| 381 |
|
| ) { |
| 382 |
5 |
▶ | if (first_cookie == (size_t)-1) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (first_cookie == (size_t)-1) { |
2 |
3 |
5 |
|
| 383 |
2 |
| first_cookie = i; |
| 384 |
|
| } |
| 385 |
|
| |
| 386 |
5 |
| if ( |
| 387 |
5 |
▶ | cookie_length > (size_t)-1 - field->valuelen |
Branch: 1 branch
| Branch | True | False | Total |
| cookie_length > (size_t)-1 - field->valuelen |
5 |
0 |
5 |
|
| 388 |
5 |
▶ | || ( |
Branch: 1 branch
| Branch | True | False | Total |
| || ( |
3 |
2 |
5 |
|
| 389 |
|
| cookie_count != 0 |
| 390 |
3 |
▶ | && cookie_length + field->valuelen |
Branch: 1 branch
| Branch | True | False | Total |
| && cookie_length + field->valuelen |
0 |
3 |
3 |
|
| 391 |
|
| > (size_t)-1 - 2 |
| 392 |
|
| ) |
| 393 |
|
| ) { |
| 394 |
0 |
| croak("HTTP/3 Cookie field coalescing overflow"); |
| 395 |
|
| } |
| 396 |
|
| |
| 397 |
5 |
| cookie_length += field->valuelen; |
| 398 |
5 |
▶ | if (cookie_count != 0) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (cookie_count != 0) { |
3 |
2 |
5 |
|
| 399 |
3 |
| cookie_length += 2; |
| 400 |
|
| } |
| 401 |
5 |
| ++cookie_count; |
| 402 |
|
| } |
| 403 |
|
| } |
| 404 |
|
| |
| 405 |
67 |
▶ | if (cookie_count > 1) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (cookie_count > 1) { |
2 |
65 |
67 |
|
| 406 |
2 |
| regular_count -= cookie_count - 1; |
| 407 |
2 |
▶ | Newx(cookie, cookie_length ? cookie_length : 1, uint8_t); |
Branch: 1 branch
| Branch | True | False | Total |
| Newx(cookie, cookie_length ? cookie_length : 1, uint8_t); |
2 |
0 |
2 |
|
| 408 |
|
| } |
| 409 |
|
| |
| 410 |
67 |
▶ | if (regular_count != 0) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (regular_count != 0) { |
12 |
55 |
67 |
|
| 411 |
12 |
▶ | Newxz(fields, regular_count, uhttp_native_field); |
Branch: 1 branch
| Branch | True | False | Total |
| Newxz(fields, regular_count, uhttp_native_field); |
0 |
12 |
12 |
|
| 412 |
|
| } |
| 413 |
|
| |
| 414 |
67 |
▶ | if (cookie_count > 1) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (cookie_count > 1) { |
2 |
65 |
67 |
|
| 415 |
2 |
| size_t cookie_offset = 0; |
| 416 |
|
| |
| 417 |
15 |
▶ | for (i = 0; i < block->count; ++i) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (i = 0; i < block->count; ++i) { |
13 |
2 |
15 |
|
| 418 |
13 |
| const unblock_http3_captured_field *field = |
| 419 |
13 |
| &block->fields[i]; |
| 420 |
|
| |
| 421 |
13 |
▶ | if ( |
Branch: 1 branch
| Branch | True | False | Total |
| if ( |
8 |
5 |
13 |
|
| 422 |
13 |
| !unblock_http3_captured_name_equal_ci( |
| 423 |
|
| field, |
| 424 |
|
| "cookie", |
| 425 |
|
| 6 |
| 426 |
|
| ) |
| 427 |
|
| ) { |
| 428 |
8 |
| continue; |
| 429 |
|
| } |
| 430 |
|
| |
| 431 |
5 |
▶ | if (cookie_offset != 0) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (cookie_offset != 0) { |
3 |
2 |
5 |
|
| 432 |
3 |
| cookie[cookie_offset++] = ';'; |
| 433 |
3 |
| cookie[cookie_offset++] = ' '; |
| 434 |
|
| } |
| 435 |
|
| |
| 436 |
5 |
▶ | if (field->valuelen) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (field->valuelen) { |
5 |
0 |
5 |
|
| 437 |
5 |
| Copy( |
| 438 |
|
| field->value, |
| 439 |
|
| cookie + cookie_offset, |
| 440 |
|
| field->valuelen, |
| 441 |
|
| uint8_t |
| 442 |
|
| ); |
| 443 |
5 |
| cookie_offset += field->valuelen; |
| 444 |
|
| } |
| 445 |
|
| } |
| 446 |
|
| } |
| 447 |
|
| |
| 448 |
262 |
▶ | for (i = 0; i < block->count; ++i) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (i = 0; i < block->count; ++i) { |
195 |
67 |
262 |
|
| 449 |
195 |
| const unblock_http3_captured_field *field = |
| 450 |
195 |
| &block->fields[i]; |
| 451 |
|
| |
| 452 |
195 |
| if ( |
| 453 |
195 |
▶ | field->namelen != 0 |
Branch: 1 branch
| Branch | True | False | Total |
| field->namelen != 0 |
195 |
0 |
195 |
|
| 454 |
195 |
▶ | && field->name[0] == ':' |
Branch: 1 branch
| Branch | True | False | Total |
| && field->name[0] == ':' |
177 |
18 |
195 |
|
| 455 |
|
| ) { |
| 456 |
177 |
| continue; |
| 457 |
|
| } |
| 458 |
|
| |
| 459 |
18 |
▶ | if ( |
Branch: 1 branch
| Branch | True | False | Total |
| if ( |
8 |
10 |
18 |
|
| 460 |
|
| cookie_count > 1 |
| 461 |
8 |
▶ | && unblock_http3_captured_name_equal_ci( |
Branch: 1 branch
| Branch | True | False | Total |
| && unblock_http3_captured_name_equal_ci( |
5 |
3 |
8 |
|
| 462 |
|
| field, |
| 463 |
|
| "cookie", |
| 464 |
|
| 6 |
| 465 |
|
| ) |
| 466 |
|
| ) { |
| 467 |
5 |
▶ | if (i != first_cookie) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (i != first_cookie) { |
3 |
2 |
5 |
|
| 468 |
3 |
| continue; |
| 469 |
|
| } |
| 470 |
|
| |
| 471 |
2 |
| fields[out_index].name.data = "cookie"; |
| 472 |
2 |
| fields[out_index].name.len = 6; |
| 473 |
2 |
| fields[out_index].value.data = |
| 474 |
|
| (const char *)cookie; |
| 475 |
2 |
| fields[out_index].value.len = |
| 476 |
|
| (STRLEN)cookie_length; |
| 477 |
2 |
| ++out_index; |
| 478 |
2 |
| continue; |
| 479 |
|
| } |
| 480 |
|
| |
| 481 |
13 |
| fields[out_index].name.data = |
| 482 |
13 |
| (const char *)field->name; |
| 483 |
13 |
| fields[out_index].name.len = |
| 484 |
13 |
| (STRLEN)field->namelen; |
| 485 |
13 |
| fields[out_index].value.data = |
| 486 |
13 |
| (const char *)field->value; |
| 487 |
13 |
| fields[out_index].value.len = |
| 488 |
13 |
| (STRLEN)field->valuelen; |
| 489 |
13 |
| ++out_index; |
| 490 |
|
| } |
| 491 |
|
| |
| 492 |
67 |
| *pfields = fields; |
| 493 |
67 |
| *pcount = (Size_t)regular_count; |
| 494 |
67 |
| *pcookie = cookie; |
| 495 |
67 |
| } |
| 496 |
|
| |
| 497 |
|
| static uhttp_native_bytes |
| 498 |
180 |
| unblock_http3_uniform_bytes_from_sv(SV *value) |
| 499 |
|
| { |
| 500 |
|
| uhttp_native_bytes bytes; |
| 501 |
|
| STRLEN len; |
| 502 |
|
| const char *data; |
| 503 |
|
| |
| 504 |
180 |
▶ | if (value == NULL || !SvOK(value)) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (value == NULL || !SvOK(value)) { |
180 |
0 |
180 |
| if (value == NULL || !SvOK(value)) { |
32 |
148 |
180 |
|
| 505 |
32 |
| bytes.data = NULL; |
| 506 |
32 |
| bytes.len = 0; |
| 507 |
32 |
| return bytes; |
| 508 |
|
| } |
| 509 |
|
| |
| 510 |
148 |
| data = SvPVbyte(value, len); |
| 511 |
148 |
| bytes.data = data; |
| 512 |
148 |
| bytes.len = len; |
| 513 |
148 |
| return bytes; |
| 514 |
|
| } |
| 515 |
|
| |
| 516 |
|
| static U32 |
| 517 |
67 |
| unblock_http3_received_uniform_flags( |
| 518 |
|
| U32 kind, |
| 519 |
|
| int fin |
| 520 |
|
| ) |
| 521 |
|
| { |
| 522 |
67 |
| U32 flags = |
| 523 |
|
| UHTTP_HEADERS_LOSSLESS |
| 524 |
|
| | UHTTP_TRAILERS_LOSSLESS; |
| 525 |
|
| |
| 526 |
67 |
▶ | if (kind == UHTTP_KIND_REQUEST) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (kind == UHTTP_KIND_REQUEST) { |
36 |
31 |
67 |
|
| 527 |
36 |
| flags |= UHTTP_TARGET_EXACT; |
| 528 |
|
| } |
| 529 |
|
| |
| 530 |
67 |
▶ | if (fin) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (fin) { |
0 |
67 |
67 |
|
| 531 |
0 |
| flags |= UHTTP_COMPLETE | UHTTP_HAS_BUFFERED_BODY; |
| 532 |
|
| } else { |
| 533 |
67 |
| flags |= |
| 534 |
|
| UHTTP_MUTABLE |
| 535 |
|
| | UHTTP_BODY_MUTABLE |
| 536 |
|
| | UHTTP_TRAILERS_MUTABLE; |
| 537 |
|
| } |
| 538 |
|
| |
| 539 |
67 |
| return flags; |
| 540 |
|
| } |
| 541 |
|
| |
| 542 |
|
| |
| 543 |
|
| static SV * |
| 544 |
36 |
| unblock_http3_header_block_uniform_request( |
| 545 |
|
| pTHX_ unblock_http3_header_block *block, |
| 546 |
|
| SV *method, |
| 547 |
|
| SV *target, |
| 548 |
|
| SV *scheme, |
| 549 |
|
| SV *authority, |
| 550 |
|
| SV *protocol, |
| 551 |
|
| int fin |
| 552 |
|
| ) |
| 553 |
|
| { |
| 554 |
|
| dMY_CXT; |
| 555 |
|
| uhttp_native_input input; |
| 556 |
36 |
| uhttp_native_field *fields = NULL; |
| 557 |
36 |
| Size_t field_count = 0; |
| 558 |
36 |
| uint8_t *cookie = NULL; |
| 559 |
|
| SV *object; |
| 560 |
|
| |
| 561 |
36 |
| unblock_http3_header_block_uniform_fields( |
| 562 |
|
| aTHX_ block, |
| 563 |
|
| &fields, |
| 564 |
|
| &field_count, |
| 565 |
|
| &cookie |
| 566 |
|
| ); |
| 567 |
|
| |
| 568 |
36 |
| uhttp_native_input_init( |
| 569 |
|
| &input, |
| 570 |
|
| UHTTP_KIND_REQUEST |
| 571 |
|
| ); |
| 572 |
36 |
| input.flags = unblock_http3_received_uniform_flags( |
| 573 |
|
| UHTTP_KIND_REQUEST, |
| 574 |
|
| fin |
| 575 |
|
| ); |
| 576 |
36 |
▶ | if (fin) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (fin) { |
0 |
36 |
36 |
|
| 577 |
0 |
| input.body.data = ""; |
| 578 |
0 |
| input.body.len = 0; |
| 579 |
|
| } |
| 580 |
36 |
| input.version.data = "3"; |
| 581 |
36 |
| input.version.len = 1; |
| 582 |
|
| input.method = |
| 583 |
36 |
| unblock_http3_uniform_bytes_from_sv(method); |
| 584 |
|
| input.target = |
| 585 |
36 |
| unblock_http3_uniform_bytes_from_sv(target); |
| 586 |
|
| input.scheme = |
| 587 |
36 |
| unblock_http3_uniform_bytes_from_sv(scheme); |
| 588 |
|
| input.authority = |
| 589 |
36 |
| unblock_http3_uniform_bytes_from_sv(authority); |
| 590 |
|
| input.protocol = |
| 591 |
36 |
| unblock_http3_uniform_bytes_from_sv(protocol); |
| 592 |
36 |
| input.headers = fields; |
| 593 |
36 |
| input.header_count = field_count; |
| 594 |
|
| |
| 595 |
36 |
| object = uhttp_native_from_validated( |
| 596 |
|
| aTHX_ &MY_CXT.uniform_api, |
| 597 |
|
| &input, |
| 598 |
|
| UHTTP_NATIVE_TRUSTED |
| 599 |
|
| ); |
| 600 |
|
| |
| 601 |
36 |
▶ | if (cookie != NULL) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (cookie != NULL) { |
1 |
35 |
36 |
|
| 602 |
1 |
| Safefree(cookie); |
| 603 |
|
| } |
| 604 |
36 |
▶ | if (fields != NULL) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (fields != NULL) { |
5 |
31 |
36 |
|
| 605 |
5 |
| Safefree(fields); |
| 606 |
|
| } |
| 607 |
|
| |
| 608 |
36 |
| return object; |
| 609 |
|
| } |
| 610 |
|
| |
| 611 |
|
| static SV * |
| 612 |
31 |
| unblock_http3_header_block_uniform_response( |
| 613 |
|
| pTHX_ unblock_http3_header_block *block, |
| 614 |
|
| IV status, |
| 615 |
|
| int fin |
| 616 |
|
| ) |
| 617 |
|
| { |
| 618 |
|
| dMY_CXT; |
| 619 |
|
| uhttp_native_input input; |
| 620 |
31 |
| uhttp_native_field *fields = NULL; |
| 621 |
31 |
| Size_t field_count = 0; |
| 622 |
31 |
| uint8_t *cookie = NULL; |
| 623 |
|
| SV *object; |
| 624 |
|
| |
| 625 |
31 |
| unblock_http3_header_block_uniform_fields( |
| 626 |
|
| aTHX_ block, |
| 627 |
|
| &fields, |
| 628 |
|
| &field_count, |
| 629 |
|
| &cookie |
| 630 |
|
| ); |
| 631 |
|
| |
| 632 |
31 |
| uhttp_native_input_init( |
| 633 |
|
| &input, |
| 634 |
|
| UHTTP_KIND_RESPONSE |
| 635 |
|
| ); |
| 636 |
31 |
| input.flags = unblock_http3_received_uniform_flags( |
| 637 |
|
| UHTTP_KIND_RESPONSE, |
| 638 |
|
| fin |
| 639 |
|
| ); |
| 640 |
31 |
▶ | if (fin) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (fin) { |
0 |
31 |
31 |
|
| 641 |
0 |
| input.body.data = ""; |
| 642 |
0 |
| input.body.len = 0; |
| 643 |
|
| } |
| 644 |
31 |
| input.version.data = "3"; |
| 645 |
31 |
| input.version.len = 1; |
| 646 |
31 |
| input.status = status; |
| 647 |
31 |
| input.headers = fields; |
| 648 |
31 |
| input.header_count = field_count; |
| 649 |
|
| |
| 650 |
31 |
| object = uhttp_native_from_validated( |
| 651 |
|
| aTHX_ &MY_CXT.uniform_api, |
| 652 |
|
| &input, |
| 653 |
|
| UHTTP_NATIVE_TRUSTED |
| 654 |
|
| ); |
| 655 |
|
| |
| 656 |
31 |
▶ | if (cookie != NULL) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (cookie != NULL) { |
1 |
30 |
31 |
|
| 657 |
1 |
| Safefree(cookie); |
| 658 |
|
| } |
| 659 |
31 |
▶ | if (fields != NULL) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (fields != NULL) { |
7 |
24 |
31 |
|
| 660 |
7 |
| Safefree(fields); |
| 661 |
|
| } |
| 662 |
|
| |
| 663 |
31 |
| return object; |
| 664 |
|
| } |
| 665 |
|
| |
| 666 |
|
| static void |
| 667 |
0 |
| unblock_http3_fail(const char *operation, int rv) |
| 668 |
|
| { |
| 669 |
0 |
| croak("%s: %s (%d)", operation, nghttp3_strerror(rv), rv); |
| 670 |
|
| } |
| 671 |
|
| |
| 672 |
|
| static unblock_http3_body * |
| 673 |
575 |
| unblock_http3_body_find( |
| 674 |
|
| unblock_http3_native_conn *native, |
| 675 |
|
| int64_t stream_id |
| 676 |
|
| ) |
| 677 |
|
| { |
| 678 |
|
| unblock_http3_body *body; |
| 679 |
|
| |
| 680 |
882 |
▶ | for (body = native->bodies; body != NULL; body = body->next) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (body = native->bodies; body != NULL; body = body->next) { |
616 |
266 |
882 |
|
| 681 |
616 |
▶ | if (body->stream_id == stream_id) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (body->stream_id == stream_id) { |
309 |
307 |
616 |
|
| 682 |
309 |
| return body; |
| 683 |
|
| } |
| 684 |
|
| } |
| 685 |
|
| |
| 686 |
266 |
| return NULL; |
| 687 |
|
| } |
| 688 |
|
| |
| 689 |
|
| static unblock_http3_body * |
| 690 |
48 |
| unblock_http3_body_create( |
| 691 |
|
| unblock_http3_native_conn *native, |
| 692 |
|
| int64_t stream_id, |
| 693 |
|
| int streaming |
| 694 |
|
| ) |
| 695 |
|
| { |
| 696 |
|
| unblock_http3_body *body; |
| 697 |
|
| |
| 698 |
48 |
▶ | if (unblock_http3_body_find(native, stream_id) != NULL) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (unblock_http3_body_find(native, stream_id) != NULL) { |
0 |
48 |
48 |
|
| 699 |
0 |
| croak("HTTP/3 stream already has an outgoing body"); |
| 700 |
|
| } |
| 701 |
|
| |
| 702 |
48 |
| Newxz(body, 1, unblock_http3_body); |
| 703 |
|
| |
| 704 |
48 |
| body->stream_id = stream_id; |
| 705 |
48 |
| body->streaming = streaming ? 1 : 0; |
| 706 |
48 |
| body->next = native->bodies; |
| 707 |
48 |
| native->bodies = body; |
| 708 |
|
| |
| 709 |
48 |
| return body; |
| 710 |
|
| } |
| 711 |
|
| |
| 712 |
|
| static void |
| 713 |
53 |
| unblock_http3_body_chunk_free(unblock_http3_body_chunk *chunk) |
| 714 |
|
| { |
| 715 |
53 |
▶ | if (chunk == NULL) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (chunk == NULL) { |
0 |
53 |
53 |
|
| 716 |
0 |
| return; |
| 717 |
|
| } |
| 718 |
|
| |
| 719 |
53 |
▶ | if (chunk->storage != NULL) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (chunk->storage != NULL) { |
53 |
0 |
53 |
|
| 720 |
53 |
| SvREFCNT_dec(chunk->storage); |
| 721 |
53 |
| chunk->storage = NULL; |
| 722 |
|
| } |
| 723 |
|
| |
| 724 |
53 |
| chunk->data = NULL; |
| 725 |
53 |
| Safefree(chunk); |
| 726 |
|
| } |
| 727 |
|
| |
| 728 |
|
| static size_t |
| 729 |
65 |
| unblock_http3_body_append( |
| 730 |
|
| unblock_http3_native_conn *native, |
| 731 |
|
| unblock_http3_body *body, |
| 732 |
|
| SV *body_sv |
| 733 |
|
| ) |
| 734 |
|
| { |
| 735 |
|
| unblock_http3_body_chunk *chunk; |
| 736 |
|
| SV *storage; |
| 737 |
|
| STRLEN len; |
| 738 |
|
| const char *bytes; |
| 739 |
|
| |
| 740 |
65 |
| storage = newSVsv(body_sv); |
| 741 |
65 |
| bytes = SvPVbyte(storage, len); |
| 742 |
|
| |
| 743 |
65 |
▶ | if (len == 0) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (len == 0) { |
12 |
53 |
65 |
|
| 744 |
12 |
| SvREFCNT_dec(storage); |
| 745 |
12 |
| return 0; |
| 746 |
|
| } |
| 747 |
|
| |
| 748 |
53 |
| Newxz(chunk, 1, unblock_http3_body_chunk); |
| 749 |
|
| |
| 750 |
53 |
| chunk->storage = storage; |
| 751 |
53 |
| chunk->data = (uint8_t *)bytes; |
| 752 |
53 |
| chunk->len = (size_t)len; |
| 753 |
|
| |
| 754 |
53 |
▶ | if (body->tail != NULL) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (body->tail != NULL) { |
10 |
43 |
53 |
|
| 755 |
10 |
| body->tail->next = chunk; |
| 756 |
|
| } else { |
| 757 |
43 |
| body->head = chunk; |
| 758 |
|
| } |
| 759 |
|
| |
| 760 |
53 |
| body->tail = chunk; |
| 761 |
|
| |
| 762 |
53 |
▶ | if (body->streaming) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (body->streaming) { |
32 |
21 |
53 |
|
| 763 |
32 |
| body->retained_bytes += (size_t)len; |
| 764 |
32 |
| native->streaming_retained_bytes += (size_t)len; |
| 765 |
|
| } |
| 766 |
|
| |
| 767 |
53 |
| return (size_t)len; |
| 768 |
|
| } |
| 769 |
|
| |
| 770 |
|
| static void |
| 771 |
18 |
| unblock_http3_body_discard( |
| 772 |
|
| unblock_http3_native_conn *native, |
| 773 |
|
| unblock_http3_body *body |
| 774 |
|
| ) |
| 775 |
|
| { |
| 776 |
|
| unblock_http3_body_chunk *chunk; |
| 777 |
|
| |
| 778 |
18 |
▶ | if (body == NULL) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (body == NULL) { |
9 |
9 |
18 |
|
| 779 |
9 |
| return; |
| 780 |
|
| } |
| 781 |
|
| |
| 782 |
9 |
| chunk = body->head; |
| 783 |
|
| |
| 784 |
15 |
▶ | while (chunk != NULL) { |
Branch: 1 branch
| Branch | True | False | Total |
| while (chunk != NULL) { |
6 |
9 |
15 |
|
| 785 |
6 |
| unblock_http3_body_chunk *next_chunk = chunk->next; |
| 786 |
|
| |
| 787 |
|
| { |
| 788 |
6 |
| size_t retained = chunk->len - chunk->acked; |
| 789 |
|
| |
| 790 |
6 |
| body->discarded_unacked += (uint64_t)retained; |
| 791 |
|
| |
| 792 |
6 |
▶ | if (body->streaming) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (body->streaming) { |
5 |
1 |
6 |
|
| 793 |
5 |
▶ | if (native->streaming_retained_bytes < retained) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (native->streaming_retained_bytes < retained) { |
0 |
5 |
5 |
|
| 794 |
0 |
| croak("HTTP/3 streaming retained-byte accounting underflow"); |
| 795 |
|
| } |
| 796 |
|
| |
| 797 |
5 |
▶ | if (body->retained_bytes < retained) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (body->retained_bytes < retained) { |
0 |
5 |
5 |
|
| 798 |
0 |
| croak("HTTP/3 per-stream retained-byte accounting underflow"); |
| 799 |
|
| } |
| 800 |
5 |
| body->retained_bytes -= retained; |
| 801 |
5 |
| native->streaming_retained_bytes -= retained; |
| 802 |
|
| } |
| 803 |
|
| } |
| 804 |
|
| |
| 805 |
6 |
| unblock_http3_body_chunk_free(chunk); |
| 806 |
6 |
| chunk = next_chunk; |
| 807 |
|
| } |
| 808 |
|
| |
| 809 |
9 |
| body->head = NULL; |
| 810 |
9 |
| body->tail = NULL; |
| 811 |
9 |
| body->eof = 1; |
| 812 |
|
| } |
| 813 |
|
| |
| 814 |
|
| static void |
| 815 |
65 |
| unblock_http3_body_remove( |
| 816 |
|
| unblock_http3_native_conn *native, |
| 817 |
|
| int64_t stream_id |
| 818 |
|
| ) |
| 819 |
|
| { |
| 820 |
65 |
| unblock_http3_body **link = &native->bodies; |
| 821 |
|
| |
| 822 |
97 |
▶ | while (*link != NULL) { |
Branch: 1 branch
| Branch | True | False | Total |
| while (*link != NULL) { |
72 |
25 |
97 |
|
| 823 |
72 |
| unblock_http3_body *body = *link; |
| 824 |
|
| |
| 825 |
72 |
▶ | if (body->stream_id != stream_id) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (body->stream_id != stream_id) { |
32 |
40 |
72 |
|
| 826 |
32 |
| link = &body->next; |
| 827 |
32 |
| continue; |
| 828 |
|
| } |
| 829 |
|
| |
| 830 |
40 |
| *link = body->next; |
| 831 |
|
| |
| 832 |
|
| { |
| 833 |
40 |
| unblock_http3_body_chunk *chunk = body->head; |
| 834 |
|
| |
| 835 |
40 |
▶ | while (chunk != NULL) { |
Branch: 1 branch
| Branch | True | False | Total |
| while (chunk != NULL) { |
0 |
40 |
40 |
|
| 836 |
0 |
| unblock_http3_body_chunk *next_chunk = chunk->next; |
| 837 |
0 |
| size_t retained = chunk->len - chunk->acked; |
| 838 |
|
| |
| 839 |
0 |
▶ | if (body->streaming) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (body->streaming) { |
0 |
0 |
0 |
|
| 840 |
0 |
▶ | if (native->streaming_retained_bytes < retained) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (native->streaming_retained_bytes < retained) { |
0 |
0 |
0 |
|
| 841 |
0 |
| croak("HTTP/3 streaming retained-byte accounting underflow"); |
| 842 |
|
| } |
| 843 |
|
| |
| 844 |
0 |
▶ | if (body->retained_bytes < retained) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (body->retained_bytes < retained) { |
0 |
0 |
0 |
|
| 845 |
0 |
| croak("HTTP/3 per-stream retained-byte accounting underflow"); |
| 846 |
|
| } |
| 847 |
0 |
| body->retained_bytes -= retained; |
| 848 |
0 |
| native->streaming_retained_bytes -= retained; |
| 849 |
|
| } |
| 850 |
|
| |
| 851 |
0 |
| unblock_http3_body_chunk_free(chunk); |
| 852 |
0 |
| chunk = next_chunk; |
| 853 |
|
| } |
| 854 |
|
| } |
| 855 |
|
| |
| 856 |
40 |
| Safefree(body); |
| 857 |
40 |
| return; |
| 858 |
|
| } |
| 859 |
|
| } |
| 860 |
|
| |
| 861 |
|
| static void |
| 862 |
63 |
| unblock_http3_body_free_all(unblock_http3_native_conn *native) |
| 863 |
|
| { |
| 864 |
63 |
| unblock_http3_body *body = native->bodies; |
| 865 |
|
| |
| 866 |
71 |
▶ | while (body != NULL) { |
Branch: 1 branch
| Branch | True | False | Total |
| while (body != NULL) { |
8 |
63 |
71 |
|
| 867 |
8 |
| unblock_http3_body *next_body = body->next; |
| 868 |
8 |
| unblock_http3_body_chunk *chunk = body->head; |
| 869 |
|
| |
| 870 |
11 |
▶ | while (chunk != NULL) { |
Branch: 1 branch
| Branch | True | False | Total |
| while (chunk != NULL) { |
3 |
8 |
11 |
|
| 871 |
3 |
| unblock_http3_body_chunk *next_chunk = chunk->next; |
| 872 |
|
| |
| 873 |
3 |
| unblock_http3_body_chunk_free(chunk); |
| 874 |
3 |
| chunk = next_chunk; |
| 875 |
|
| } |
| 876 |
|
| |
| 877 |
8 |
| Safefree(body); |
| 878 |
8 |
| body = next_body; |
| 879 |
|
| } |
| 880 |
|
| |
| 881 |
63 |
| native->bodies = NULL; |
| 882 |
63 |
| native->streaming_retained_bytes = 0; |
| 883 |
63 |
| } |
| 884 |
|
| |
| 885 |
|
| static nghttp3_ssize |
| 886 |
106 |
| unblock_http3_read_body_cb( |
| 887 |
|
| nghttp3_conn *conn, |
| 888 |
|
| int64_t stream_id, |
| 889 |
|
| nghttp3_vec *vec, |
| 890 |
|
| size_t veccnt, |
| 891 |
|
| uint32_t *pflags, |
| 892 |
|
| void *conn_user_data, |
| 893 |
|
| void *stream_user_data |
| 894 |
|
| ) |
| 895 |
|
| { |
| 896 |
106 |
| unblock_http3_body *body = (unblock_http3_body *)stream_user_data; |
| 897 |
|
| unblock_http3_body_chunk *chunk; |
| 898 |
106 |
| size_t count = 0; |
| 899 |
106 |
| int more_unsupplied = 0; |
| 900 |
|
| |
| 901 |
|
| (void)conn; |
| 902 |
|
| (void)stream_id; |
| 903 |
|
| (void)conn_user_data; |
| 904 |
|
| |
| 905 |
106 |
▶ | if (body == NULL) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (body == NULL) { |
0 |
106 |
106 |
|
| 906 |
0 |
| return NGHTTP3_ERR_CALLBACK_FAILURE; |
| 907 |
|
| } |
| 908 |
|
| |
| 909 |
106 |
| *pflags = NGHTTP3_DATA_FLAG_NONE; |
| 910 |
|
| |
| 911 |
191 |
▶ | for (chunk = body->head; chunk != NULL; chunk = chunk->next) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (chunk = body->head; chunk != NULL; chunk = chunk->next) { |
85 |
106 |
191 |
|
| 912 |
85 |
▶ | if (chunk->supplied) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (chunk->supplied) { |
35 |
50 |
85 |
|
| 913 |
35 |
| continue; |
| 914 |
|
| } |
| 915 |
|
| |
| 916 |
50 |
▶ | if (count == veccnt) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (count == veccnt) { |
0 |
50 |
50 |
|
| 917 |
0 |
| more_unsupplied = 1; |
| 918 |
0 |
| break; |
| 919 |
|
| } |
| 920 |
|
| |
| 921 |
50 |
| vec[count].base = chunk->data; |
| 922 |
50 |
| vec[count].len = chunk->len; |
| 923 |
50 |
| chunk->supplied = 1; |
| 924 |
50 |
| ++count; |
| 925 |
|
| } |
| 926 |
|
| |
| 927 |
106 |
▶ | if (count != 0) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (count != 0) { |
50 |
56 |
106 |
|
| 928 |
50 |
▶ | if (body->eof && !more_unsupplied) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (body->eof && !more_unsupplied) { |
29 |
21 |
50 |
| if (body->eof && !more_unsupplied) { |
29 |
0 |
29 |
|
| 929 |
66 |
▶ | for (chunk = body->head; chunk != NULL; chunk = chunk->next) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (chunk = body->head; chunk != NULL; chunk = chunk->next) { |
37 |
29 |
66 |
|
| 930 |
37 |
▶ | if (!chunk->supplied) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (!chunk->supplied) { |
0 |
37 |
37 |
|
| 931 |
0 |
| more_unsupplied = 1; |
| 932 |
0 |
| break; |
| 933 |
|
| } |
| 934 |
|
| } |
| 935 |
|
| |
| 936 |
29 |
▶ | if (!more_unsupplied) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (!more_unsupplied) { |
29 |
0 |
29 |
|
| 937 |
29 |
| *pflags |= NGHTTP3_DATA_FLAG_EOF; |
| 938 |
|
| } |
| 939 |
|
| } |
| 940 |
|
| |
| 941 |
50 |
| return (nghttp3_ssize)count; |
| 942 |
|
| } |
| 943 |
|
| |
| 944 |
56 |
▶ | if (body->eof) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (body->eof) { |
12 |
44 |
56 |
|
| 945 |
12 |
| *pflags |= NGHTTP3_DATA_FLAG_EOF; |
| 946 |
12 |
| return 0; |
| 947 |
|
| } |
| 948 |
|
| |
| 949 |
44 |
| return NGHTTP3_ERR_WOULDBLOCK; |
| 950 |
|
| } |
| 951 |
|
| |
| 952 |
|
| static const nghttp3_data_reader unblock_http3_body_reader = { |
| 953 |
|
| unblock_http3_read_body_cb |
| 954 |
|
| }; |
| 955 |
|
| |
| 956 |
|
| static int |
| 957 |
51 |
| unblock_http3_acked_stream_data_cb( |
| 958 |
|
| nghttp3_conn *conn, |
| 959 |
|
| int64_t stream_id, |
| 960 |
|
| uint64_t datalen, |
| 961 |
|
| void *conn_user_data, |
| 962 |
|
| void *stream_user_data |
| 963 |
|
| ) |
| 964 |
|
| { |
| 965 |
51 |
| unblock_http3_native_conn *native = |
| 966 |
|
| (unblock_http3_native_conn *)conn_user_data; |
| 967 |
51 |
| unblock_http3_body *body = (unblock_http3_body *)stream_user_data; |
| 968 |
51 |
| uint64_t remaining = datalen; |
| 969 |
|
| |
| 970 |
|
| (void)conn; |
| 971 |
|
| (void)stream_id; |
| 972 |
|
| |
| 973 |
51 |
▶ | if (body == NULL) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (body == NULL) { |
0 |
51 |
51 |
|
| 974 |
0 |
| return 0; |
| 975 |
|
| } |
| 976 |
|
| |
| 977 |
51 |
▶ | if (remaining != 0 && body->discarded_unacked != 0) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (remaining != 0 && body->discarded_unacked != 0) { |
51 |
0 |
51 |
| if (remaining != 0 && body->discarded_unacked != 0) { |
2 |
49 |
51 |
|
| 978 |
2 |
| uint64_t ignored = remaining < body->discarded_unacked |
| 979 |
|
| ? remaining |
| 980 |
|
| : body->discarded_unacked; |
| 981 |
|
| |
| 982 |
2 |
| body->discarded_unacked -= ignored; |
| 983 |
2 |
| remaining -= ignored; |
| 984 |
|
| } |
| 985 |
|
| |
| 986 |
100 |
▶ | while (remaining != 0 && body->head != NULL) { |
Branch: 2 branches
| Branch | True | False | Total |
| while (remaining != 0 && body->head != NULL) { |
49 |
51 |
100 |
| while (remaining != 0 && body->head != NULL) { |
49 |
0 |
49 |
|
| 987 |
49 |
| unblock_http3_body_chunk *chunk = body->head; |
| 988 |
|
| size_t available; |
| 989 |
|
| size_t take; |
| 990 |
|
| |
| 991 |
49 |
▶ | if (!chunk->supplied) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (!chunk->supplied) { |
0 |
49 |
49 |
|
| 992 |
0 |
| return NGHTTP3_ERR_CALLBACK_FAILURE; |
| 993 |
|
| } |
| 994 |
|
| |
| 995 |
49 |
| available = chunk->len - chunk->acked; |
| 996 |
49 |
| take = remaining < (uint64_t)available |
| 997 |
|
| ? (size_t)remaining |
| 998 |
|
| : available; |
| 999 |
|
| |
| 1000 |
49 |
| chunk->acked += take; |
| 1001 |
49 |
| remaining -= take; |
| 1002 |
|
| |
| 1003 |
49 |
▶ | if (body->streaming) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (body->streaming) { |
31 |
18 |
49 |
|
| 1004 |
31 |
▶ | if (native->streaming_retained_bytes < take) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (native->streaming_retained_bytes < take) { |
0 |
31 |
31 |
|
| 1005 |
0 |
| return NGHTTP3_ERR_CALLBACK_FAILURE; |
| 1006 |
|
| } |
| 1007 |
31 |
▶ | if (body->retained_bytes < take) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (body->retained_bytes < take) { |
0 |
31 |
31 |
|
| 1008 |
0 |
| return NGHTTP3_ERR_CALLBACK_FAILURE; |
| 1009 |
|
| } |
| 1010 |
31 |
| body->retained_bytes -= take; |
| 1011 |
31 |
| native->streaming_retained_bytes -= take; |
| 1012 |
|
| } |
| 1013 |
|
| |
| 1014 |
49 |
▶ | if (chunk->acked == chunk->len) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (chunk->acked == chunk->len) { |
44 |
5 |
49 |
|
| 1015 |
44 |
| body->head = chunk->next; |
| 1016 |
44 |
▶ | if (body->head == NULL) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (body->head == NULL) { |
35 |
9 |
44 |
|
| 1017 |
35 |
| body->tail = NULL; |
| 1018 |
|
| } |
| 1019 |
|
| |
| 1020 |
44 |
| unblock_http3_body_chunk_free(chunk); |
| 1021 |
|
| } |
| 1022 |
|
| } |
| 1023 |
|
| |
| 1024 |
51 |
▶ | if (remaining != 0) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (remaining != 0) { |
0 |
51 |
51 |
|
| 1025 |
0 |
| return NGHTTP3_ERR_CALLBACK_FAILURE; |
| 1026 |
|
| } |
| 1027 |
|
| |
| 1028 |
51 |
| return 0; |
| 1029 |
|
| } |
| 1030 |
|
| |
| 1031 |
|
| static AV * |
| 1032 |
302 |
| unblock_http3_event_new(const char *type, int64_t stream_id) |
| 1033 |
|
| { |
| 1034 |
302 |
| AV *event = newAV(); |
| 1035 |
|
| |
| 1036 |
302 |
| av_push(event, newSVpv(type, 0)); |
| 1037 |
302 |
| av_push(event, newSViv((IV)stream_id)); |
| 1038 |
|
| |
| 1039 |
302 |
| return event; |
| 1040 |
|
| } |
| 1041 |
|
| |
| 1042 |
|
| static void |
| 1043 |
302 |
| unblock_http3_push_event(unblock_http3_native_conn *native, AV *event) |
| 1044 |
|
| { |
| 1045 |
302 |
| av_push(native->events, newRV_noinc((SV *)event)); |
| 1046 |
302 |
| } |
| 1047 |
|
| |
| 1048 |
|
| static int |
| 1049 |
30 |
| unblock_http3_recv_settings2_cb( |
| 1050 |
|
| nghttp3_conn *conn, |
| 1051 |
|
| const nghttp3_proto_settings *settings, |
| 1052 |
|
| void *conn_user_data |
| 1053 |
|
| ) |
| 1054 |
|
| { |
| 1055 |
30 |
| unblock_http3_native_conn *native = |
| 1056 |
|
| (unblock_http3_native_conn *)conn_user_data; |
| 1057 |
30 |
| AV *event = unblock_http3_event_new("settings", -1); |
| 1058 |
|
| char max_field_section_size[32]; |
| 1059 |
|
| |
| 1060 |
|
| (void)conn; |
| 1061 |
|
| |
| 1062 |
30 |
| snprintf( |
| 1063 |
|
| max_field_section_size, |
| 1064 |
|
| sizeof(max_field_section_size), |
| 1065 |
|
| "%" PRIu64, |
| 1066 |
30 |
| settings->max_field_section_size |
| 1067 |
|
| ); |
| 1068 |
|
| |
| 1069 |
30 |
| av_push(event, newSVpv(max_field_section_size, 0)); |
| 1070 |
30 |
| av_push(event, newSViv(settings->enable_connect_protocol ? 1 : 0)); |
| 1071 |
30 |
| av_push(event, newSViv(settings->h3_datagram ? 1 : 0)); |
| 1072 |
30 |
| unblock_http3_push_event(native, event); |
| 1073 |
|
| |
| 1074 |
30 |
| return 0; |
| 1075 |
|
| } |
| 1076 |
|
| |
| 1077 |
|
| static int |
| 1078 |
2 |
| unblock_http3_recv_origin_cb( |
| 1079 |
|
| nghttp3_conn *conn, |
| 1080 |
|
| const uint8_t *origin, |
| 1081 |
|
| size_t originlen, |
| 1082 |
|
| void *conn_user_data |
| 1083 |
|
| ) |
| 1084 |
|
| { |
| 1085 |
2 |
| unblock_http3_native_conn *native = |
| 1086 |
|
| (unblock_http3_native_conn *)conn_user_data; |
| 1087 |
2 |
| AV *event = unblock_http3_event_new("origin", -1); |
| 1088 |
|
| |
| 1089 |
|
| (void)conn; |
| 1090 |
|
| |
| 1091 |
2 |
| av_push(event, newSVpvn((const char *)origin, originlen)); |
| 1092 |
2 |
| unblock_http3_push_event(native, event); |
| 1093 |
|
| |
| 1094 |
2 |
| return 0; |
| 1095 |
|
| } |
| 1096 |
|
| |
| 1097 |
|
| static int |
| 1098 |
1 |
| unblock_http3_end_origin_cb( |
| 1099 |
|
| nghttp3_conn *conn, |
| 1100 |
|
| void *conn_user_data |
| 1101 |
|
| ) |
| 1102 |
|
| { |
| 1103 |
1 |
| unblock_http3_native_conn *native = |
| 1104 |
|
| (unblock_http3_native_conn *)conn_user_data; |
| 1105 |
|
| |
| 1106 |
|
| (void)conn; |
| 1107 |
|
| |
| 1108 |
1 |
| unblock_http3_push_event( |
| 1109 |
|
| native, |
| 1110 |
|
| unblock_http3_event_new("end_origin", -1) |
| 1111 |
|
| ); |
| 1112 |
|
| |
| 1113 |
1 |
| return 0; |
| 1114 |
|
| } |
| 1115 |
|
| |
| 1116 |
|
| static int |
| 1117 |
58 |
| unblock_http3_recv_data_cb( |
| 1118 |
|
| nghttp3_conn *conn, |
| 1119 |
|
| int64_t stream_id, |
| 1120 |
|
| const uint8_t *data, |
| 1121 |
|
| size_t datalen, |
| 1122 |
|
| void *conn_user_data, |
| 1123 |
|
| void *stream_user_data |
| 1124 |
|
| ) |
| 1125 |
|
| { |
| 1126 |
58 |
| unblock_http3_native_conn *native = |
| 1127 |
|
| (unblock_http3_native_conn *)conn_user_data; |
| 1128 |
58 |
| AV *event = unblock_http3_event_new("data", stream_id); |
| 1129 |
|
| |
| 1130 |
|
| (void)conn; |
| 1131 |
|
| (void)stream_user_data; |
| 1132 |
|
| |
| 1133 |
58 |
| av_push(event, newSVpvn((const char *)data, datalen)); |
| 1134 |
58 |
| unblock_http3_push_event(native, event); |
| 1135 |
|
| |
| 1136 |
58 |
| return 0; |
| 1137 |
|
| } |
| 1138 |
|
| |
| 1139 |
|
| static int |
| 1140 |
0 |
| unblock_http3_deferred_consume_cb( |
| 1141 |
|
| nghttp3_conn *conn, |
| 1142 |
|
| int64_t stream_id, |
| 1143 |
|
| size_t consumed, |
| 1144 |
|
| void *conn_user_data, |
| 1145 |
|
| void *stream_user_data |
| 1146 |
|
| ) |
| 1147 |
|
| { |
| 1148 |
0 |
| unblock_http3_native_conn *native = |
| 1149 |
|
| (unblock_http3_native_conn *)conn_user_data; |
| 1150 |
0 |
| AV *event = unblock_http3_event_new("deferred_consume", stream_id); |
| 1151 |
|
| |
| 1152 |
|
| (void)conn; |
| 1153 |
|
| (void)stream_user_data; |
| 1154 |
|
| |
| 1155 |
0 |
| av_push(event, newSVuv((UV)consumed)); |
| 1156 |
0 |
| unblock_http3_push_event(native, event); |
| 1157 |
|
| |
| 1158 |
0 |
| return 0; |
| 1159 |
|
| } |
| 1160 |
|
| |
| 1161 |
|
| static int |
| 1162 |
71 |
| unblock_http3_begin_headers_cb( |
| 1163 |
|
| nghttp3_conn *conn, |
| 1164 |
|
| int64_t stream_id, |
| 1165 |
|
| void *conn_user_data, |
| 1166 |
|
| void *stream_user_data |
| 1167 |
|
| ) |
| 1168 |
|
| { |
| 1169 |
71 |
| unblock_http3_native_conn *native = |
| 1170 |
|
| (unblock_http3_native_conn *)conn_user_data; |
| 1171 |
|
| |
| 1172 |
|
| (void)conn; |
| 1173 |
|
| (void)stream_user_data; |
| 1174 |
|
| |
| 1175 |
71 |
| (void)unblock_http3_header_block_create( |
| 1176 |
|
| native, |
| 1177 |
|
| stream_id |
| 1178 |
|
| ); |
| 1179 |
|
| |
| 1180 |
71 |
| return 0; |
| 1181 |
|
| } |
| 1182 |
|
| |
| 1183 |
|
| static int |
| 1184 |
213 |
| unblock_http3_recv_header_cb( |
| 1185 |
|
| nghttp3_conn *conn, |
| 1186 |
|
| int64_t stream_id, |
| 1187 |
|
| int32_t token, |
| 1188 |
|
| nghttp3_rcbuf *name, |
| 1189 |
|
| nghttp3_rcbuf *value, |
| 1190 |
|
| uint8_t flags, |
| 1191 |
|
| void *conn_user_data, |
| 1192 |
|
| void *stream_user_data |
| 1193 |
|
| ) |
| 1194 |
|
| { |
| 1195 |
213 |
| unblock_http3_native_conn *native = |
| 1196 |
|
| (unblock_http3_native_conn *)conn_user_data; |
| 1197 |
|
| unblock_http3_header_block *block = |
| 1198 |
213 |
| unblock_http3_header_block_find(native, stream_id); |
| 1199 |
213 |
| nghttp3_vec nbuf = nghttp3_rcbuf_get_buf(name); |
| 1200 |
213 |
| nghttp3_vec vbuf = nghttp3_rcbuf_get_buf(value); |
| 1201 |
|
| |
| 1202 |
|
| (void)conn; |
| 1203 |
|
| (void)token; |
| 1204 |
|
| (void)flags; |
| 1205 |
|
| (void)stream_user_data; |
| 1206 |
|
| |
| 1207 |
213 |
| unblock_http3_header_block_append( |
| 1208 |
|
| block, |
| 1209 |
213 |
| nbuf.base, |
| 1210 |
|
| nbuf.len, |
| 1211 |
213 |
| vbuf.base, |
| 1212 |
|
| vbuf.len |
| 1213 |
|
| ); |
| 1214 |
|
| |
| 1215 |
213 |
| return 0; |
| 1216 |
|
| } |
| 1217 |
|
| |
| 1218 |
|
| static int |
| 1219 |
71 |
| unblock_http3_end_headers_cb( |
| 1220 |
|
| nghttp3_conn *conn, |
| 1221 |
|
| int64_t stream_id, |
| 1222 |
|
| int fin, |
| 1223 |
|
| void *conn_user_data, |
| 1224 |
|
| void *stream_user_data |
| 1225 |
|
| ) |
| 1226 |
|
| { |
| 1227 |
71 |
| unblock_http3_native_conn *native = |
| 1228 |
|
| (unblock_http3_native_conn *)conn_user_data; |
| 1229 |
|
| unblock_http3_header_block *block = |
| 1230 |
71 |
| unblock_http3_header_block_find(native, stream_id); |
| 1231 |
|
| AV *event; |
| 1232 |
|
| |
| 1233 |
|
| (void)conn; |
| 1234 |
|
| (void)stream_user_data; |
| 1235 |
|
| |
| 1236 |
71 |
▶ | if (block == NULL) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (block == NULL) { |
0 |
71 |
71 |
|
| 1237 |
0 |
| croak("HTTP/3 header section ended without beginning"); |
| 1238 |
|
| } |
| 1239 |
|
| |
| 1240 |
71 |
| event = unblock_http3_event_new("headers", stream_id); |
| 1241 |
71 |
| av_push(event, newSVuv((UV)block->field_section_size)); |
| 1242 |
71 |
| av_push(event, newSViv(fin ? 1 : 0)); |
| 1243 |
71 |
| unblock_http3_push_event(native, event); |
| 1244 |
|
| |
| 1245 |
71 |
| return 0; |
| 1246 |
|
| } |
| 1247 |
|
| |
| 1248 |
|
| static int |
| 1249 |
4 |
| unblock_http3_begin_trailers_cb( |
| 1250 |
|
| nghttp3_conn *conn, |
| 1251 |
|
| int64_t stream_id, |
| 1252 |
|
| void *conn_user_data, |
| 1253 |
|
| void *stream_user_data |
| 1254 |
|
| ) |
| 1255 |
|
| { |
| 1256 |
4 |
| unblock_http3_native_conn *native = |
| 1257 |
|
| (unblock_http3_native_conn *)conn_user_data; |
| 1258 |
|
| |
| 1259 |
|
| (void)conn; |
| 1260 |
|
| (void)stream_user_data; |
| 1261 |
|
| |
| 1262 |
4 |
| unblock_http3_push_event( |
| 1263 |
|
| native, |
| 1264 |
|
| unblock_http3_event_new("begin_trailers", stream_id) |
| 1265 |
|
| ); |
| 1266 |
|
| |
| 1267 |
4 |
| return 0; |
| 1268 |
|
| } |
| 1269 |
|
| |
| 1270 |
|
| static int |
| 1271 |
6 |
| unblock_http3_recv_trailer_cb( |
| 1272 |
|
| nghttp3_conn *conn, |
| 1273 |
|
| int64_t stream_id, |
| 1274 |
|
| int32_t token, |
| 1275 |
|
| nghttp3_rcbuf *name, |
| 1276 |
|
| nghttp3_rcbuf *value, |
| 1277 |
|
| uint8_t flags, |
| 1278 |
|
| void *conn_user_data, |
| 1279 |
|
| void *stream_user_data |
| 1280 |
|
| ) |
| 1281 |
|
| { |
| 1282 |
6 |
| unblock_http3_native_conn *native = |
| 1283 |
|
| (unblock_http3_native_conn *)conn_user_data; |
| 1284 |
6 |
| nghttp3_vec nbuf = nghttp3_rcbuf_get_buf(name); |
| 1285 |
6 |
| nghttp3_vec vbuf = nghttp3_rcbuf_get_buf(value); |
| 1286 |
6 |
| AV *event = unblock_http3_event_new("trailer", stream_id); |
| 1287 |
|
| |
| 1288 |
|
| (void)conn; |
| 1289 |
|
| (void)token; |
| 1290 |
|
| (void)flags; |
| 1291 |
|
| (void)stream_user_data; |
| 1292 |
|
| |
| 1293 |
6 |
| av_push(event, newSVpvn((const char *)nbuf.base, nbuf.len)); |
| 1294 |
6 |
| av_push(event, newSVpvn((const char *)vbuf.base, vbuf.len)); |
| 1295 |
6 |
| unblock_http3_push_event(native, event); |
| 1296 |
|
| |
| 1297 |
6 |
| return 0; |
| 1298 |
|
| } |
| 1299 |
|
| |
| 1300 |
|
| static int |
| 1301 |
4 |
| unblock_http3_end_trailers_cb( |
| 1302 |
|
| nghttp3_conn *conn, |
| 1303 |
|
| int64_t stream_id, |
| 1304 |
|
| int fin, |
| 1305 |
|
| void *conn_user_data, |
| 1306 |
|
| void *stream_user_data |
| 1307 |
|
| ) |
| 1308 |
|
| { |
| 1309 |
4 |
| unblock_http3_native_conn *native = |
| 1310 |
|
| (unblock_http3_native_conn *)conn_user_data; |
| 1311 |
4 |
| AV *event = unblock_http3_event_new("end_trailers", stream_id); |
| 1312 |
|
| |
| 1313 |
|
| (void)conn; |
| 1314 |
|
| (void)stream_user_data; |
| 1315 |
|
| |
| 1316 |
4 |
| av_push(event, newSViv(fin ? 1 : 0)); |
| 1317 |
4 |
| unblock_http3_push_event(native, event); |
| 1318 |
|
| |
| 1319 |
4 |
| return 0; |
| 1320 |
|
| } |
| 1321 |
|
| |
| 1322 |
|
| static int |
| 1323 |
58 |
| unblock_http3_end_stream_cb( |
| 1324 |
|
| nghttp3_conn *conn, |
| 1325 |
|
| int64_t stream_id, |
| 1326 |
|
| void *conn_user_data, |
| 1327 |
|
| void *stream_user_data |
| 1328 |
|
| ) |
| 1329 |
|
| { |
| 1330 |
58 |
| unblock_http3_native_conn *native = |
| 1331 |
|
| (unblock_http3_native_conn *)conn_user_data; |
| 1332 |
|
| |
| 1333 |
|
| (void)conn; |
| 1334 |
|
| (void)stream_user_data; |
| 1335 |
|
| |
| 1336 |
58 |
| unblock_http3_push_event( |
| 1337 |
|
| native, |
| 1338 |
|
| unblock_http3_event_new("end_stream", stream_id) |
| 1339 |
|
| ); |
| 1340 |
|
| |
| 1341 |
58 |
| return 0; |
| 1342 |
|
| } |
| 1343 |
|
| |
| 1344 |
|
| static int |
| 1345 |
0 |
| unblock_http3_stop_sending_cb( |
| 1346 |
|
| nghttp3_conn *conn, |
| 1347 |
|
| int64_t stream_id, |
| 1348 |
|
| uint64_t app_error_code, |
| 1349 |
|
| void *conn_user_data, |
| 1350 |
|
| void *stream_user_data |
| 1351 |
|
| ) |
| 1352 |
|
| { |
| 1353 |
0 |
| unblock_http3_native_conn *native = |
| 1354 |
|
| (unblock_http3_native_conn *)conn_user_data; |
| 1355 |
0 |
| AV *event = unblock_http3_event_new("stop_sending", stream_id); |
| 1356 |
|
| |
| 1357 |
|
| (void)conn; |
| 1358 |
|
| (void)stream_user_data; |
| 1359 |
|
| |
| 1360 |
0 |
| av_push(event, newSVuv((UV)app_error_code)); |
| 1361 |
0 |
| unblock_http3_push_event(native, event); |
| 1362 |
|
| |
| 1363 |
0 |
| return 0; |
| 1364 |
|
| } |
| 1365 |
|
| |
| 1366 |
|
| static int |
| 1367 |
0 |
| unblock_http3_reset_stream_cb( |
| 1368 |
|
| nghttp3_conn *conn, |
| 1369 |
|
| int64_t stream_id, |
| 1370 |
|
| uint64_t app_error_code, |
| 1371 |
|
| void *conn_user_data, |
| 1372 |
|
| void *stream_user_data |
| 1373 |
|
| ) |
| 1374 |
|
| { |
| 1375 |
0 |
| unblock_http3_native_conn *native = |
| 1376 |
|
| (unblock_http3_native_conn *)conn_user_data; |
| 1377 |
0 |
| AV *event = unblock_http3_event_new("reset_stream", stream_id); |
| 1378 |
|
| |
| 1379 |
|
| (void)conn; |
| 1380 |
|
| (void)stream_user_data; |
| 1381 |
|
| |
| 1382 |
0 |
| av_push(event, newSVuv((UV)app_error_code)); |
| 1383 |
0 |
| unblock_http3_push_event(native, event); |
| 1384 |
|
| |
| 1385 |
0 |
| return 0; |
| 1386 |
|
| } |
| 1387 |
|
| |
| 1388 |
|
| static int |
| 1389 |
3 |
| unblock_http3_shutdown_cb( |
| 1390 |
|
| nghttp3_conn *conn, |
| 1391 |
|
| int64_t id, |
| 1392 |
|
| void *conn_user_data |
| 1393 |
|
| ) |
| 1394 |
|
| { |
| 1395 |
3 |
| unblock_http3_native_conn *native = |
| 1396 |
|
| (unblock_http3_native_conn *)conn_user_data; |
| 1397 |
3 |
| AV *event = unblock_http3_event_new("shutdown", id); |
| 1398 |
|
| |
| 1399 |
|
| (void)conn; |
| 1400 |
|
| |
| 1401 |
3 |
| unblock_http3_push_event(native, event); |
| 1402 |
|
| |
| 1403 |
3 |
| return 0; |
| 1404 |
|
| } |
| 1405 |
|
| |
| 1406 |
|
| static int |
| 1407 |
65 |
| unblock_http3_stream_close2_cb( |
| 1408 |
|
| nghttp3_conn *conn, |
| 1409 |
|
| uint32_t flags, |
| 1410 |
|
| int64_t stream_id, |
| 1411 |
|
| uint64_t rx_app_error_code, |
| 1412 |
|
| uint64_t tx_app_error_code, |
| 1413 |
|
| void *conn_user_data, |
| 1414 |
|
| void *stream_user_data |
| 1415 |
|
| ) |
| 1416 |
|
| { |
| 1417 |
65 |
| unblock_http3_native_conn *native = |
| 1418 |
|
| (unblock_http3_native_conn *)conn_user_data; |
| 1419 |
65 |
| AV *event = unblock_http3_event_new("stream_close", stream_id); |
| 1420 |
|
| |
| 1421 |
|
| (void)conn; |
| 1422 |
|
| (void)stream_user_data; |
| 1423 |
|
| |
| 1424 |
65 |
| av_push(event, newSVuv((UV)flags)); |
| 1425 |
65 |
| av_push(event, newSVuv((UV)rx_app_error_code)); |
| 1426 |
65 |
| av_push(event, newSVuv((UV)tx_app_error_code)); |
| 1427 |
65 |
| unblock_http3_push_event(native, event); |
| 1428 |
|
| |
| 1429 |
65 |
| return 0; |
| 1430 |
|
| } |
| 1431 |
|
| |
| 1432 |
|
| static SV * |
| 1433 |
63 |
| unblock_http3_bless_conn(unblock_http3_native_conn *native) |
| 1434 |
|
| { |
| 1435 |
63 |
| SV *inner = newSViv(PTR2IV(native)); |
| 1436 |
63 |
| SV *rv = newRV_noinc(inner); |
| 1437 |
|
| |
| 1438 |
63 |
| sv_bless( |
| 1439 |
|
| rv, |
| 1440 |
|
| gv_stashpv("Unblock::HTTP3::_Native::Connection", GV_ADD) |
| 1441 |
|
| ); |
| 1442 |
|
| |
| 1443 |
63 |
| return rv; |
| 1444 |
|
| } |
| 1445 |
|
| |
| 1446 |
|
| static unblock_http3_native_conn * |
| 1447 |
5255 |
| unblock_http3_conn_from_sv(SV *self) |
| 1448 |
|
| { |
| 1449 |
|
| unblock_http3_native_conn *native; |
| 1450 |
|
| |
| 1451 |
5255 |
▶ | if (!SvROK(self)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (!SvROK(self)) { |
0 |
5255 |
5255 |
|
| 1452 |
0 |
| croak("native HTTP/3 connection is not a reference"); |
| 1453 |
|
| } |
| 1454 |
|
| |
| 1455 |
5255 |
| native = INT2PTR( |
| 1456 |
|
| unblock_http3_native_conn *, |
| 1457 |
|
| SvIV(SvRV(self)) |
| 1458 |
|
| ); |
| 1459 |
|
| |
| 1460 |
5255 |
▶ | if (native == NULL || native->conn == NULL) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (native == NULL || native->conn == NULL) { |
5255 |
0 |
5255 |
| if (native == NULL || native->conn == NULL) { |
0 |
5255 |
5255 |
|
| 1461 |
0 |
| croak("native HTTP/3 connection has been destroyed"); |
| 1462 |
|
| } |
| 1463 |
|
| |
| 1464 |
5255 |
▶ | if (native->fatal) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (native->fatal) { |
1 |
5254 |
5255 |
|
| 1465 |
1 |
| croak("native HTTP/3 connection is no longer usable"); |
| 1466 |
|
| } |
| 1467 |
|
| |
| 1468 |
5254 |
| return native; |
| 1469 |
|
| } |
| 1470 |
|
| |
| 1471 |
|
| static SV * |
| 1472 |
63 |
| unblock_http3_new_conn( |
| 1473 |
|
| int is_server, |
| 1474 |
|
| uint64_t max_field_section_size, |
| 1475 |
|
| uint64_t qpack_max_table_capacity, |
| 1476 |
|
| uint64_t qpack_blocked_streams, |
| 1477 |
|
| int enable_connect_protocol, |
| 1478 |
|
| int h3_datagram, |
| 1479 |
|
| SV *origin_list_sv |
| 1480 |
|
| ) |
| 1481 |
|
| { |
| 1482 |
|
| unblock_http3_native_conn *native; |
| 1483 |
|
| nghttp3_callbacks callbacks; |
| 1484 |
|
| nghttp3_settings settings; |
| 1485 |
|
| int rv; |
| 1486 |
|
| |
| 1487 |
63 |
| Newxz(native, 1, unblock_http3_native_conn); |
| 1488 |
63 |
| Zero(&callbacks, 1, nghttp3_callbacks); |
| 1489 |
|
| |
| 1490 |
63 |
| native->events = newAV(); |
| 1491 |
|
| |
| 1492 |
63 |
| callbacks.acked_stream_data = unblock_http3_acked_stream_data_cb; |
| 1493 |
63 |
| callbacks.recv_settings2 = unblock_http3_recv_settings2_cb; |
| 1494 |
63 |
| callbacks.recv_origin = unblock_http3_recv_origin_cb; |
| 1495 |
63 |
| callbacks.end_origin = unblock_http3_end_origin_cb; |
| 1496 |
63 |
| callbacks.recv_data = unblock_http3_recv_data_cb; |
| 1497 |
63 |
| callbacks.deferred_consume = unblock_http3_deferred_consume_cb; |
| 1498 |
63 |
| callbacks.begin_headers = unblock_http3_begin_headers_cb; |
| 1499 |
63 |
| callbacks.recv_header = unblock_http3_recv_header_cb; |
| 1500 |
63 |
| callbacks.end_headers = unblock_http3_end_headers_cb; |
| 1501 |
63 |
| callbacks.begin_trailers = unblock_http3_begin_trailers_cb; |
| 1502 |
63 |
| callbacks.recv_trailer = unblock_http3_recv_trailer_cb; |
| 1503 |
63 |
| callbacks.end_trailers = unblock_http3_end_trailers_cb; |
| 1504 |
63 |
| callbacks.end_stream = unblock_http3_end_stream_cb; |
| 1505 |
63 |
| callbacks.stop_sending = unblock_http3_stop_sending_cb; |
| 1506 |
63 |
| callbacks.reset_stream = unblock_http3_reset_stream_cb; |
| 1507 |
63 |
| callbacks.shutdown = unblock_http3_shutdown_cb; |
| 1508 |
63 |
| callbacks.stream_close2 = unblock_http3_stream_close2_cb; |
| 1509 |
|
| |
| 1510 |
63 |
| nghttp3_settings_default(&settings); |
| 1511 |
63 |
| settings.max_field_section_size = max_field_section_size; |
| 1512 |
63 |
| settings.qpack_max_dtable_capacity = qpack_max_table_capacity; |
| 1513 |
63 |
| settings.qpack_blocked_streams = qpack_blocked_streams; |
| 1514 |
63 |
| settings.enable_connect_protocol = enable_connect_protocol ? 1 : 0; |
| 1515 |
63 |
| settings.h3_datagram = h3_datagram ? 1 : 0; |
| 1516 |
|
| |
| 1517 |
63 |
▶ | if (is_server && origin_list_sv != NULL && SvOK(origin_list_sv)) { |
Branch: 3 branches
| Branch | True | False | Total |
| if (is_server && origin_list_sv != NULL && SvOK(origin_list_sv)) { |
39 |
24 |
63 |
| if (is_server && origin_list_sv != NULL && SvOK(origin_list_sv)) { |
39 |
0 |
39 |
| if (is_server && origin_list_sv != NULL && SvOK(origin_list_sv)) { |
2 |
37 |
39 |
|
| 1518 |
|
| STRLEN origin_list_len; |
| 1519 |
|
| const char *origin_list_bytes = |
| 1520 |
2 |
| SvPVbyte(origin_list_sv, origin_list_len); |
| 1521 |
|
| |
| 1522 |
2 |
▶ | if (origin_list_len != 0) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (origin_list_len != 0) { |
1 |
1 |
2 |
|
| 1523 |
1 |
| Newx(native->origin_list_data, origin_list_len, uint8_t); |
| 1524 |
1 |
| Copy( |
| 1525 |
|
| origin_list_bytes, |
| 1526 |
|
| native->origin_list_data, |
| 1527 |
|
| origin_list_len, |
| 1528 |
|
| uint8_t |
| 1529 |
|
| ); |
| 1530 |
|
| } |
| 1531 |
|
| |
| 1532 |
2 |
| native->origin_list.base = native->origin_list_data; |
| 1533 |
2 |
| native->origin_list.len = (size_t)origin_list_len; |
| 1534 |
2 |
| settings.origin_list = &native->origin_list; |
| 1535 |
|
| } |
| 1536 |
|
| |
| 1537 |
63 |
▶ | if (is_server) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (is_server) { |
39 |
24 |
63 |
|
| 1538 |
39 |
| rv = nghttp3_conn_server_new( |
| 1539 |
|
| &native->conn, |
| 1540 |
|
| &callbacks, |
| 1541 |
|
| &settings, |
| 1542 |
|
| NULL, |
| 1543 |
|
| native |
| 1544 |
|
| ); |
| 1545 |
|
| } else { |
| 1546 |
24 |
| rv = nghttp3_conn_client_new( |
| 1547 |
|
| &native->conn, |
| 1548 |
|
| &callbacks, |
| 1549 |
|
| &settings, |
| 1550 |
|
| NULL, |
| 1551 |
|
| native |
| 1552 |
|
| ); |
| 1553 |
|
| } |
| 1554 |
|
| |
| 1555 |
63 |
▶ | if (rv != 0) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (rv != 0) { |
0 |
63 |
63 |
|
| 1556 |
0 |
| SvREFCNT_dec((SV *)native->events); |
| 1557 |
0 |
▶ | if (native->origin_list_data != NULL) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (native->origin_list_data != NULL) { |
0 |
0 |
0 |
|
| 1558 |
0 |
| Safefree(native->origin_list_data); |
| 1559 |
|
| } |
| 1560 |
0 |
| Safefree(native); |
| 1561 |
0 |
| unblock_http3_fail("could not create libnghttp3 connection", rv); |
| 1562 |
|
| } |
| 1563 |
|
| |
| 1564 |
63 |
| native->is_server = is_server ? 1 : 0; |
| 1565 |
|
| |
| 1566 |
63 |
| return unblock_http3_bless_conn(native); |
| 1567 |
|
| } |
| 1568 |
|
| |
| 1569 |
|
| |
| 1570 |
|
| typedef struct { |
| 1571 |
|
| nghttp3_nv *nva; |
| 1572 |
|
| uint8_t **owned_names; |
| 1573 |
|
| size_t nvlen; |
| 1574 |
|
| } unblock_http3_uniform_fields; |
| 1575 |
|
| |
| 1576 |
|
| static int |
| 1577 |
0 |
| unblock_http3_bytes_equal( |
| 1578 |
|
| const uint8_t *left, |
| 1579 |
|
| size_t left_len, |
| 1580 |
|
| const char *right |
| 1581 |
|
| ) |
| 1582 |
|
| { |
| 1583 |
0 |
| size_t right_len = strlen(right); |
| 1584 |
|
| |
| 1585 |
|
| return left_len == right_len |
| 1586 |
0 |
▶ | && memcmp(left, right, right_len) == 0; |
Branch: 2 branches
| Branch | True | False | Total |
| && memcmp(left, right, right_len) == 0; |
0 |
0 |
0 |
| && memcmp(left, right, right_len) == 0; |
0 |
0 |
0 |
|
| 1587 |
|
| } |
| 1588 |
|
| |
| 1589 |
|
| static int |
| 1590 |
318 |
| unblock_http3_ascii_equal_ci( |
| 1591 |
|
| const uint8_t *left, |
| 1592 |
|
| size_t left_len, |
| 1593 |
|
| const char *right |
| 1594 |
|
| ) |
| 1595 |
|
| { |
| 1596 |
|
| size_t i; |
| 1597 |
318 |
| size_t right_len = strlen(right); |
| 1598 |
|
| |
| 1599 |
318 |
▶ | if (left_len != right_len) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (left_len != right_len) { |
303 |
15 |
318 |
|
| 1600 |
303 |
| return 0; |
| 1601 |
|
| } |
| 1602 |
|
| |
| 1603 |
15 |
▶ | for (i = 0; i < left_len; ++i) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (i = 0; i < left_len; ++i) { |
15 |
0 |
15 |
|
| 1604 |
15 |
| uint8_t ch = left[i]; |
| 1605 |
15 |
| uint8_t expected = (uint8_t)right[i]; |
| 1606 |
|
| |
| 1607 |
15 |
▶ | if (ch >= 'A' && ch <= 'Z') { |
Branch: 2 branches
| Branch | True | False | Total |
| if (ch >= 'A' && ch <= 'Z') { |
15 |
0 |
15 |
| if (ch >= 'A' && ch <= 'Z') { |
0 |
15 |
15 |
|
| 1608 |
0 |
| ch = (uint8_t)(ch + ('a' - 'A')); |
| 1609 |
|
| } |
| 1610 |
|
| |
| 1611 |
15 |
▶ | if (expected >= 'A' && expected <= 'Z') { |
Branch: 2 branches
| Branch | True | False | Total |
| if (expected >= 'A' && expected <= 'Z') { |
15 |
0 |
15 |
| if (expected >= 'A' && expected <= 'Z') { |
0 |
15 |
15 |
|
| 1612 |
0 |
| expected = (uint8_t)(expected + ('a' - 'A')); |
| 1613 |
|
| } |
| 1614 |
|
| |
| 1615 |
15 |
▶ | if (ch != expected) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (ch != expected) { |
15 |
0 |
15 |
|
| 1616 |
15 |
| return 0; |
| 1617 |
|
| } |
| 1618 |
|
| } |
| 1619 |
|
| |
| 1620 |
0 |
| return 1; |
| 1621 |
|
| } |
| 1622 |
|
| |
| 1623 |
|
| static void |
| 1624 |
134 |
| unblock_http3_uniform_fields_free(unblock_http3_uniform_fields *fields) |
| 1625 |
|
| { |
| 1626 |
|
| size_t i; |
| 1627 |
|
| |
| 1628 |
134 |
▶ | if (fields == NULL) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (fields == NULL) { |
0 |
134 |
134 |
|
| 1629 |
0 |
| return; |
| 1630 |
|
| } |
| 1631 |
|
| |
| 1632 |
134 |
▶ | if (fields->owned_names != NULL) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (fields->owned_names != NULL) { |
72 |
62 |
134 |
|
| 1633 |
277 |
▶ | for (i = 0; i < fields->nvlen; ++i) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (i = 0; i < fields->nvlen; ++i) { |
205 |
72 |
277 |
|
| 1634 |
205 |
▶ | if (fields->owned_names[i] != NULL) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (fields->owned_names[i] != NULL) { |
1 |
204 |
205 |
|
| 1635 |
1 |
| Safefree(fields->owned_names[i]); |
| 1636 |
|
| } |
| 1637 |
|
| } |
| 1638 |
|
| |
| 1639 |
72 |
| Safefree(fields->owned_names); |
| 1640 |
|
| } |
| 1641 |
|
| |
| 1642 |
134 |
▶ | if (fields->nva != NULL) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (fields->nva != NULL) { |
72 |
62 |
134 |
|
| 1643 |
72 |
| Safefree(fields->nva); |
| 1644 |
|
| } |
| 1645 |
|
| |
| 1646 |
134 |
| fields->nva = NULL; |
| 1647 |
134 |
| fields->owned_names = NULL; |
| 1648 |
134 |
| fields->nvlen = 0; |
| 1649 |
|
| } |
| 1650 |
|
| |
| 1651 |
|
| static void |
| 1652 |
181 |
| unblock_http3_uniform_nv_static( |
| 1653 |
|
| nghttp3_nv *nv, |
| 1654 |
|
| const char *name, |
| 1655 |
|
| const char *value, |
| 1656 |
|
| size_t value_len |
| 1657 |
|
| ) |
| 1658 |
|
| { |
| 1659 |
181 |
| nv->name = (const uint8_t *)name; |
| 1660 |
181 |
| nv->namelen = strlen(name); |
| 1661 |
181 |
| nv->value = (const uint8_t *)value; |
| 1662 |
181 |
| nv->valuelen = value_len; |
| 1663 |
181 |
| nv->flags = NGHTTP3_NV_FLAG_NONE; |
| 1664 |
181 |
| } |
| 1665 |
|
| |
| 1666 |
|
| static void |
| 1667 |
150 |
| unblock_http3_uniform_nv_sv( |
| 1668 |
|
| nghttp3_nv *nv, |
| 1669 |
|
| const char *name, |
| 1670 |
|
| SV *value |
| 1671 |
|
| ) |
| 1672 |
|
| { |
| 1673 |
|
| STRLEN len; |
| 1674 |
150 |
| const char *bytes = SvPVbyte(value, len); |
| 1675 |
|
| |
| 1676 |
150 |
| unblock_http3_uniform_nv_static( |
| 1677 |
|
| nv, |
| 1678 |
|
| name, |
| 1679 |
|
| bytes, |
| 1680 |
|
| (size_t)len |
| 1681 |
|
| ); |
| 1682 |
150 |
| } |
| 1683 |
|
| |
| 1684 |
|
| static void |
| 1685 |
49 |
| unblock_http3_validate_uniform_field( |
| 1686 |
|
| int context, |
| 1687 |
|
| const uint8_t *name, |
| 1688 |
|
| size_t namelen, |
| 1689 |
|
| const uint8_t *value, |
| 1690 |
|
| size_t valuelen |
| 1691 |
|
| ) |
| 1692 |
|
| { |
| 1693 |
|
| size_t start; |
| 1694 |
|
| size_t end; |
| 1695 |
|
| |
| 1696 |
49 |
▶ | if ( |
Branch: 1 branch
| Branch | True | False | Total |
| if ( |
49 |
0 |
49 |
|
| 1697 |
49 |
| unblock_http3_ascii_equal_ci(name, namelen, "connection") |
| 1698 |
49 |
▶ | || unblock_http3_ascii_equal_ci(name, namelen, "keep-alive") |
Branch: 1 branch
| Branch | True | False | Total |
| || unblock_http3_ascii_equal_ci(name, namelen, "keep-alive") |
49 |
0 |
49 |
|
| 1699 |
49 |
▶ | || unblock_http3_ascii_equal_ci(name, namelen, "proxy-connection") |
Branch: 1 branch
| Branch | True | False | Total |
| || unblock_http3_ascii_equal_ci(name, namelen, "proxy-connection") |
49 |
0 |
49 |
|
| 1700 |
49 |
▶ | || unblock_http3_ascii_equal_ci(name, namelen, "transfer-encoding") |
Branch: 1 branch
| Branch | True | False | Total |
| || unblock_http3_ascii_equal_ci(name, namelen, "transfer-encoding") |
49 |
0 |
49 |
|
| 1701 |
49 |
▶ | || unblock_http3_ascii_equal_ci(name, namelen, "upgrade") |
Branch: 1 branch
| Branch | True | False | Total |
| || unblock_http3_ascii_equal_ci(name, namelen, "upgrade") |
0 |
49 |
49 |
|
| 1702 |
|
| ) { |
| 1703 |
0 |
| croak("HTTP/3 does not allow connection-specific field '%.*s'", |
| 1704 |
|
| (int)namelen, (const char *)name); |
| 1705 |
|
| } |
| 1706 |
|
| |
| 1707 |
49 |
▶ | if (unblock_http3_ascii_equal_ci(name, namelen, "te")) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (unblock_http3_ascii_equal_ci(name, namelen, "te")) { |
0 |
49 |
49 |
|
| 1708 |
0 |
▶ | if (context != 0) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (context != 0) { |
0 |
0 |
0 |
|
| 1709 |
0 |
| croak("HTTP/3 TE is only allowed in request headers"); |
| 1710 |
|
| } |
| 1711 |
|
| |
| 1712 |
0 |
| start = 0; |
| 1713 |
0 |
| end = valuelen; |
| 1714 |
|
| |
| 1715 |
0 |
| while ( |
| 1716 |
|
| start < end |
| 1717 |
0 |
▶ | && (value[start] == ' ' || value[start] == '\t') |
Branch: 3 branches
| Branch | True | False | Total |
| && (value[start] == ' ' || value[start] == '\t') |
0 |
0 |
0 |
| && (value[start] == ' ' || value[start] == '\t') |
0 |
0 |
0 |
| && (value[start] == ' ' || value[start] == '\t') |
0 |
0 |
0 |
|
| 1718 |
|
| ) { |
| 1719 |
0 |
| ++start; |
| 1720 |
|
| } |
| 1721 |
|
| |
| 1722 |
0 |
| while ( |
| 1723 |
|
| end > start |
| 1724 |
0 |
▶ | && (value[end - 1] == ' ' || value[end - 1] == '\t') |
Branch: 3 branches
| Branch | True | False | Total |
| && (value[end - 1] == ' ' || value[end - 1] == '\t') |
0 |
0 |
0 |
| && (value[end - 1] == ' ' || value[end - 1] == '\t') |
0 |
0 |
0 |
| && (value[end - 1] == ' ' || value[end - 1] == '\t') |
0 |
0 |
0 |
|
| 1725 |
|
| ) { |
| 1726 |
0 |
| --end; |
| 1727 |
|
| } |
| 1728 |
|
| |
| 1729 |
0 |
▶ | if ( |
Branch: 1 branch
| Branch | True | False | Total |
| if ( |
0 |
0 |
0 |
|
| 1730 |
0 |
| !unblock_http3_ascii_equal_ci( |
| 1731 |
|
| value + start, |
| 1732 |
|
| end - start, |
| 1733 |
|
| "trailers" |
| 1734 |
|
| ) |
| 1735 |
|
| ) { |
| 1736 |
0 |
| croak("HTTP/3 TE field may contain only 'trailers'"); |
| 1737 |
|
| } |
| 1738 |
|
| } |
| 1739 |
|
| |
| 1740 |
49 |
▶ | if (context == 2) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (context == 2) { |
12 |
37 |
49 |
|
| 1741 |
12 |
▶ | if (unblock_http3_ascii_equal_ci(name, namelen, "content-length")) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (unblock_http3_ascii_equal_ci(name, namelen, "content-length")) { |
0 |
12 |
12 |
|
| 1742 |
0 |
| croak("HTTP/3 Content-Length is not allowed in trailers"); |
| 1743 |
|
| } |
| 1744 |
|
| |
| 1745 |
12 |
▶ | if (unblock_http3_ascii_equal_ci(name, namelen, "host")) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (unblock_http3_ascii_equal_ci(name, namelen, "host")) { |
0 |
12 |
12 |
|
| 1746 |
0 |
| croak("HTTP/3 Host is not allowed in trailers"); |
| 1747 |
|
| } |
| 1748 |
|
| } |
| 1749 |
49 |
| } |
| 1750 |
|
| |
| 1751 |
|
| |
| 1752 |
|
| static void |
| 1753 |
269 |
| unblock_http3_uniform_validate_section( |
| 1754 |
|
| pTHX_ const uhttp_native_section *section, |
| 1755 |
|
| int context |
| 1756 |
|
| ) |
| 1757 |
|
| { |
| 1758 |
|
| Size_t i; |
| 1759 |
269 |
| Size_t count = uhttp_native_field_count(aTHX_ section); |
| 1760 |
|
| |
| 1761 |
318 |
▶ | for (i = 0; i < count; ++i) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (i = 0; i < count; ++i) { |
49 |
269 |
318 |
|
| 1762 |
|
| SV *name_sv; |
| 1763 |
|
| SV *value_sv; |
| 1764 |
|
| STRLEN namelen; |
| 1765 |
|
| STRLEN valuelen; |
| 1766 |
|
| const char *name; |
| 1767 |
|
| const char *value; |
| 1768 |
|
| |
| 1769 |
49 |
▶ | if ( |
Branch: 1 branch
| Branch | True | False | Total |
| if ( |
0 |
49 |
49 |
|
| 1770 |
49 |
| !uhttp_native_field_at( |
| 1771 |
|
| aTHX_ section, |
| 1772 |
|
| i, |
| 1773 |
|
| &name_sv, |
| 1774 |
|
| &value_sv |
| 1775 |
|
| ) |
| 1776 |
|
| ) { |
| 1777 |
0 |
| croak("Uniform field inspection failed"); |
| 1778 |
|
| } |
| 1779 |
|
| |
| 1780 |
49 |
| name = SvPVbyte(name_sv, namelen); |
| 1781 |
49 |
▶ | value = SvPVbyte(value_sv, valuelen); |
Branch: 1 branch
| Branch | True | False | Total |
| value = SvPVbyte(value_sv, valuelen); |
49 |
0 |
49 |
|
| 1782 |
|
| |
| 1783 |
49 |
| unblock_http3_validate_uniform_field( |
| 1784 |
|
| context, |
| 1785 |
|
| (const uint8_t *)name, |
| 1786 |
|
| (size_t)namelen, |
| 1787 |
|
| (const uint8_t *)value, |
| 1788 |
|
| (size_t)valuelen |
| 1789 |
|
| ); |
| 1790 |
|
| } |
| 1791 |
269 |
| } |
| 1792 |
|
| |
| 1793 |
|
| static size_t |
| 1794 |
135 |
| unblock_http3_uniform_section_size( |
| 1795 |
|
| pTHX_ const uhttp_native_section *section |
| 1796 |
|
| ) |
| 1797 |
|
| { |
| 1798 |
|
| Size_t i; |
| 1799 |
135 |
| Size_t count = uhttp_native_field_count(aTHX_ section); |
| 1800 |
135 |
| size_t total = 0; |
| 1801 |
|
| |
| 1802 |
160 |
▶ | for (i = 0; i < count; ++i) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (i = 0; i < count; ++i) { |
25 |
135 |
160 |
|
| 1803 |
|
| SV *name_sv; |
| 1804 |
|
| SV *value_sv; |
| 1805 |
|
| STRLEN namelen; |
| 1806 |
|
| STRLEN valuelen; |
| 1807 |
|
| |
| 1808 |
25 |
▶ | if ( |
Branch: 1 branch
| Branch | True | False | Total |
| if ( |
0 |
25 |
25 |
|
| 1809 |
25 |
| !uhttp_native_field_at( |
| 1810 |
|
| aTHX_ section, |
| 1811 |
|
| i, |
| 1812 |
|
| &name_sv, |
| 1813 |
|
| &value_sv |
| 1814 |
|
| ) |
| 1815 |
|
| ) { |
| 1816 |
0 |
| croak("Uniform header inspection failed"); |
| 1817 |
|
| } |
| 1818 |
|
| |
| 1819 |
25 |
| (void)SvPVbyte(name_sv, namelen); |
| 1820 |
25 |
▶ | (void)SvPVbyte(value_sv, valuelen); |
Branch: 1 branch
| Branch | True | False | Total |
| (void)SvPVbyte(value_sv, valuelen); |
25 |
0 |
25 |
|
| 1821 |
|
| |
| 1822 |
25 |
| if ( |
| 1823 |
25 |
▶ | total > SIZE_MAX - (size_t)namelen |
Branch: 1 branch
| Branch | True | False | Total |
| total > SIZE_MAX - (size_t)namelen |
25 |
0 |
25 |
|
| 1824 |
25 |
▶ | || total + (size_t)namelen > SIZE_MAX - (size_t)valuelen |
Branch: 1 branch
| Branch | True | False | Total |
| || total + (size_t)namelen > SIZE_MAX - (size_t)valuelen |
25 |
0 |
25 |
|
| 1825 |
25 |
▶ | || total + (size_t)namelen + (size_t)valuelen > SIZE_MAX - 32 |
Branch: 1 branch
| Branch | True | False | Total |
| || total + (size_t)namelen + (size_t)valuelen > SIZE_MAX - 32 |
0 |
25 |
25 |
|
| 1826 |
|
| ) { |
| 1827 |
0 |
| croak("HTTP/3 field section size overflow"); |
| 1828 |
|
| } |
| 1829 |
|
| |
| 1830 |
25 |
| total += (size_t)namelen + (size_t)valuelen + 32; |
| 1831 |
|
| } |
| 1832 |
|
| |
| 1833 |
135 |
| return total; |
| 1834 |
|
| } |
| 1835 |
|
| |
| 1836 |
|
| static size_t |
| 1837 |
154 |
| unblock_http3_uniform_pseudo_size( |
| 1838 |
|
| const char *name, |
| 1839 |
|
| SV *value |
| 1840 |
|
| ) |
| 1841 |
|
| { |
| 1842 |
|
| STRLEN valuelen; |
| 1843 |
|
| |
| 1844 |
|
| (void)SvPVbyte(value, valuelen); |
| 1845 |
154 |
| return strlen(name) + (size_t)valuelen + 32; |
| 1846 |
|
| } |
| 1847 |
|
| |
| 1848 |
|
| static void |
| 1849 |
72 |
| unblock_http3_uniform_add_section( |
| 1850 |
|
| pTHX_ unblock_http3_uniform_fields *out, |
| 1851 |
|
| size_t *index, |
| 1852 |
|
| const uhttp_native_section *section, |
| 1853 |
|
| int context |
| 1854 |
|
| ) |
| 1855 |
|
| { |
| 1856 |
|
| Size_t i; |
| 1857 |
72 |
| Size_t count = uhttp_native_field_count(aTHX_ section); |
| 1858 |
|
| |
| 1859 |
96 |
▶ | for (i = 0; i < count; ++i) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (i = 0; i < count; ++i) { |
24 |
72 |
96 |
|
| 1860 |
|
| SV *name_sv; |
| 1861 |
|
| SV *value_sv; |
| 1862 |
|
| STRLEN namelen; |
| 1863 |
|
| STRLEN valuelen; |
| 1864 |
|
| const char *name; |
| 1865 |
|
| const char *value; |
| 1866 |
24 |
| uint8_t *lower = NULL; |
| 1867 |
|
| size_t j; |
| 1868 |
24 |
| int needs_lower = 0; |
| 1869 |
|
| |
| 1870 |
24 |
▶ | if ( |
Branch: 1 branch
| Branch | True | False | Total |
| if ( |
0 |
24 |
24 |
|
| 1871 |
24 |
| !uhttp_native_field_at( |
| 1872 |
|
| aTHX_ section, |
| 1873 |
|
| i, |
| 1874 |
|
| &name_sv, |
| 1875 |
|
| &value_sv |
| 1876 |
|
| ) |
| 1877 |
|
| ) { |
| 1878 |
0 |
| croak("Uniform field inspection failed"); |
| 1879 |
|
| } |
| 1880 |
|
| |
| 1881 |
24 |
| name = SvPVbyte(name_sv, namelen); |
| 1882 |
24 |
▶ | value = SvPVbyte(value_sv, valuelen); |
Branch: 1 branch
| Branch | True | False | Total |
| value = SvPVbyte(value_sv, valuelen); |
24 |
0 |
24 |
|
| 1883 |
|
| |
| 1884 |
282 |
▶ | for (j = 0; j < (size_t)namelen; ++j) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (j = 0; j < (size_t)namelen; ++j) { |
259 |
23 |
282 |
|
| 1885 |
259 |
| uint8_t ch = (uint8_t)name[j]; |
| 1886 |
|
| |
| 1887 |
259 |
▶ | if (ch >= 'A' && ch <= 'Z') { |
Branch: 2 branches
| Branch | True | False | Total |
| if (ch >= 'A' && ch <= 'Z') { |
238 |
21 |
259 |
| if (ch >= 'A' && ch <= 'Z') { |
1 |
237 |
238 |
|
| 1888 |
1 |
| needs_lower = 1; |
| 1889 |
1 |
| break; |
| 1890 |
|
| } |
| 1891 |
|
| } |
| 1892 |
|
| |
| 1893 |
24 |
▶ | if (needs_lower) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (needs_lower) { |
1 |
23 |
24 |
|
| 1894 |
1 |
▶ | Newx(lower, namelen ? namelen : 1, uint8_t); |
Branch: 1 branch
| Branch | True | False | Total |
| Newx(lower, namelen ? namelen : 1, uint8_t); |
1 |
0 |
1 |
|
| 1895 |
|
| |
| 1896 |
9 |
▶ | for (j = 0; j < (size_t)namelen; ++j) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (j = 0; j < (size_t)namelen; ++j) { |
8 |
1 |
9 |
|
| 1897 |
8 |
| uint8_t ch = (uint8_t)name[j]; |
| 1898 |
|
| |
| 1899 |
8 |
▶ | if (ch >= 'A' && ch <= 'Z') { |
Branch: 2 branches
| Branch | True | False | Total |
| if (ch >= 'A' && ch <= 'Z') { |
8 |
0 |
8 |
| if (ch >= 'A' && ch <= 'Z') { |
1 |
7 |
8 |
|
| 1900 |
1 |
| ch = (uint8_t)(ch + ('a' - 'A')); |
| 1901 |
|
| } |
| 1902 |
|
| |
| 1903 |
8 |
| lower[j] = ch; |
| 1904 |
|
| } |
| 1905 |
|
| |
| 1906 |
1 |
| out->nva[*index].name = lower; |
| 1907 |
|
| } else { |
| 1908 |
23 |
| out->nva[*index].name = (const uint8_t *)name; |
| 1909 |
|
| } |
| 1910 |
24 |
| out->nva[*index].namelen = (size_t)namelen; |
| 1911 |
24 |
| out->nva[*index].value = (const uint8_t *)value; |
| 1912 |
24 |
| out->nva[*index].valuelen = (size_t)valuelen; |
| 1913 |
24 |
| out->nva[*index].flags = NGHTTP3_NV_FLAG_NONE; |
| 1914 |
24 |
| out->owned_names[*index] = lower; |
| 1915 |
24 |
| ++*index; |
| 1916 |
|
| } |
| 1917 |
72 |
| } |
| 1918 |
|
| |
| 1919 |
|
| static int |
| 1920 |
75 |
| unblock_http3_uniform_request_shape( |
| 1921 |
|
| pTHX_ const uhttp_native_view *view, |
| 1922 |
|
| int *is_connect, |
| 1923 |
|
| int *is_extended |
| 1924 |
|
| ) |
| 1925 |
|
| { |
| 1926 |
|
| STRLEN method_len; |
| 1927 |
|
| const char *method; |
| 1928 |
|
| |
| 1929 |
75 |
▶ | if (!SvOK(view->method) || !SvOK(view->target)) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (!SvOK(view->method) || !SvOK(view->target)) { |
75 |
0 |
75 |
| if (!SvOK(view->method) || !SvOK(view->target)) { |
0 |
75 |
75 |
|
| 1930 |
0 |
| croak("canonical Uniform request is missing method or target"); |
| 1931 |
|
| } |
| 1932 |
|
| |
| 1933 |
75 |
| method = SvPVbyte(view->method, method_len); |
| 1934 |
75 |
| *is_connect = |
| 1935 |
91 |
| method_len == 7 && memcmp(method, "CONNECT", 7) == 0 |
| 1936 |
75 |
▶ | ? 1 : 0; |
Branch: 2 branches
| Branch | True | False | Total |
| ? 1 : 0; |
16 |
59 |
75 |
| ? 1 : 0; |
16 |
0 |
16 |
|
| 1937 |
75 |
▶ | *is_extended = *is_connect && SvOK(view->protocol) ? 1 : 0; |
Branch: 2 branches
| Branch | True | False | Total |
| *is_extended = *is_connect && SvOK(view->protocol) ? 1 : 0; |
16 |
59 |
75 |
| *is_extended = *is_connect && SvOK(view->protocol) ? 1 : 0; |
12 |
4 |
16 |
|
| 1938 |
|
| |
| 1939 |
75 |
▶ | if (*is_connect) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (*is_connect) { |
16 |
59 |
75 |
|
| 1940 |
16 |
▶ | if (!SvOK(view->authority)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (!SvOK(view->authority)) { |
0 |
16 |
16 |
|
| 1941 |
0 |
| croak("HTTP/3 CONNECT request requires authority"); |
| 1942 |
|
| } |
| 1943 |
|
| |
| 1944 |
16 |
▶ | if (*is_extended && !SvOK(view->scheme)) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (*is_extended && !SvOK(view->scheme)) { |
12 |
4 |
16 |
| if (*is_extended && !SvOK(view->scheme)) { |
0 |
12 |
12 |
|
| 1945 |
0 |
| croak("HTTP/3 Extended CONNECT request requires scheme"); |
| 1946 |
|
| } |
| 1947 |
|
| } else { |
| 1948 |
59 |
▶ | if (!SvOK(view->scheme)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (!SvOK(view->scheme)) { |
0 |
59 |
59 |
|
| 1949 |
0 |
| croak("HTTP/3 request requires scheme"); |
| 1950 |
|
| } |
| 1951 |
|
| |
| 1952 |
59 |
▶ | if (!SvOK(view->authority)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (!SvOK(view->authority)) { |
0 |
59 |
59 |
|
| 1953 |
0 |
| croak("HTTP/3 request requires authority"); |
| 1954 |
|
| } |
| 1955 |
|
| } |
| 1956 |
|
| |
| 1957 |
75 |
| return 1; |
| 1958 |
|
| } |
| 1959 |
|
| |
| 1960 |
|
| static size_t |
| 1961 |
38 |
| unblock_http3_uniform_request_size( |
| 1962 |
|
| pTHX_ const uhttp_native_view *view |
| 1963 |
|
| ) |
| 1964 |
|
| { |
| 1965 |
|
| int is_connect; |
| 1966 |
|
| int is_extended; |
| 1967 |
|
| size_t total; |
| 1968 |
|
| |
| 1969 |
38 |
| unblock_http3_uniform_request_shape( |
| 1970 |
|
| aTHX_ view, |
| 1971 |
|
| &is_connect, |
| 1972 |
|
| &is_extended |
| 1973 |
|
| ); |
| 1974 |
|
| |
| 1975 |
38 |
| total = unblock_http3_uniform_section_size( |
| 1976 |
|
| aTHX_ &view->headers |
| 1977 |
|
| ); |
| 1978 |
|
| |
| 1979 |
76 |
| total += unblock_http3_uniform_pseudo_size( |
| 1980 |
|
| ":method", |
| 1981 |
38 |
| view->method |
| 1982 |
|
| ); |
| 1983 |
|
| |
| 1984 |
38 |
▶ | if (is_extended) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (is_extended) { |
6 |
32 |
38 |
|
| 1985 |
12 |
| total += unblock_http3_uniform_pseudo_size( |
| 1986 |
|
| ":protocol", |
| 1987 |
6 |
| view->protocol |
| 1988 |
|
| ); |
| 1989 |
12 |
| total += unblock_http3_uniform_pseudo_size( |
| 1990 |
|
| ":scheme", |
| 1991 |
6 |
| view->scheme |
| 1992 |
|
| ); |
| 1993 |
12 |
| total += unblock_http3_uniform_pseudo_size( |
| 1994 |
|
| ":authority", |
| 1995 |
6 |
| view->authority |
| 1996 |
|
| ); |
| 1997 |
6 |
| total += unblock_http3_uniform_pseudo_size( |
| 1998 |
|
| ":path", |
| 1999 |
6 |
| view->target |
| 2000 |
|
| ); |
| 2001 |
32 |
▶ | } else if (is_connect) { |
Branch: 1 branch
| Branch | True | False | Total |
| } else if (is_connect) { |
2 |
30 |
32 |
|
| 2002 |
2 |
| total += unblock_http3_uniform_pseudo_size( |
| 2003 |
|
| ":authority", |
| 2004 |
2 |
| view->authority |
| 2005 |
|
| ); |
| 2006 |
|
| } else { |
| 2007 |
60 |
| total += unblock_http3_uniform_pseudo_size( |
| 2008 |
|
| ":scheme", |
| 2009 |
30 |
| view->scheme |
| 2010 |
|
| ); |
| 2011 |
60 |
| total += unblock_http3_uniform_pseudo_size( |
| 2012 |
|
| ":authority", |
| 2013 |
30 |
| view->authority |
| 2014 |
|
| ); |
| 2015 |
30 |
| total += unblock_http3_uniform_pseudo_size( |
| 2016 |
|
| ":path", |
| 2017 |
30 |
| view->target |
| 2018 |
|
| ); |
| 2019 |
|
| } |
| 2020 |
|
| |
| 2021 |
38 |
| return total; |
| 2022 |
|
| } |
| 2023 |
|
| |
| 2024 |
|
| static size_t |
| 2025 |
31 |
| unblock_http3_uniform_response_size( |
| 2026 |
|
| pTHX_ const uhttp_native_view *view |
| 2027 |
|
| ) |
| 2028 |
|
| { |
| 2029 |
|
| IV status; |
| 2030 |
|
| char status_buffer[4]; |
| 2031 |
|
| |
| 2032 |
31 |
▶ | if (!SvOK(view->status)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (!SvOK(view->status)) { |
0 |
31 |
31 |
|
| 2033 |
0 |
| croak("canonical Uniform response is missing status"); |
| 2034 |
|
| } |
| 2035 |
|
| |
| 2036 |
31 |
| status = SvIV(view->status); |
| 2037 |
|
| |
| 2038 |
31 |
▶ | if (status < 100 || status > 599) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (status < 100 || status > 599) { |
31 |
0 |
31 |
| if (status < 100 || status > 599) { |
0 |
31 |
31 |
|
| 2039 |
0 |
| croak("canonical Uniform response status is invalid"); |
| 2040 |
|
| } |
| 2041 |
|
| |
| 2042 |
31 |
| snprintf(status_buffer, sizeof(status_buffer), "%ld", (long)status); |
| 2043 |
|
| |
| 2044 |
31 |
| return strlen(":status") + strlen(status_buffer) + 32 |
| 2045 |
31 |
| + unblock_http3_uniform_section_size( |
| 2046 |
|
| aTHX_ &view->headers |
| 2047 |
|
| ); |
| 2048 |
|
| } |
| 2049 |
|
| |
| 2050 |
|
| static void |
| 2051 |
37 |
| unblock_http3_uniform_request_fields( |
| 2052 |
|
| pTHX_ const uhttp_native_view *view, |
| 2053 |
|
| unblock_http3_uniform_fields *out |
| 2054 |
|
| ) |
| 2055 |
|
| { |
| 2056 |
37 |
| Size_t header_count = uhttp_native_field_count( |
| 2057 |
|
| aTHX_ &view->headers |
| 2058 |
|
| ); |
| 2059 |
|
| int is_connect; |
| 2060 |
|
| int is_extended; |
| 2061 |
|
| size_t pseudo_count; |
| 2062 |
37 |
| size_t index = 0; |
| 2063 |
|
| |
| 2064 |
37 |
| unblock_http3_uniform_request_shape( |
| 2065 |
|
| aTHX_ view, |
| 2066 |
|
| &is_connect, |
| 2067 |
|
| &is_extended |
| 2068 |
|
| ); |
| 2069 |
37 |
| unblock_http3_uniform_validate_section( |
| 2070 |
|
| aTHX_ &view->headers, |
| 2071 |
|
| 0 |
| 2072 |
|
| ); |
| 2073 |
|
| |
| 2074 |
37 |
▶ | pseudo_count = is_extended ? 5 : (is_connect ? 2 : 4); |
Branch: 2 branches
| Branch | True | False | Total |
| pseudo_count = is_extended ? 5 : (is_connect ? 2 : 4); |
31 |
6 |
37 |
| pseudo_count = is_extended ? 5 : (is_connect ? 2 : 4); |
2 |
29 |
31 |
|
| 2075 |
|
| |
| 2076 |
37 |
| Zero(out, 1, unblock_http3_uniform_fields); |
| 2077 |
37 |
| out->nvlen = pseudo_count + (size_t)header_count; |
| 2078 |
|
| |
| 2079 |
37 |
▶ | if (out->nvlen == 0) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (out->nvlen == 0) { |
0 |
37 |
37 |
|
| 2080 |
0 |
| return; |
| 2081 |
|
| } |
| 2082 |
|
| |
| 2083 |
37 |
▶ | Newxz(out->nva, out->nvlen, nghttp3_nv); |
Branch: 1 branch
| Branch | True | False | Total |
| Newxz(out->nva, out->nvlen, nghttp3_nv); |
0 |
37 |
37 |
|
| 2084 |
37 |
▶ | Newxz(out->owned_names, out->nvlen, uint8_t *); |
Branch: 1 branch
| Branch | True | False | Total |
| Newxz(out->owned_names, out->nvlen, uint8_t *); |
0 |
37 |
37 |
|
| 2085 |
|
| |
| 2086 |
37 |
| unblock_http3_uniform_nv_sv( |
| 2087 |
37 |
| &out->nva[index++], |
| 2088 |
|
| ":method", |
| 2089 |
37 |
| view->method |
| 2090 |
|
| ); |
| 2091 |
|
| |
| 2092 |
37 |
▶ | if (is_extended) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (is_extended) { |
6 |
31 |
37 |
|
| 2093 |
6 |
| unblock_http3_uniform_nv_sv( |
| 2094 |
6 |
| &out->nva[index++], |
| 2095 |
|
| ":protocol", |
| 2096 |
6 |
| view->protocol |
| 2097 |
|
| ); |
| 2098 |
6 |
| unblock_http3_uniform_nv_sv( |
| 2099 |
6 |
| &out->nva[index++], |
| 2100 |
|
| ":scheme", |
| 2101 |
6 |
| view->scheme |
| 2102 |
|
| ); |
| 2103 |
6 |
| unblock_http3_uniform_nv_sv( |
| 2104 |
6 |
| &out->nva[index++], |
| 2105 |
|
| ":authority", |
| 2106 |
6 |
| view->authority |
| 2107 |
|
| ); |
| 2108 |
6 |
| unblock_http3_uniform_nv_sv( |
| 2109 |
6 |
| &out->nva[index++], |
| 2110 |
|
| ":path", |
| 2111 |
6 |
| view->target |
| 2112 |
|
| ); |
| 2113 |
31 |
▶ | } else if (is_connect) { |
Branch: 1 branch
| Branch | True | False | Total |
| } else if (is_connect) { |
2 |
29 |
31 |
|
| 2114 |
2 |
| unblock_http3_uniform_nv_sv( |
| 2115 |
2 |
| &out->nva[index++], |
| 2116 |
|
| ":authority", |
| 2117 |
2 |
| view->authority |
| 2118 |
|
| ); |
| 2119 |
|
| } else { |
| 2120 |
29 |
| unblock_http3_uniform_nv_sv( |
| 2121 |
29 |
| &out->nva[index++], |
| 2122 |
|
| ":scheme", |
| 2123 |
29 |
| view->scheme |
| 2124 |
|
| ); |
| 2125 |
29 |
| unblock_http3_uniform_nv_sv( |
| 2126 |
29 |
| &out->nva[index++], |
| 2127 |
|
| ":authority", |
| 2128 |
29 |
| view->authority |
| 2129 |
|
| ); |
| 2130 |
29 |
| unblock_http3_uniform_nv_sv( |
| 2131 |
29 |
| &out->nva[index++], |
| 2132 |
|
| ":path", |
| 2133 |
29 |
| view->target |
| 2134 |
|
| ); |
| 2135 |
|
| } |
| 2136 |
|
| |
| 2137 |
37 |
| unblock_http3_uniform_add_section( |
| 2138 |
|
| aTHX_ out, |
| 2139 |
|
| &index, |
| 2140 |
|
| &view->headers, |
| 2141 |
|
| 0 |
| 2142 |
|
| ); |
| 2143 |
|
| } |
| 2144 |
|
| |
| 2145 |
|
| static void |
| 2146 |
31 |
| unblock_http3_uniform_response_fields( |
| 2147 |
|
| pTHX_ const uhttp_native_view *view, |
| 2148 |
|
| unblock_http3_uniform_fields *out, |
| 2149 |
|
| char status_buffer[4] |
| 2150 |
|
| ) |
| 2151 |
|
| { |
| 2152 |
31 |
| Size_t header_count = uhttp_native_field_count( |
| 2153 |
|
| aTHX_ &view->headers |
| 2154 |
|
| ); |
| 2155 |
|
| IV status; |
| 2156 |
31 |
| size_t index = 0; |
| 2157 |
|
| |
| 2158 |
31 |
▶ | if (!SvOK(view->status)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (!SvOK(view->status)) { |
0 |
31 |
31 |
|
| 2159 |
0 |
| croak("canonical Uniform response is missing status"); |
| 2160 |
|
| } |
| 2161 |
|
| |
| 2162 |
31 |
| status = SvIV(view->status); |
| 2163 |
|
| |
| 2164 |
31 |
▶ | if (status < 100 || status > 599) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (status < 100 || status > 599) { |
31 |
0 |
31 |
| if (status < 100 || status > 599) { |
0 |
31 |
31 |
|
| 2165 |
0 |
| croak("canonical Uniform response status is invalid"); |
| 2166 |
|
| } |
| 2167 |
|
| |
| 2168 |
31 |
| snprintf(status_buffer, 4, "%ld", (long)status); |
| 2169 |
31 |
| unblock_http3_uniform_validate_section( |
| 2170 |
|
| aTHX_ &view->headers, |
| 2171 |
|
| 1 |
| 2172 |
|
| ); |
| 2173 |
|
| |
| 2174 |
31 |
| Zero(out, 1, unblock_http3_uniform_fields); |
| 2175 |
31 |
| out->nvlen = 1 + (size_t)header_count; |
| 2176 |
|
| |
| 2177 |
31 |
▶ | Newxz(out->nva, out->nvlen, nghttp3_nv); |
Branch: 1 branch
| Branch | True | False | Total |
| Newxz(out->nva, out->nvlen, nghttp3_nv); |
0 |
31 |
31 |
|
| 2178 |
31 |
▶ | Newxz(out->owned_names, out->nvlen, uint8_t *); |
Branch: 1 branch
| Branch | True | False | Total |
| Newxz(out->owned_names, out->nvlen, uint8_t *); |
0 |
31 |
31 |
|
| 2179 |
|
| |
| 2180 |
31 |
| unblock_http3_uniform_nv_static( |
| 2181 |
31 |
| &out->nva[index++], |
| 2182 |
|
| ":status", |
| 2183 |
|
| status_buffer, |
| 2184 |
|
| strlen(status_buffer) |
| 2185 |
|
| ); |
| 2186 |
|
| |
| 2187 |
31 |
| unblock_http3_uniform_add_section( |
| 2188 |
|
| aTHX_ out, |
| 2189 |
|
| &index, |
| 2190 |
|
| &view->headers, |
| 2191 |
|
| 1 |
| 2192 |
|
| ); |
| 2193 |
31 |
| } |
| 2194 |
|
| |
| 2195 |
|
| static void |
| 2196 |
66 |
| unblock_http3_uniform_trailer_fields( |
| 2197 |
|
| pTHX_ const uhttp_native_view *view, |
| 2198 |
|
| unblock_http3_uniform_fields *out |
| 2199 |
|
| ) |
| 2200 |
|
| { |
| 2201 |
66 |
| Size_t count = uhttp_native_field_count( |
| 2202 |
|
| aTHX_ &view->trailers |
| 2203 |
|
| ); |
| 2204 |
66 |
| size_t index = 0; |
| 2205 |
|
| |
| 2206 |
66 |
| unblock_http3_uniform_validate_section( |
| 2207 |
|
| aTHX_ &view->trailers, |
| 2208 |
|
| 2 |
| 2209 |
|
| ); |
| 2210 |
66 |
| Zero(out, 1, unblock_http3_uniform_fields); |
| 2211 |
66 |
| out->nvlen = (size_t)count; |
| 2212 |
|
| |
| 2213 |
66 |
▶ | if (out->nvlen == 0) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (out->nvlen == 0) { |
62 |
4 |
66 |
|
| 2214 |
62 |
| return; |
| 2215 |
|
| } |
| 2216 |
|
| |
| 2217 |
4 |
▶ | Newxz(out->nva, out->nvlen, nghttp3_nv); |
Branch: 1 branch
| Branch | True | False | Total |
| Newxz(out->nva, out->nvlen, nghttp3_nv); |
0 |
4 |
4 |
|
| 2218 |
4 |
▶ | Newxz(out->owned_names, out->nvlen, uint8_t *); |
Branch: 1 branch
| Branch | True | False | Total |
| Newxz(out->owned_names, out->nvlen, uint8_t *); |
0 |
4 |
4 |
|
| 2219 |
|
| |
| 2220 |
4 |
| unblock_http3_uniform_add_section( |
| 2221 |
|
| aTHX_ out, |
| 2222 |
|
| &index, |
| 2223 |
|
| &view->trailers, |
| 2224 |
|
| 2 |
| 2225 |
|
| ); |
| 2226 |
|
| } |
| 2227 |
|
| |
| 2228 |
|
| static void |
| 2229 |
203 |
| unblock_http3_uniform_any_view( |
| 2230 |
|
| pTHX_ SV *message, |
| 2231 |
|
| uhttp_native_view *view |
| 2232 |
|
| ) |
| 2233 |
|
| { |
| 2234 |
|
| dMY_CXT; |
| 2235 |
|
| |
| 2236 |
203 |
▶ | if ( |
Branch: 1 branch
| Branch | True | False | Total |
| if ( |
0 |
203 |
203 |
|
| 2237 |
203 |
| !uhttp_native_inspect( |
| 2238 |
|
| aTHX_ &MY_CXT.uniform_api, |
| 2239 |
|
| message, |
| 2240 |
|
| view |
| 2241 |
|
| ) |
| 2242 |
|
| ) { |
| 2243 |
0 |
| croak("native Uniform fast path requires an exact canonical message"); |
| 2244 |
|
| } |
| 2245 |
203 |
| } |
| 2246 |
|
| |
| 2247 |
|
| static void |
| 2248 |
137 |
| unblock_http3_uniform_view( |
| 2249 |
|
| pTHX_ SV *message, |
| 2250 |
|
| U32 expected_kind, |
| 2251 |
|
| uhttp_native_view *view |
| 2252 |
|
| ) |
| 2253 |
|
| { |
| 2254 |
137 |
| unblock_http3_uniform_any_view( |
| 2255 |
|
| aTHX_ message, |
| 2256 |
|
| view |
| 2257 |
|
| ); |
| 2258 |
|
| |
| 2259 |
137 |
▶ | if (view->kind != expected_kind) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (view->kind != expected_kind) { |
0 |
137 |
137 |
|
| 2260 |
0 |
| croak("canonical Uniform message has the wrong kind"); |
| 2261 |
|
| } |
| 2262 |
137 |
| } |
| 2263 |
|
| |
| 2264 |
|
| |
| 2265 |
|
| typedef struct { |
| 2266 |
|
| SV *connection; |
| 2267 |
|
| HV *connection_hv; |
| 2268 |
|
| CV *service_cv; |
| 2269 |
|
| CV *request_cv; |
| 2270 |
|
| CV *respond_cv; |
| 2271 |
|
| CV *send_informational_cv; |
| 2272 |
|
| void *interpreter; |
| 2273 |
|
| } unblock_http3_consumer_context; |
| 2274 |
|
| |
| 2275 |
|
| static void * |
| 2276 |
13 |
| unblock_http3_consumer_interpreter(pTHX) |
| 2277 |
|
| { |
| 2278 |
|
| #ifdef MULTIPLICITY |
| 2279 |
|
| return (void *)aTHX; |
| 2280 |
|
| #else |
| 2281 |
13 |
| return NULL; |
| 2282 |
|
| #endif |
| 2283 |
|
| } |
| 2284 |
|
| |
| 2285 |
|
| static SV * |
| 2286 |
14 |
| unblock_http3_consumer_fetch( |
| 2287 |
|
| pTHX_ HV *hv, |
| 2288 |
|
| const char *key, |
| 2289 |
|
| I32 key_len, |
| 2290 |
|
| int required |
| 2291 |
|
| ) |
| 2292 |
|
| { |
| 2293 |
14 |
| SV **slot = hv_fetch(hv, key, key_len, 0); |
| 2294 |
|
| |
| 2295 |
14 |
▶ | if (slot == NULL) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (slot == NULL) { |
0 |
14 |
14 |
|
| 2296 |
0 |
▶ | if (required) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (required) { |
0 |
0 |
0 |
|
| 2297 |
0 |
| croak("Unblock::HTTP3 native ABI object is missing '%.*s'", |
| 2298 |
|
| (int)key_len, key); |
| 2299 |
|
| } |
| 2300 |
|
| |
| 2301 |
0 |
| return NULL; |
| 2302 |
|
| } |
| 2303 |
|
| |
| 2304 |
14 |
| return *slot; |
| 2305 |
|
| } |
| 2306 |
|
| |
| 2307 |
|
| static HV * |
| 2308 |
5 |
| unblock_http3_consumer_exact_object( |
| 2309 |
|
| pTHX_ |
| 2310 |
|
| SV *object, |
| 2311 |
|
| const char *class_name |
| 2312 |
|
| ) |
| 2313 |
|
| { |
| 2314 |
|
| HV *stash; |
| 2315 |
|
| |
| 2316 |
5 |
▶ | if ( |
Branch: 1 branch
| Branch | True | False | Total |
| if ( |
5 |
0 |
5 |
|
| 2317 |
|
| object == NULL |
| 2318 |
5 |
▶ | || !SvROK(object) |
Branch: 1 branch
| Branch | True | False | Total |
| || !SvROK(object) |
5 |
0 |
5 |
|
| 2319 |
5 |
▶ | || SvTYPE(SvRV(object)) != SVt_PVHV |
Branch: 1 branch
| Branch | True | False | Total |
| || SvTYPE(SvRV(object)) != SVt_PVHV |
5 |
0 |
5 |
|
| 2320 |
5 |
▶ | || !SvOBJECT(SvRV(object)) |
Branch: 1 branch
| Branch | True | False | Total |
| || !SvOBJECT(SvRV(object)) |
5 |
0 |
5 |
|
| 2321 |
5 |
▶ | || SvMAGICAL(SvRV(object)) |
Branch: 1 branch
| Branch | True | False | Total |
| || SvMAGICAL(SvRV(object)) |
0 |
5 |
5 |
|
| 2322 |
|
| ) { |
| 2323 |
0 |
| croak("Unblock::HTTP3 native ABI requires a plain blessed hash object"); |
| 2324 |
|
| } |
| 2325 |
|
| |
| 2326 |
5 |
| stash = gv_stashpv(class_name, 0); |
| 2327 |
|
| |
| 2328 |
5 |
▶ | if (stash == NULL || SvSTASH(SvRV(object)) != stash) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (stash == NULL || SvSTASH(SvRV(object)) != stash) { |
5 |
0 |
5 |
| if (stash == NULL || SvSTASH(SvRV(object)) != stash) { |
0 |
5 |
5 |
|
| 2329 |
0 |
| croak("Unblock::HTTP3 native ABI requires exact class %s", class_name); |
| 2330 |
|
| } |
| 2331 |
|
| |
| 2332 |
5 |
| return (HV *)SvRV(object); |
| 2333 |
|
| } |
| 2334 |
|
| |
| 2335 |
|
| static HV * |
| 2336 |
5 |
| unblock_http3_consumer_exact_connection( |
| 2337 |
|
| pTHX_ SV *object |
| 2338 |
|
| ) |
| 2339 |
|
| { |
| 2340 |
|
| HV *client_stash; |
| 2341 |
|
| HV *server_stash; |
| 2342 |
|
| HV *object_stash; |
| 2343 |
|
| |
| 2344 |
5 |
▶ | if ( |
Branch: 1 branch
| Branch | True | False | Total |
| if ( |
5 |
0 |
5 |
|
| 2345 |
|
| object == NULL |
| 2346 |
5 |
▶ | || !SvROK(object) |
Branch: 1 branch
| Branch | True | False | Total |
| || !SvROK(object) |
5 |
0 |
5 |
|
| 2347 |
5 |
▶ | || SvTYPE(SvRV(object)) != SVt_PVHV |
Branch: 1 branch
| Branch | True | False | Total |
| || SvTYPE(SvRV(object)) != SVt_PVHV |
5 |
0 |
5 |
|
| 2348 |
5 |
▶ | || !SvOBJECT(SvRV(object)) |
Branch: 1 branch
| Branch | True | False | Total |
| || !SvOBJECT(SvRV(object)) |
5 |
0 |
5 |
|
| 2349 |
5 |
▶ | || SvMAGICAL(SvRV(object)) |
Branch: 1 branch
| Branch | True | False | Total |
| || SvMAGICAL(SvRV(object)) |
0 |
5 |
5 |
|
| 2350 |
|
| ) { |
| 2351 |
0 |
| croak("Unblock::HTTP3 native ABI requires a plain blessed hash object"); |
| 2352 |
|
| } |
| 2353 |
|
| |
| 2354 |
5 |
| client_stash = gv_stashpv("Unblock::HTTP3::Client", 0); |
| 2355 |
5 |
| server_stash = gv_stashpv("Unblock::HTTP3::Server", 0); |
| 2356 |
5 |
| object_stash = SvSTASH(SvRV(object)); |
| 2357 |
|
| |
| 2358 |
5 |
▶ | if ( |
Branch: 1 branch
| Branch | True | False | Total |
| if ( |
5 |
0 |
5 |
|
| 2359 |
5 |
▶ | (client_stash == NULL || object_stash != client_stash) |
Branch: 1 branch
| Branch | True | False | Total |
| (client_stash == NULL || object_stash != client_stash) |
2 |
3 |
5 |
|
| 2360 |
2 |
▶ | && (server_stash == NULL || object_stash != server_stash) |
Branch: 2 branches
| Branch | True | False | Total |
| && (server_stash == NULL || object_stash != server_stash) |
2 |
0 |
2 |
| && (server_stash == NULL || object_stash != server_stash) |
1 |
1 |
2 |
|
| 2361 |
|
| ) { |
| 2362 |
1 |
| croak( |
| 2363 |
|
| "Unblock::HTTP3 native ABI requires exact class " |
| 2364 |
|
| "Unblock::HTTP3::Client or Unblock::HTTP3::Server" |
| 2365 |
|
| ); |
| 2366 |
|
| } |
| 2367 |
|
| |
| 2368 |
4 |
| return (HV *)SvRV(object); |
| 2369 |
|
| } |
| 2370 |
|
| |
| 2371 |
|
| static unblock_http3_consumer_context * |
| 2372 |
5 |
| unblock_http3_consumer_require_context( |
| 2373 |
|
| pTHX_ void *opaque |
| 2374 |
|
| ) |
| 2375 |
|
| { |
| 2376 |
5 |
| unblock_http3_consumer_context *context = |
| 2377 |
|
| (unblock_http3_consumer_context *)opaque; |
| 2378 |
|
| |
| 2379 |
5 |
▶ | if ( |
Branch: 1 branch
| Branch | True | False | Total |
| if ( |
5 |
0 |
5 |
|
| 2380 |
|
| context == NULL |
| 2381 |
5 |
▶ | || context->connection == NULL |
Branch: 1 branch
| Branch | True | False | Total |
| || context->connection == NULL |
5 |
0 |
5 |
|
| 2382 |
5 |
▶ | || context->connection_hv == NULL |
Branch: 1 branch
| Branch | True | False | Total |
| || context->connection_hv == NULL |
5 |
0 |
5 |
|
| 2383 |
5 |
▶ | || context->interpreter != unblock_http3_consumer_interpreter(aTHX) |
Branch: 1 branch
| Branch | True | False | Total |
| || context->interpreter != unblock_http3_consumer_interpreter(aTHX) |
0 |
5 |
5 |
|
| 2384 |
|
| ) { |
| 2385 |
0 |
| croak("Unblock::HTTP3 native consumer context is invalid"); |
| 2386 |
|
| } |
| 2387 |
|
| |
| 2388 |
5 |
| return context; |
| 2389 |
|
| } |
| 2390 |
|
| |
| 2391 |
|
| static SV * |
| 2392 |
0 |
| unblock_http3_consumer_call_scalar_2( |
| 2393 |
|
| pTHX_ |
| 2394 |
|
| CV *cv, |
| 2395 |
|
| SV *first, |
| 2396 |
|
| SV *second |
| 2397 |
|
| ) |
| 2398 |
|
| { |
| 2399 |
0 |
| dSP; |
| 2400 |
|
| int count; |
| 2401 |
|
| SV *value; |
| 2402 |
0 |
| SV *owned = NULL; |
| 2403 |
|
| |
| 2404 |
0 |
| ENTER; |
| 2405 |
0 |
| SAVETMPS; |
| 2406 |
|
| |
| 2407 |
0 |
▶ | PUSHMARK(SP); |
Branch: 1 branch
| Branch | True | False | Total |
| PUSHMARK(SP); |
0 |
0 |
0 |
|
| 2408 |
0 |
▶ | XPUSHs(first); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(first); |
0 |
0 |
0 |
|
| 2409 |
0 |
▶ | XPUSHs(second); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(second); |
0 |
0 |
0 |
|
| 2410 |
0 |
| PUTBACK; |
| 2411 |
|
| |
| 2412 |
0 |
| count = call_sv((SV *)cv, G_SCALAR); |
| 2413 |
|
| |
| 2414 |
0 |
| SPAGAIN; |
| 2415 |
|
| |
| 2416 |
0 |
▶ | if (count != 1) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (count != 1) { |
0 |
0 |
0 |
|
| 2417 |
0 |
| PUTBACK; |
| 2418 |
0 |
▶ | FREETMPS; |
Branch: 1 branch
| Branch | True | False | Total |
| FREETMPS; |
0 |
0 |
0 |
|
| 2419 |
0 |
| LEAVE; |
| 2420 |
0 |
| croak("Unblock::HTTP3 native ABI callback returned an invalid result"); |
| 2421 |
|
| } |
| 2422 |
|
| |
| 2423 |
0 |
| value = POPs; |
| 2424 |
|
| |
| 2425 |
0 |
▶ | if (SvOK(value)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (SvOK(value)) { |
0 |
0 |
0 |
|
| 2426 |
0 |
| owned = newSVsv(value); |
| 2427 |
|
| } |
| 2428 |
|
| |
| 2429 |
0 |
| PUTBACK; |
| 2430 |
0 |
▶ | FREETMPS; |
Branch: 1 branch
| Branch | True | False | Total |
| FREETMPS; |
0 |
0 |
0 |
|
| 2431 |
0 |
| LEAVE; |
| 2432 |
|
| |
| 2433 |
0 |
| return owned; |
| 2434 |
|
| } |
| 2435 |
|
| |
| 2436 |
|
| static void |
| 2437 |
0 |
| unblock_http3_consumer_call_void_1( |
| 2438 |
|
| pTHX_ |
| 2439 |
|
| CV *cv, |
| 2440 |
|
| SV *first |
| 2441 |
|
| ) |
| 2442 |
|
| { |
| 2443 |
0 |
| dSP; |
| 2444 |
|
| |
| 2445 |
0 |
| ENTER; |
| 2446 |
0 |
| SAVETMPS; |
| 2447 |
|
| |
| 2448 |
0 |
▶ | PUSHMARK(SP); |
Branch: 1 branch
| Branch | True | False | Total |
| PUSHMARK(SP); |
0 |
0 |
0 |
|
| 2449 |
0 |
▶ | XPUSHs(first); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(first); |
0 |
0 |
0 |
|
| 2450 |
0 |
| PUTBACK; |
| 2451 |
|
| |
| 2452 |
0 |
| (void)call_sv((SV *)cv, G_VOID); |
| 2453 |
|
| |
| 2454 |
0 |
▶ | FREETMPS; |
Branch: 1 branch
| Branch | True | False | Total |
| FREETMPS; |
0 |
0 |
0 |
|
| 2455 |
0 |
| LEAVE; |
| 2456 |
0 |
| } |
| 2457 |
|
| |
| 2458 |
|
| static void |
| 2459 |
0 |
| unblock_http3_consumer_call_void_2( |
| 2460 |
|
| pTHX_ |
| 2461 |
|
| CV *cv, |
| 2462 |
|
| SV *first, |
| 2463 |
|
| SV *second |
| 2464 |
|
| ) |
| 2465 |
|
| { |
| 2466 |
0 |
| dSP; |
| 2467 |
|
| |
| 2468 |
0 |
| ENTER; |
| 2469 |
0 |
| SAVETMPS; |
| 2470 |
|
| |
| 2471 |
0 |
▶ | PUSHMARK(SP); |
Branch: 1 branch
| Branch | True | False | Total |
| PUSHMARK(SP); |
0 |
0 |
0 |
|
| 2472 |
0 |
▶ | XPUSHs(first); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(first); |
0 |
0 |
0 |
|
| 2473 |
0 |
▶ | XPUSHs(second); |
Branch: 1 branch
| Branch | True | False | Total |
| XPUSHs(second); |
0 |
0 |
0 |
|
| 2474 |
0 |
| PUTBACK; |
| 2475 |
|
| |
| 2476 |
0 |
| (void)call_sv((SV *)cv, G_VOID); |
| 2477 |
|
| |
| 2478 |
0 |
▶ | FREETMPS; |
Branch: 1 branch
| Branch | True | False | Total |
| FREETMPS; |
0 |
0 |
0 |
|
| 2479 |
0 |
| LEAVE; |
| 2480 |
0 |
| } |
| 2481 |
|
| |
| 2482 |
|
| static SV * |
| 2483 |
3 |
| unblock_http3_consumer_shift_queue( |
| 2484 |
|
| pTHX_ |
| 2485 |
|
| HV *connection_hv, |
| 2486 |
|
| const char *key, |
| 2487 |
|
| I32 key_len |
| 2488 |
|
| ) |
| 2489 |
|
| { |
| 2490 |
|
| SV *queue_sv; |
| 2491 |
|
| AV *queue; |
| 2492 |
|
| |
| 2493 |
3 |
| queue_sv = unblock_http3_consumer_fetch( |
| 2494 |
|
| aTHX_ connection_hv, |
| 2495 |
|
| key, |
| 2496 |
|
| key_len, |
| 2497 |
|
| 1 |
| 2498 |
|
| ); |
| 2499 |
|
| |
| 2500 |
3 |
| if ( |
| 2501 |
3 |
▶ | !SvROK(queue_sv) |
Branch: 1 branch
| Branch | True | False | Total |
| !SvROK(queue_sv) |
3 |
0 |
3 |
|
| 2502 |
3 |
▶ | || SvTYPE(SvRV(queue_sv)) != SVt_PVAV |
Branch: 1 branch
| Branch | True | False | Total |
| || SvTYPE(SvRV(queue_sv)) != SVt_PVAV |
3 |
0 |
3 |
|
| 2503 |
3 |
▶ | || SvMAGICAL(SvRV(queue_sv)) |
Branch: 1 branch
| Branch | True | False | Total |
| || SvMAGICAL(SvRV(queue_sv)) |
3 |
0 |
3 |
|
| 2504 |
3 |
▶ | || SvOBJECT(SvRV(queue_sv)) |
Branch: 1 branch
| Branch | True | False | Total |
| || SvOBJECT(SvRV(queue_sv)) |
0 |
3 |
3 |
|
| 2505 |
|
| ) { |
| 2506 |
0 |
| croak("Unblock::HTTP3 native ABI queue storage is invalid"); |
| 2507 |
|
| } |
| 2508 |
|
| |
| 2509 |
3 |
| queue = (AV *)SvRV(queue_sv); |
| 2510 |
|
| |
| 2511 |
3 |
▶ | if (av_len(queue) < 0) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (av_len(queue) < 0) { |
0 |
3 |
3 |
|
| 2512 |
0 |
| return NULL; |
| 2513 |
|
| } |
| 2514 |
|
| |
| 2515 |
3 |
| return av_shift(queue); |
| 2516 |
|
| } |
| 2517 |
|
| |
| 2518 |
|
| static void * |
| 2519 |
5 |
| unblock_http3_consumer_create( |
| 2520 |
|
| pTHX_ SV *connection |
| 2521 |
|
| ) |
| 2522 |
|
| { |
| 2523 |
|
| unblock_http3_consumer_context *context; |
| 2524 |
|
| |
| 2525 |
5 |
| (void)unblock_http3_consumer_exact_connection( |
| 2526 |
|
| aTHX_ connection |
| 2527 |
|
| ); |
| 2528 |
|
| |
| 2529 |
4 |
| Newxz(context, 1, unblock_http3_consumer_context); |
| 2530 |
|
| |
| 2531 |
4 |
| context->connection = newSVsv(connection); |
| 2532 |
4 |
| context->connection_hv = (HV *)SvRV(context->connection); |
| 2533 |
4 |
| context->service_cv = |
| 2534 |
4 |
| get_cv("Unblock::HTTP3::Connection::_service", 0); |
| 2535 |
4 |
| context->request_cv = |
| 2536 |
4 |
| get_cv("Unblock::HTTP3::Connection::request", 0); |
| 2537 |
4 |
| context->respond_cv = |
| 2538 |
4 |
| get_cv("Unblock::HTTP3::Transaction::respond", 0); |
| 2539 |
4 |
| context->send_informational_cv = |
| 2540 |
4 |
| get_cv("Unblock::HTTP3::Transaction::send_informational", 0); |
| 2541 |
4 |
| context->interpreter = |
| 2542 |
4 |
| unblock_http3_consumer_interpreter(aTHX); |
| 2543 |
|
| |
| 2544 |
4 |
| if ( |
| 2545 |
4 |
▶ | context->service_cv == NULL |
Branch: 1 branch
| Branch | True | False | Total |
| context->service_cv == NULL |
4 |
0 |
4 |
|
| 2546 |
4 |
▶ | || context->request_cv == NULL |
Branch: 1 branch
| Branch | True | False | Total |
| || context->request_cv == NULL |
4 |
0 |
4 |
|
| 2547 |
4 |
▶ | || context->respond_cv == NULL |
Branch: 1 branch
| Branch | True | False | Total |
| || context->respond_cv == NULL |
4 |
0 |
4 |
|
| 2548 |
4 |
▶ | || context->send_informational_cv == NULL |
Branch: 1 branch
| Branch | True | False | Total |
| || context->send_informational_cv == NULL |
0 |
4 |
4 |
|
| 2549 |
|
| ) { |
| 2550 |
0 |
| SvREFCNT_dec(context->connection); |
| 2551 |
0 |
| Safefree(context); |
| 2552 |
0 |
| croak("Unblock::HTTP3 native ABI could not resolve provider callbacks"); |
| 2553 |
|
| } |
| 2554 |
|
| |
| 2555 |
4 |
| return context; |
| 2556 |
|
| } |
| 2557 |
|
| |
| 2558 |
|
| static void |
| 2559 |
0 |
| unblock_http3_consumer_service( |
| 2560 |
|
| pTHX_ void *opaque |
| 2561 |
|
| ) |
| 2562 |
|
| { |
| 2563 |
|
| unblock_http3_consumer_context *context = |
| 2564 |
0 |
| unblock_http3_consumer_require_context(aTHX_ opaque); |
| 2565 |
|
| |
| 2566 |
0 |
| unblock_http3_consumer_call_void_1( |
| 2567 |
|
| aTHX_ context->service_cv, |
| 2568 |
|
| context->connection |
| 2569 |
|
| ); |
| 2570 |
0 |
| } |
| 2571 |
|
| |
| 2572 |
|
| static int |
| 2573 |
2 |
| unblock_http3_consumer_should_service( |
| 2574 |
|
| pTHX_ unblock_http3_consumer_context *context |
| 2575 |
|
| ) |
| 2576 |
|
| { |
| 2577 |
2 |
| SV *started = unblock_http3_consumer_fetch( |
| 2578 |
|
| aTHX_ context->connection_hv, |
| 2579 |
|
| "started", |
| 2580 |
|
| 7, |
| 2581 |
|
| 1 |
| 2582 |
|
| ); |
| 2583 |
2 |
| SV *failed = unblock_http3_consumer_fetch( |
| 2584 |
|
| aTHX_ context->connection_hv, |
| 2585 |
|
| "failed", |
| 2586 |
|
| 6, |
| 2587 |
|
| 1 |
| 2588 |
|
| ); |
| 2589 |
|
| |
| 2590 |
2 |
▶ | return SvTRUE(started) && !SvTRUE(failed); |
Branch: 2 branches
| Branch | True | False | Total |
| return SvTRUE(started) && !SvTRUE(failed); |
0 |
2 |
2 |
| return SvTRUE(started) && !SvTRUE(failed); |
0 |
0 |
0 |
|
| 2591 |
|
| } |
| 2592 |
|
| |
| 2593 |
|
| static SV * |
| 2594 |
0 |
| unblock_http3_consumer_request( |
| 2595 |
|
| pTHX_ |
| 2596 |
|
| void *opaque, |
| 2597 |
|
| SV *request |
| 2598 |
|
| ) |
| 2599 |
|
| { |
| 2600 |
|
| unblock_http3_consumer_context *context = |
| 2601 |
0 |
| unblock_http3_consumer_require_context(aTHX_ opaque); |
| 2602 |
|
| |
| 2603 |
0 |
| return unblock_http3_consumer_call_scalar_2( |
| 2604 |
|
| aTHX_ |
| 2605 |
|
| context->request_cv, |
| 2606 |
|
| context->connection, |
| 2607 |
|
| request |
| 2608 |
|
| ); |
| 2609 |
|
| } |
| 2610 |
|
| |
| 2611 |
|
| static SV * |
| 2612 |
1 |
| unblock_http3_consumer_next_transaction( |
| 2613 |
|
| pTHX_ void *opaque |
| 2614 |
|
| ) |
| 2615 |
|
| { |
| 2616 |
|
| unblock_http3_consumer_context *context = |
| 2617 |
1 |
| unblock_http3_consumer_require_context(aTHX_ opaque); |
| 2618 |
|
| |
| 2619 |
1 |
▶ | if (unblock_http3_consumer_should_service(aTHX_ context)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (unblock_http3_consumer_should_service(aTHX_ context)) { |
0 |
1 |
1 |
|
| 2620 |
0 |
| unblock_http3_consumer_service(aTHX_ context); |
| 2621 |
|
| } |
| 2622 |
|
| |
| 2623 |
1 |
| return unblock_http3_consumer_shift_queue( |
| 2624 |
|
| aTHX_ |
| 2625 |
|
| context->connection_hv, |
| 2626 |
|
| "ready_transactions", |
| 2627 |
|
| 18 |
| 2628 |
|
| ); |
| 2629 |
|
| } |
| 2630 |
|
| |
| 2631 |
|
| static SV * |
| 2632 |
1 |
| unblock_http3_consumer_next_informational( |
| 2633 |
|
| pTHX_ void *opaque |
| 2634 |
|
| ) |
| 2635 |
|
| { |
| 2636 |
|
| unblock_http3_consumer_context *context = |
| 2637 |
1 |
| unblock_http3_consumer_require_context(aTHX_ opaque); |
| 2638 |
|
| |
| 2639 |
1 |
▶ | if (unblock_http3_consumer_should_service(aTHX_ context)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (unblock_http3_consumer_should_service(aTHX_ context)) { |
0 |
1 |
1 |
|
| 2640 |
0 |
| unblock_http3_consumer_service(aTHX_ context); |
| 2641 |
|
| } |
| 2642 |
|
| |
| 2643 |
1 |
| return unblock_http3_consumer_shift_queue( |
| 2644 |
|
| aTHX_ |
| 2645 |
|
| context->connection_hv, |
| 2646 |
|
| "ready_informational", |
| 2647 |
|
| 19 |
| 2648 |
|
| ); |
| 2649 |
|
| } |
| 2650 |
|
| |
| 2651 |
|
| static HV * |
| 2652 |
5 |
| unblock_http3_consumer_transaction_hv( |
| 2653 |
|
| pTHX_ SV *transaction |
| 2654 |
|
| ) |
| 2655 |
|
| { |
| 2656 |
5 |
| return unblock_http3_consumer_exact_object( |
| 2657 |
|
| aTHX_ |
| 2658 |
|
| transaction, |
| 2659 |
|
| "Unblock::HTTP3::Transaction" |
| 2660 |
|
| ); |
| 2661 |
|
| } |
| 2662 |
|
| |
| 2663 |
|
| static SV * |
| 2664 |
1 |
| unblock_http3_consumer_transaction_next_informational( |
| 2665 |
|
| pTHX_ SV *transaction |
| 2666 |
|
| ) |
| 2667 |
|
| { |
| 2668 |
1 |
| HV *hv = unblock_http3_consumer_transaction_hv( |
| 2669 |
|
| aTHX_ transaction |
| 2670 |
|
| ); |
| 2671 |
|
| |
| 2672 |
1 |
| return unblock_http3_consumer_shift_queue( |
| 2673 |
|
| aTHX_ |
| 2674 |
|
| hv, |
| 2675 |
|
| "informational", |
| 2676 |
|
| 13 |
| 2677 |
|
| ); |
| 2678 |
|
| } |
| 2679 |
|
| |
| 2680 |
|
| static SV * |
| 2681 |
1 |
| unblock_http3_consumer_transaction_request( |
| 2682 |
|
| pTHX_ SV *transaction |
| 2683 |
|
| ) |
| 2684 |
|
| { |
| 2685 |
1 |
| HV *hv = unblock_http3_consumer_transaction_hv( |
| 2686 |
|
| aTHX_ transaction |
| 2687 |
|
| ); |
| 2688 |
|
| |
| 2689 |
1 |
| return unblock_http3_consumer_fetch( |
| 2690 |
|
| aTHX_ hv, |
| 2691 |
|
| "request", |
| 2692 |
|
| 7, |
| 2693 |
|
| 1 |
| 2694 |
|
| ); |
| 2695 |
|
| } |
| 2696 |
|
| |
| 2697 |
|
| static SV * |
| 2698 |
1 |
| unblock_http3_consumer_transaction_response( |
| 2699 |
|
| pTHX_ SV *transaction |
| 2700 |
|
| ) |
| 2701 |
|
| { |
| 2702 |
1 |
| HV *hv = unblock_http3_consumer_transaction_hv( |
| 2703 |
|
| aTHX_ transaction |
| 2704 |
|
| ); |
| 2705 |
1 |
| SV *response = unblock_http3_consumer_fetch( |
| 2706 |
|
| aTHX_ hv, |
| 2707 |
|
| "response", |
| 2708 |
|
| 8, |
| 2709 |
|
| 1 |
| 2710 |
|
| ); |
| 2711 |
|
| |
| 2712 |
1 |
▶ | return SvOK(response) ? response : NULL; |
Branch: 1 branch
| Branch | True | False | Total |
| return SvOK(response) ? response : NULL; |
1 |
0 |
1 |
|
| 2713 |
|
| } |
| 2714 |
|
| |
| 2715 |
|
| static int64_t |
| 2716 |
1 |
| unblock_http3_consumer_transaction_stream_id( |
| 2717 |
|
| pTHX_ SV *transaction |
| 2718 |
|
| ) |
| 2719 |
|
| { |
| 2720 |
1 |
| HV *hv = unblock_http3_consumer_transaction_hv( |
| 2721 |
|
| aTHX_ transaction |
| 2722 |
|
| ); |
| 2723 |
1 |
| SV *stream_id = unblock_http3_consumer_fetch( |
| 2724 |
|
| aTHX_ hv, |
| 2725 |
|
| "stream_id", |
| 2726 |
|
| 9, |
| 2727 |
|
| 1 |
| 2728 |
|
| ); |
| 2729 |
|
| |
| 2730 |
1 |
| return (int64_t)SvIV(stream_id); |
| 2731 |
|
| } |
| 2732 |
|
| |
| 2733 |
|
| static uint32_t |
| 2734 |
1 |
| unblock_http3_consumer_transaction_state( |
| 2735 |
|
| pTHX_ SV *transaction |
| 2736 |
|
| ) |
| 2737 |
|
| { |
| 2738 |
1 |
| HV *hv = unblock_http3_consumer_transaction_hv( |
| 2739 |
|
| aTHX_ transaction |
| 2740 |
|
| ); |
| 2741 |
1 |
| SV *state_sv = unblock_http3_consumer_fetch( |
| 2742 |
|
| aTHX_ hv, |
| 2743 |
|
| "state", |
| 2744 |
|
| 5, |
| 2745 |
|
| 1 |
| 2746 |
|
| ); |
| 2747 |
|
| STRLEN len; |
| 2748 |
1 |
| const char *state = SvPV(state_sv, len); |
| 2749 |
|
| |
| 2750 |
1 |
▶ | if (len == 6 && memcmp(state, "active", 6) == 0) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (len == 6 && memcmp(state, "active", 6) == 0) { |
1 |
0 |
1 |
| if (len == 6 && memcmp(state, "active", 6) == 0) { |
1 |
0 |
1 |
|
| 2751 |
1 |
| return UB_HTTP3_TX_ACTIVE; |
| 2752 |
|
| } |
| 2753 |
|
| |
| 2754 |
0 |
▶ | if (len == 8 && memcmp(state, "complete", 8) == 0) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (len == 8 && memcmp(state, "complete", 8) == 0) { |
0 |
0 |
0 |
| if (len == 8 && memcmp(state, "complete", 8) == 0) { |
0 |
0 |
0 |
|
| 2755 |
0 |
| return UB_HTTP3_TX_COMPLETE; |
| 2756 |
|
| } |
| 2757 |
|
| |
| 2758 |
0 |
▶ | if (len == 9 && memcmp(state, "cancelled", 9) == 0) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (len == 9 && memcmp(state, "cancelled", 9) == 0) { |
0 |
0 |
0 |
| if (len == 9 && memcmp(state, "cancelled", 9) == 0) { |
0 |
0 |
0 |
|
| 2759 |
0 |
| return UB_HTTP3_TX_CANCELLED; |
| 2760 |
|
| } |
| 2761 |
|
| |
| 2762 |
0 |
▶ | if (len == 5 && memcmp(state, "error", 5) == 0) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (len == 5 && memcmp(state, "error", 5) == 0) { |
0 |
0 |
0 |
| if (len == 5 && memcmp(state, "error", 5) == 0) { |
0 |
0 |
0 |
|
| 2763 |
0 |
| return UB_HTTP3_TX_ERROR; |
| 2764 |
|
| } |
| 2765 |
|
| |
| 2766 |
0 |
| croak("Unblock::HTTP3 native ABI encountered an unknown Transaction state"); |
| 2767 |
|
| return UB_HTTP3_TX_ERROR; |
| 2768 |
|
| } |
| 2769 |
|
| |
| 2770 |
|
| static void |
| 2771 |
0 |
| unblock_http3_consumer_require_transaction_owner( |
| 2772 |
|
| pTHX_ |
| 2773 |
|
| unblock_http3_consumer_context *context, |
| 2774 |
|
| SV *transaction |
| 2775 |
|
| ) |
| 2776 |
|
| { |
| 2777 |
0 |
| HV *hv = unblock_http3_consumer_transaction_hv( |
| 2778 |
|
| aTHX_ transaction |
| 2779 |
|
| ); |
| 2780 |
0 |
| SV *owner = unblock_http3_consumer_fetch( |
| 2781 |
|
| aTHX_ hv, |
| 2782 |
|
| "connection", |
| 2783 |
|
| 10, |
| 2784 |
|
| 1 |
| 2785 |
|
| ); |
| 2786 |
|
| |
| 2787 |
0 |
| if ( |
| 2788 |
0 |
▶ | !SvOK(owner) |
Branch: 1 branch
| Branch | True | False | Total |
| !SvOK(owner) |
0 |
0 |
0 |
|
| 2789 |
0 |
▶ | || !SvROK(owner) |
Branch: 1 branch
| Branch | True | False | Total |
| || !SvROK(owner) |
0 |
0 |
0 |
|
| 2790 |
0 |
▶ | || SvRV(owner) != SvRV(context->connection) |
Branch: 1 branch
| Branch | True | False | Total |
| || SvRV(owner) != SvRV(context->connection) |
0 |
0 |
0 |
|
| 2791 |
|
| ) { |
| 2792 |
0 |
| croak("Transaction does not belong to this Unblock::HTTP3 Connection"); |
| 2793 |
|
| } |
| 2794 |
0 |
| } |
| 2795 |
|
| |
| 2796 |
|
| static void |
| 2797 |
0 |
| unblock_http3_consumer_respond( |
| 2798 |
|
| pTHX_ |
| 2799 |
|
| void *opaque, |
| 2800 |
|
| SV *transaction |
| 2801 |
|
| ) |
| 2802 |
|
| { |
| 2803 |
|
| unblock_http3_consumer_context *context = |
| 2804 |
0 |
| unblock_http3_consumer_require_context(aTHX_ opaque); |
| 2805 |
|
| HV *transaction_hv; |
| 2806 |
|
| SV *response; |
| 2807 |
|
| |
| 2808 |
0 |
| unblock_http3_consumer_require_transaction_owner( |
| 2809 |
|
| aTHX_ context, |
| 2810 |
|
| transaction |
| 2811 |
|
| ); |
| 2812 |
|
| |
| 2813 |
0 |
| transaction_hv = unblock_http3_consumer_exact_object( |
| 2814 |
|
| aTHX_ transaction, |
| 2815 |
|
| "Unblock::HTTP3::Transaction" |
| 2816 |
|
| ); |
| 2817 |
0 |
| response = unblock_http3_consumer_fetch( |
| 2818 |
|
| aTHX_ transaction_hv, |
| 2819 |
|
| "response", |
| 2820 |
|
| 8, |
| 2821 |
|
| 1 |
| 2822 |
|
| ); |
| 2823 |
|
| |
| 2824 |
0 |
▶ | if (!SvOK(response)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (!SvOK(response)) { |
0 |
0 |
0 |
|
| 2825 |
0 |
| croak("HTTP/3 Transaction has no response"); |
| 2826 |
|
| } |
| 2827 |
|
| |
| 2828 |
0 |
| unblock_http3_consumer_call_void_2( |
| 2829 |
|
| aTHX_ |
| 2830 |
|
| context->respond_cv, |
| 2831 |
|
| transaction, |
| 2832 |
|
| response |
| 2833 |
|
| ); |
| 2834 |
0 |
| } |
| 2835 |
|
| |
| 2836 |
|
| static void |
| 2837 |
0 |
| unblock_http3_consumer_send_informational( |
| 2838 |
|
| pTHX_ |
| 2839 |
|
| void *opaque, |
| 2840 |
|
| SV *transaction, |
| 2841 |
|
| SV *response |
| 2842 |
|
| ) |
| 2843 |
|
| { |
| 2844 |
|
| unblock_http3_consumer_context *context = |
| 2845 |
0 |
| unblock_http3_consumer_require_context(aTHX_ opaque); |
| 2846 |
|
| |
| 2847 |
0 |
| unblock_http3_consumer_require_transaction_owner( |
| 2848 |
|
| aTHX_ context, |
| 2849 |
|
| transaction |
| 2850 |
|
| ); |
| 2851 |
|
| |
| 2852 |
0 |
| unblock_http3_consumer_call_void_2( |
| 2853 |
|
| aTHX_ |
| 2854 |
|
| context->send_informational_cv, |
| 2855 |
|
| transaction, |
| 2856 |
|
| response |
| 2857 |
|
| ); |
| 2858 |
0 |
| } |
| 2859 |
|
| |
| 2860 |
|
| static int |
| 2861 |
1 |
| unblock_http3_consumer_failed( |
| 2862 |
|
| pTHX_ void *opaque |
| 2863 |
|
| ) |
| 2864 |
|
| { |
| 2865 |
|
| unblock_http3_consumer_context *context = |
| 2866 |
1 |
| unblock_http3_consumer_require_context(aTHX_ opaque); |
| 2867 |
1 |
| SV *failed = unblock_http3_consumer_fetch( |
| 2868 |
|
| aTHX_ context->connection_hv, |
| 2869 |
|
| "failed", |
| 2870 |
|
| 6, |
| 2871 |
|
| 1 |
| 2872 |
|
| ); |
| 2873 |
|
| |
| 2874 |
1 |
| return SvTRUE(failed) ? 1 : 0; |
| 2875 |
|
| } |
| 2876 |
|
| |
| 2877 |
|
| static int |
| 2878 |
1 |
| unblock_http3_consumer_error_code( |
| 2879 |
|
| pTHX_ |
| 2880 |
|
| void *opaque, |
| 2881 |
|
| uint64_t *code |
| 2882 |
|
| ) |
| 2883 |
|
| { |
| 2884 |
|
| unblock_http3_consumer_context *context = |
| 2885 |
1 |
| unblock_http3_consumer_require_context(aTHX_ opaque); |
| 2886 |
1 |
| SV *value = unblock_http3_consumer_fetch( |
| 2887 |
|
| aTHX_ context->connection_hv, |
| 2888 |
|
| "error_code", |
| 2889 |
|
| 10, |
| 2890 |
|
| 1 |
| 2891 |
|
| ); |
| 2892 |
|
| |
| 2893 |
1 |
▶ | if (!SvOK(value)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (!SvOK(value)) { |
0 |
1 |
1 |
|
| 2894 |
0 |
| return 0; |
| 2895 |
|
| } |
| 2896 |
|
| |
| 2897 |
1 |
▶ | if (code == NULL) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (code == NULL) { |
0 |
1 |
1 |
|
| 2898 |
0 |
| croak("Unblock::HTTP3 native ABI error-code output is NULL"); |
| 2899 |
|
| } |
| 2900 |
|
| |
| 2901 |
1 |
| *code = (uint64_t)SvUV(value); |
| 2902 |
1 |
| return 1; |
| 2903 |
|
| } |
| 2904 |
|
| |
| 2905 |
|
| static SV * |
| 2906 |
1 |
| unblock_http3_consumer_error( |
| 2907 |
|
| pTHX_ void *opaque |
| 2908 |
|
| ) |
| 2909 |
|
| { |
| 2910 |
|
| unblock_http3_consumer_context *context = |
| 2911 |
1 |
| unblock_http3_consumer_require_context(aTHX_ opaque); |
| 2912 |
1 |
| SV *value = unblock_http3_consumer_fetch( |
| 2913 |
|
| aTHX_ context->connection_hv, |
| 2914 |
|
| "error", |
| 2915 |
|
| 5, |
| 2916 |
|
| 1 |
| 2917 |
|
| ); |
| 2918 |
|
| |
| 2919 |
1 |
▶ | return SvOK(value) ? value : NULL; |
Branch: 1 branch
| Branch | True | False | Total |
| return SvOK(value) ? value : NULL; |
1 |
0 |
1 |
|
| 2920 |
|
| } |
| 2921 |
|
| |
| 2922 |
|
| static void |
| 2923 |
4 |
| unblock_http3_consumer_destroy( |
| 2924 |
|
| pTHX_ void *opaque |
| 2925 |
|
| ) |
| 2926 |
|
| { |
| 2927 |
4 |
| unblock_http3_consumer_context *context = |
| 2928 |
|
| (unblock_http3_consumer_context *)opaque; |
| 2929 |
|
| |
| 2930 |
4 |
▶ | if (context == NULL) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (context == NULL) { |
0 |
4 |
4 |
|
| 2931 |
0 |
| return; |
| 2932 |
|
| } |
| 2933 |
|
| |
| 2934 |
4 |
▶ | if ( |
Branch: 1 branch
| Branch | True | False | Total |
| if ( |
0 |
4 |
4 |
|
| 2935 |
4 |
| context->interpreter != unblock_http3_consumer_interpreter(aTHX) |
| 2936 |
|
| ) { |
| 2937 |
0 |
| croak("Unblock::HTTP3 native consumer context belongs to another interpreter"); |
| 2938 |
|
| } |
| 2939 |
|
| |
| 2940 |
4 |
▶ | if (context->connection != NULL) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (context->connection != NULL) { |
4 |
0 |
4 |
|
| 2941 |
4 |
| SvREFCNT_dec(context->connection); |
| 2942 |
4 |
| context->connection = NULL; |
| 2943 |
|
| } |
| 2944 |
|
| |
| 2945 |
4 |
| context->connection_hv = NULL; |
| 2946 |
4 |
| context->service_cv = NULL; |
| 2947 |
4 |
| context->request_cv = NULL; |
| 2948 |
4 |
| context->respond_cv = NULL; |
| 2949 |
4 |
| context->send_informational_cv = NULL; |
| 2950 |
4 |
| context->interpreter = NULL; |
| 2951 |
|
| |
| 2952 |
4 |
| Safefree(context); |
| 2953 |
|
| } |
| 2954 |
|
| |
| 2955 |
|
| static const ub_http3_consumer_ops_v1 |
| 2956 |
|
| unblock_http3_consumer_operations = { |
| 2957 |
|
| UB_HTTP3_CONSUMER_ABI_VERSION, |
| 2958 |
|
| sizeof(ub_http3_consumer_ops_v1), |
| 2959 |
|
| "Unblock::HTTP3 consumer ABI v1", |
| 2960 |
|
| &unblock_http3_consumer_create, |
| 2961 |
|
| &unblock_http3_consumer_service, |
| 2962 |
|
| &unblock_http3_consumer_request, |
| 2963 |
|
| &unblock_http3_consumer_next_transaction, |
| 2964 |
|
| &unblock_http3_consumer_next_informational, |
| 2965 |
|
| &unblock_http3_consumer_transaction_next_informational, |
| 2966 |
|
| &unblock_http3_consumer_transaction_request, |
| 2967 |
|
| &unblock_http3_consumer_transaction_response, |
| 2968 |
|
| &unblock_http3_consumer_transaction_stream_id, |
| 2969 |
|
| &unblock_http3_consumer_transaction_state, |
| 2970 |
|
| &unblock_http3_consumer_respond, |
| 2971 |
|
| &unblock_http3_consumer_send_informational, |
| 2972 |
|
| &unblock_http3_consumer_failed, |
| 2973 |
|
| &unblock_http3_consumer_error_code, |
| 2974 |
|
| &unblock_http3_consumer_error, |
| 2975 |
|
| &unblock_http3_consumer_destroy |
| 2976 |
|
| }; |
| 2977 |
|
| |
| 2978 |
|
| static nghttp3_nv * |
| 2979 |
6 |
| unblock_http3_fields_from_sv(SV *fields_sv, size_t *pnvlen) |
| 2980 |
|
| { |
| 2981 |
|
| AV *fields; |
| 2982 |
|
| SSize_t last; |
| 2983 |
|
| size_t nvlen; |
| 2984 |
|
| nghttp3_nv *nva; |
| 2985 |
|
| size_t i; |
| 2986 |
|
| |
| 2987 |
6 |
▶ | if (!SvROK(fields_sv) || SvTYPE(SvRV(fields_sv)) != SVt_PVAV) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (!SvROK(fields_sv) || SvTYPE(SvRV(fields_sv)) != SVt_PVAV) { |
6 |
0 |
6 |
| if (!SvROK(fields_sv) || SvTYPE(SvRV(fields_sv)) != SVt_PVAV) { |
0 |
6 |
6 |
|
| 2988 |
0 |
| croak("HTTP fields must be an array reference"); |
| 2989 |
|
| } |
| 2990 |
|
| |
| 2991 |
6 |
| fields = (AV *)SvRV(fields_sv); |
| 2992 |
6 |
| last = av_len(fields); |
| 2993 |
6 |
▶ | nvlen = last < 0 ? 0 : (size_t)last + 1; |
Branch: 1 branch
| Branch | True | False | Total |
| nvlen = last < 0 ? 0 : (size_t)last + 1; |
6 |
0 |
6 |
|
| 2994 |
|
| |
| 2995 |
6 |
▶ | if (nvlen == 0) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (nvlen == 0) { |
0 |
6 |
6 |
|
| 2996 |
0 |
| *pnvlen = 0; |
| 2997 |
0 |
| return NULL; |
| 2998 |
|
| } |
| 2999 |
|
| |
| 3000 |
6 |
▶ | Newxz(nva, nvlen, nghttp3_nv); |
Branch: 1 branch
| Branch | True | False | Total |
| Newxz(nva, nvlen, nghttp3_nv); |
0 |
6 |
6 |
|
| 3001 |
|
| |
| 3002 |
32 |
▶ | for (i = 0; i < nvlen; ++i) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (i = 0; i < nvlen; ++i) { |
26 |
6 |
32 |
|
| 3003 |
26 |
| SV **fieldp = av_fetch(fields, (SSize_t)i, 0); |
| 3004 |
|
| AV *field; |
| 3005 |
|
| SV **namep; |
| 3006 |
|
| SV **valuep; |
| 3007 |
|
| STRLEN namelen; |
| 3008 |
|
| STRLEN valuelen; |
| 3009 |
|
| const char *name; |
| 3010 |
|
| const char *value; |
| 3011 |
|
| |
| 3012 |
26 |
▶ | if ( |
Branch: 1 branch
| Branch | True | False | Total |
| if ( |
26 |
0 |
26 |
|
| 3013 |
26 |
| fieldp == NULL || |
| 3014 |
26 |
▶ | !SvROK(*fieldp) || |
Branch: 1 branch
| Branch | True | False | Total |
| !SvROK(*fieldp) || |
26 |
0 |
26 |
|
| 3015 |
26 |
▶ | SvTYPE(SvRV(*fieldp)) != SVt_PVAV |
Branch: 1 branch
| Branch | True | False | Total |
| SvTYPE(SvRV(*fieldp)) != SVt_PVAV |
0 |
26 |
26 |
|
| 3016 |
|
| ) { |
| 3017 |
0 |
| Safefree(nva); |
| 3018 |
0 |
| croak("each HTTP field must be a two-element array reference"); |
| 3019 |
|
| } |
| 3020 |
|
| |
| 3021 |
26 |
| field = (AV *)SvRV(*fieldp); |
| 3022 |
|
| |
| 3023 |
26 |
▶ | if (av_len(field) != 1) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (av_len(field) != 1) { |
0 |
26 |
26 |
|
| 3024 |
0 |
| Safefree(nva); |
| 3025 |
0 |
| croak("each HTTP field must contain exactly a name and value"); |
| 3026 |
|
| } |
| 3027 |
|
| |
| 3028 |
26 |
| namep = av_fetch(field, 0, 0); |
| 3029 |
26 |
| valuep = av_fetch(field, 1, 0); |
| 3030 |
|
| |
| 3031 |
26 |
▶ | if (namep == NULL || valuep == NULL) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (namep == NULL || valuep == NULL) { |
26 |
0 |
26 |
| if (namep == NULL || valuep == NULL) { |
0 |
26 |
26 |
|
| 3032 |
0 |
| Safefree(nva); |
| 3033 |
0 |
| croak("HTTP field name and value are required"); |
| 3034 |
|
| } |
| 3035 |
|
| |
| 3036 |
26 |
| name = SvPVbyte(*namep, namelen); |
| 3037 |
26 |
▶ | value = SvPVbyte(*valuep, valuelen); |
Branch: 1 branch
| Branch | True | False | Total |
| value = SvPVbyte(*valuep, valuelen); |
26 |
0 |
26 |
|
| 3038 |
|
| |
| 3039 |
26 |
| nva[i].name = (const uint8_t *)name; |
| 3040 |
26 |
| nva[i].value = (const uint8_t *)value; |
| 3041 |
26 |
| nva[i].namelen = (size_t)namelen; |
| 3042 |
26 |
| nva[i].valuelen = (size_t)valuelen; |
| 3043 |
26 |
| nva[i].flags = NGHTTP3_NV_FLAG_NONE; |
| 3044 |
|
| } |
| 3045 |
|
| |
| 3046 |
6 |
| *pnvlen = nvlen; |
| 3047 |
6 |
| return nva; |
| 3048 |
|
| } |
| 3049 |
|
| |
| 3050 |
|
| MODULE = Unblock::HTTP3 PACKAGE = Unblock::HTTP3::_Native |
| 3051 |
|
| |
| 3052 |
|
| PROTOTYPES: DISABLE |
| 3053 |
|
| |
| 3054 |
|
| BOOT: |
| 3055 |
|
| MY_CXT_INIT; |
| 3056 |
26 |
▶ | if (!uhttp_native_init( |
Branch: 1 branch
| Branch | True | False | Total |
| if (!uhttp_native_init( |
0 |
26 |
26 |
|
| 3057 |
|
| aTHX_ &MY_CXT.uniform_api, |
| 3058 |
|
| UHTTP_NATIVE_ABI_VERSION |
| 3059 |
|
| )) |
| 3060 |
0 |
| croak("Uniform::HTTP native FastPath ABI mismatch"); |
| 3061 |
|
| |
| 3062 |
|
| void |
| 3063 |
|
| CLONE(...) |
| 3064 |
|
| CODE: |
| 3065 |
|
| MY_CXT_CLONE; |
| 3066 |
0 |
▶ | if (!uhttp_native_init( |
Branch: 1 branch
| Branch | True | False | Total |
| if (!uhttp_native_init( |
0 |
0 |
0 |
|
| 3067 |
|
| aTHX_ &MY_CXT.uniform_api, |
| 3068 |
|
| UHTTP_NATIVE_ABI_VERSION |
| 3069 |
|
| )) |
| 3070 |
0 |
| croak("Uniform::HTTP native FastPath clone ABI mismatch"); |
| 3071 |
|
| |
| 3072 |
|
| |
| 3073 |
|
| UV |
| 3074 |
|
| _consumer_operations_address() |
| 3075 |
|
| CODE: |
| 3076 |
2 |
▶ | RETVAL = PTR2UV(&unblock_http3_consumer_operations); |
Branch: 1 branch
| Branch | True | False | Total |
| RETVAL = PTR2UV(&unblock_http3_consumer_operations); |
0 |
2 |
2 |
|
| 3077 |
|
| OUTPUT: |
| 3078 |
|
| RETVAL |
| 3079 |
|
| |
| 3080 |
|
| UV |
| 3081 |
|
| _consumer_operations_size() |
| 3082 |
|
| CODE: |
| 3083 |
3 |
▶ | RETVAL = (UV)sizeof(ub_http3_consumer_ops_v1); |
Branch: 1 branch
| Branch | True | False | Total |
| RETVAL = (UV)sizeof(ub_http3_consumer_ops_v1); |
0 |
3 |
3 |
|
| 3084 |
|
| OUTPUT: |
| 3085 |
|
| RETVAL |
| 3086 |
|
| |
| 3087 |
|
| int |
| 3088 |
|
| _consumer_context_probe(connection) |
| 3089 |
|
| SV *connection |
| 3090 |
|
| PREINIT: |
| 3091 |
|
| void *context; |
| 3092 |
|
| CODE: |
| 3093 |
4 |
| context = unblock_http3_consumer_operations.create( |
| 3094 |
|
| aTHX_ connection |
| 3095 |
|
| ); |
| 3096 |
3 |
| unblock_http3_consumer_operations.destroy( |
| 3097 |
|
| aTHX_ context |
| 3098 |
|
| ); |
| 3099 |
3 |
▶ | RETVAL = 1; |
Branch: 1 branch
| Branch | True | False | Total |
| RETVAL = 1; |
0 |
3 |
3 |
|
| 3100 |
|
| OUTPUT: |
| 3101 |
|
| RETVAL |
| 3102 |
|
| |
| 3103 |
|
| |
| 3104 |
|
| SV * |
| 3105 |
|
| _consumer_transaction_probe(transaction) |
| 3106 |
|
| SV *transaction |
| 3107 |
|
| PREINIT: |
| 3108 |
|
| AV *out; |
| 3109 |
|
| SV *request; |
| 3110 |
|
| SV *response; |
| 3111 |
|
| SV *informational; |
| 3112 |
|
| CODE: |
| 3113 |
|
| request = |
| 3114 |
1 |
| unblock_http3_consumer_operations.transaction_request( |
| 3115 |
|
| aTHX_ transaction |
| 3116 |
|
| ); |
| 3117 |
|
| response = |
| 3118 |
1 |
| unblock_http3_consumer_operations.transaction_response( |
| 3119 |
|
| aTHX_ transaction |
| 3120 |
|
| ); |
| 3121 |
|
| informational = |
| 3122 |
1 |
| unblock_http3_consumer_operations.transaction_next_informational( |
| 3123 |
|
| aTHX_ transaction |
| 3124 |
|
| ); |
| 3125 |
|
| |
| 3126 |
1 |
| out = newAV(); |
| 3127 |
1 |
| av_push( |
| 3128 |
|
| out, |
| 3129 |
|
| newSViv( |
| 3130 |
|
| (IV)unblock_http3_consumer_operations.transaction_stream_id( |
| 3131 |
|
| aTHX_ transaction |
| 3132 |
|
| ) |
| 3133 |
|
| ) |
| 3134 |
|
| ); |
| 3135 |
1 |
| av_push( |
| 3136 |
|
| out, |
| 3137 |
|
| newSVuv( |
| 3138 |
|
| (UV)unblock_http3_consumer_operations.transaction_state( |
| 3139 |
|
| aTHX_ transaction |
| 3140 |
|
| ) |
| 3141 |
|
| ) |
| 3142 |
|
| ); |
| 3143 |
1 |
| av_push(out, newSVsv(request)); |
| 3144 |
1 |
▶ | av_push( |
Branch: 1 branch
| Branch | True | False | Total |
| av_push( |
0 |
1 |
1 |
|
| 3145 |
|
| out, |
| 3146 |
|
| response == NULL |
| 3147 |
|
| ? newSV(0) |
| 3148 |
|
| : newSVsv(response) |
| 3149 |
|
| ); |
| 3150 |
1 |
▶ | av_push( |
Branch: 1 branch
| Branch | True | False | Total |
| av_push( |
0 |
1 |
1 |
|
| 3151 |
|
| out, |
| 3152 |
|
| informational == NULL |
| 3153 |
|
| ? newSV(0) |
| 3154 |
|
| : informational |
| 3155 |
|
| ); |
| 3156 |
|
| |
| 3157 |
1 |
| RETVAL = newRV_noinc((SV *)out); |
| 3158 |
|
| OUTPUT: |
| 3159 |
|
| RETVAL |
| 3160 |
|
| |
| 3161 |
|
| |
| 3162 |
|
| SV * |
| 3163 |
|
| _consumer_queue_probe(connection) |
| 3164 |
|
| SV *connection |
| 3165 |
|
| PREINIT: |
| 3166 |
|
| void *context; |
| 3167 |
|
| SV *transaction; |
| 3168 |
|
| SV *informational; |
| 3169 |
|
| SV *error; |
| 3170 |
|
| uint64_t code; |
| 3171 |
|
| int has_code; |
| 3172 |
|
| AV *out; |
| 3173 |
|
| CODE: |
| 3174 |
1 |
| context = unblock_http3_consumer_operations.create( |
| 3175 |
|
| aTHX_ connection |
| 3176 |
|
| ); |
| 3177 |
|
| |
| 3178 |
|
| transaction = |
| 3179 |
1 |
| unblock_http3_consumer_operations.next_transaction( |
| 3180 |
|
| aTHX_ context |
| 3181 |
|
| ); |
| 3182 |
|
| informational = |
| 3183 |
1 |
| unblock_http3_consumer_operations.next_informational( |
| 3184 |
|
| aTHX_ context |
| 3185 |
|
| ); |
| 3186 |
|
| has_code = |
| 3187 |
1 |
| unblock_http3_consumer_operations.error_code( |
| 3188 |
|
| aTHX_ context, |
| 3189 |
|
| &code |
| 3190 |
|
| ); |
| 3191 |
|
| error = |
| 3192 |
1 |
| unblock_http3_consumer_operations.error( |
| 3193 |
|
| aTHX_ context |
| 3194 |
|
| ); |
| 3195 |
|
| |
| 3196 |
1 |
| out = newAV(); |
| 3197 |
1 |
▶ | av_push( |
Branch: 1 branch
| Branch | True | False | Total |
| av_push( |
0 |
1 |
1 |
|
| 3198 |
|
| out, |
| 3199 |
|
| transaction == NULL |
| 3200 |
|
| ? newSV(0) |
| 3201 |
|
| : transaction |
| 3202 |
|
| ); |
| 3203 |
1 |
▶ | av_push( |
Branch: 1 branch
| Branch | True | False | Total |
| av_push( |
0 |
1 |
1 |
|
| 3204 |
|
| out, |
| 3205 |
|
| informational == NULL |
| 3206 |
|
| ? newSV(0) |
| 3207 |
|
| : informational |
| 3208 |
|
| ); |
| 3209 |
1 |
| av_push( |
| 3210 |
|
| out, |
| 3211 |
|
| newSViv( |
| 3212 |
|
| unblock_http3_consumer_operations.failed( |
| 3213 |
|
| aTHX_ context |
| 3214 |
|
| ) |
| 3215 |
|
| ) |
| 3216 |
|
| ); |
| 3217 |
1 |
| av_push(out, newSViv(has_code ? 1 : 0)); |
| 3218 |
1 |
▶ | av_push( |
Branch: 1 branch
| Branch | True | False | Total |
| av_push( |
1 |
0 |
1 |
|
| 3219 |
|
| out, |
| 3220 |
|
| has_code |
| 3221 |
|
| ? newSVuv((UV)code) |
| 3222 |
|
| : newSV(0) |
| 3223 |
|
| ); |
| 3224 |
1 |
▶ | av_push( |
Branch: 1 branch
| Branch | True | False | Total |
| av_push( |
0 |
1 |
1 |
|
| 3225 |
|
| out, |
| 3226 |
|
| error == NULL |
| 3227 |
|
| ? newSV(0) |
| 3228 |
|
| : newSVsv(error) |
| 3229 |
|
| ); |
| 3230 |
|
| |
| 3231 |
1 |
| unblock_http3_consumer_operations.destroy( |
| 3232 |
|
| aTHX_ context |
| 3233 |
|
| ); |
| 3234 |
|
| |
| 3235 |
1 |
| RETVAL = newRV_noinc((SV *)out); |
| 3236 |
|
| OUTPUT: |
| 3237 |
|
| RETVAL |
| 3238 |
|
| |
| 3239 |
|
| |
| 3240 |
|
| SV * |
| 3241 |
|
| _parse_priority(value) |
| 3242 |
|
| SV *value |
| 3243 |
|
| PREINIT: |
| 3244 |
|
| STRLEN len; |
| 3245 |
|
| const uint8_t *bytes; |
| 3246 |
|
| nghttp3_pri pri; |
| 3247 |
|
| AV *out; |
| 3248 |
|
| int rv; |
| 3249 |
|
| CODE: |
| 3250 |
6 |
| bytes = (const uint8_t *)SvPVbyte(value, len); |
| 3251 |
|
| |
| 3252 |
6 |
| pri.urgency = NGHTTP3_DEFAULT_URGENCY; |
| 3253 |
6 |
| pri.inc = 0; |
| 3254 |
|
| |
| 3255 |
6 |
| rv = nghttp3_pri_parse_priority( |
| 3256 |
|
| &pri, |
| 3257 |
|
| bytes, |
| 3258 |
|
| (size_t)len |
| 3259 |
|
| ); |
| 3260 |
|
| |
| 3261 |
6 |
▶ | if (rv != 0) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (rv != 0) { |
1 |
5 |
6 |
|
| 3262 |
1 |
| croak("invalid RFC 9218 Priority field"); |
| 3263 |
|
| } |
| 3264 |
|
| |
| 3265 |
5 |
| out = newAV(); |
| 3266 |
5 |
| av_push(out, newSVuv((UV)pri.urgency)); |
| 3267 |
5 |
| av_push(out, newSViv(pri.inc ? 1 : 0)); |
| 3268 |
|
| |
| 3269 |
5 |
| RETVAL = newRV_noinc((SV *)out); |
| 3270 |
|
| OUTPUT: |
| 3271 |
|
| RETVAL |
| 3272 |
|
| |
| 3273 |
|
| const char * |
| 3274 |
|
| _nghttp3_version() |
| 3275 |
|
| PREINIT: |
| 3276 |
|
| const nghttp3_info *info; |
| 3277 |
|
| CODE: |
| 3278 |
1 |
| info = nghttp3_version(0); |
| 3279 |
1 |
▶ | if (info == NULL || info->version_str == NULL) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (info == NULL || info->version_str == NULL) { |
1 |
0 |
1 |
| if (info == NULL || info->version_str == NULL) { |
0 |
1 |
1 |
|
| 3280 |
0 |
| croak("could not read libnghttp3 version"); |
| 3281 |
|
| } |
| 3282 |
1 |
| RETVAL = info->version_str; |
| 3283 |
|
| OUTPUT: |
| 3284 |
|
| RETVAL |
| 3285 |
|
| |
| 3286 |
|
| SV * |
| 3287 |
|
| _new_client(max_field_section_size, qpack_max_table_capacity, qpack_blocked_streams, enable_connect_protocol, h3_datagram) |
| 3288 |
|
| UV max_field_section_size |
| 3289 |
|
| UV qpack_max_table_capacity |
| 3290 |
|
| UV qpack_blocked_streams |
| 3291 |
|
| IV enable_connect_protocol |
| 3292 |
|
| IV h3_datagram |
| 3293 |
|
| CODE: |
| 3294 |
25 |
▶ | if ( |
Branch: 1 branch
| Branch | True | False | Total |
| if ( |
25 |
0 |
25 |
|
| 3295 |
25 |
▶ | (uint64_t)max_field_section_size > UNBLOCK_HTTP3_MAX_VARINT || |
Branch: 1 branch
| Branch | True | False | Total |
| (uint64_t)max_field_section_size > UNBLOCK_HTTP3_MAX_VARINT || |
24 |
1 |
25 |
|
| 3296 |
24 |
▶ | (uint64_t)qpack_max_table_capacity > UNBLOCK_HTTP3_MAX_VARINT || |
Branch: 1 branch
| Branch | True | False | Total |
| (uint64_t)qpack_max_table_capacity > UNBLOCK_HTTP3_MAX_VARINT || |
0 |
24 |
24 |
|
| 3297 |
|
| (uint64_t)qpack_blocked_streams > UNBLOCK_HTTP3_MAX_VARINT |
| 3298 |
|
| ) { |
| 3299 |
1 |
| croak("HTTP/3 setting exceeds varint maximum"); |
| 3300 |
|
| } |
| 3301 |
|
| |
| 3302 |
24 |
| RETVAL = unblock_http3_new_conn( |
| 3303 |
|
| 0, |
| 3304 |
|
| (uint64_t)max_field_section_size, |
| 3305 |
|
| (uint64_t)qpack_max_table_capacity, |
| 3306 |
|
| (uint64_t)qpack_blocked_streams, |
| 3307 |
|
| enable_connect_protocol ? 1 : 0, |
| 3308 |
|
| h3_datagram ? 1 : 0, |
| 3309 |
|
| &PL_sv_undef |
| 3310 |
|
| ); |
| 3311 |
|
| OUTPUT: |
| 3312 |
|
| RETVAL |
| 3313 |
|
| |
| 3314 |
|
| SV * |
| 3315 |
|
| _new_server(max_field_section_size, qpack_max_table_capacity, qpack_blocked_streams, enable_connect_protocol, h3_datagram, origin_list) |
| 3316 |
|
| UV max_field_section_size |
| 3317 |
|
| UV qpack_max_table_capacity |
| 3318 |
|
| UV qpack_blocked_streams |
| 3319 |
|
| IV enable_connect_protocol |
| 3320 |
|
| IV h3_datagram |
| 3321 |
|
| SV *origin_list |
| 3322 |
|
| CODE: |
| 3323 |
39 |
▶ | if ( |
Branch: 1 branch
| Branch | True | False | Total |
| if ( |
39 |
0 |
39 |
|
| 3324 |
39 |
▶ | (uint64_t)max_field_section_size > UNBLOCK_HTTP3_MAX_VARINT || |
Branch: 1 branch
| Branch | True | False | Total |
| (uint64_t)max_field_section_size > UNBLOCK_HTTP3_MAX_VARINT || |
39 |
0 |
39 |
|
| 3325 |
39 |
▶ | (uint64_t)qpack_max_table_capacity > UNBLOCK_HTTP3_MAX_VARINT || |
Branch: 1 branch
| Branch | True | False | Total |
| (uint64_t)qpack_max_table_capacity > UNBLOCK_HTTP3_MAX_VARINT || |
0 |
39 |
39 |
|
| 3326 |
|
| (uint64_t)qpack_blocked_streams > UNBLOCK_HTTP3_MAX_VARINT |
| 3327 |
|
| ) { |
| 3328 |
0 |
| croak("HTTP/3 setting exceeds varint maximum"); |
| 3329 |
|
| } |
| 3330 |
|
| |
| 3331 |
39 |
| RETVAL = unblock_http3_new_conn( |
| 3332 |
|
| 1, |
| 3333 |
|
| (uint64_t)max_field_section_size, |
| 3334 |
|
| (uint64_t)qpack_max_table_capacity, |
| 3335 |
|
| (uint64_t)qpack_blocked_streams, |
| 3336 |
|
| enable_connect_protocol ? 1 : 0, |
| 3337 |
|
| h3_datagram ? 1 : 0, |
| 3338 |
|
| origin_list |
| 3339 |
|
| ); |
| 3340 |
|
| OUTPUT: |
| 3341 |
|
| RETVAL |
| 3342 |
|
| |
| 3343 |
|
| MODULE = Unblock::HTTP3 PACKAGE = Unblock::HTTP3::_Native::Connection |
| 3344 |
|
| |
| 3345 |
|
| SV * |
| 3346 |
|
| header_pseudo(self, stream_id, name) |
| 3347 |
|
| SV *self |
| 3348 |
|
| IV stream_id |
| 3349 |
|
| SV *name |
| 3350 |
|
| PREINIT: |
| 3351 |
|
| unblock_http3_native_conn *native; |
| 3352 |
|
| unblock_http3_header_block *block; |
| 3353 |
|
| STRLEN namelen; |
| 3354 |
|
| const char *name_bytes; |
| 3355 |
|
| const unblock_http3_captured_field *field; |
| 3356 |
|
| CODE: |
| 3357 |
216 |
| native = unblock_http3_conn_from_sv(self); |
| 3358 |
216 |
| block = unblock_http3_header_block_find( |
| 3359 |
|
| native, |
| 3360 |
|
| (int64_t)stream_id |
| 3361 |
|
| ); |
| 3362 |
|
| |
| 3363 |
216 |
▶ | if (block == NULL) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (block == NULL) { |
0 |
216 |
216 |
|
| 3364 |
0 |
| croak("HTTP/3 stream has no pending header block"); |
| 3365 |
|
| } |
| 3366 |
|
| |
| 3367 |
216 |
| name_bytes = SvPVbyte(name, namelen); |
| 3368 |
216 |
| field = unblock_http3_header_block_pseudo( |
| 3369 |
|
| block, |
| 3370 |
|
| name_bytes, |
| 3371 |
|
| (size_t)namelen |
| 3372 |
|
| ); |
| 3373 |
|
| |
| 3374 |
216 |
▶ | if (field == NULL) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (field == NULL) { |
35 |
181 |
216 |
|
| 3375 |
35 |
| XSRETURN_UNDEF; |
| 3376 |
|
| } |
| 3377 |
|
| |
| 3378 |
181 |
| RETVAL = newSVpvn( |
| 3379 |
|
| (const char *)field->value, |
| 3380 |
|
| (STRLEN)field->valuelen |
| 3381 |
|
| ); |
| 3382 |
|
| OUTPUT: |
| 3383 |
|
| RETVAL |
| 3384 |
|
| |
| 3385 |
|
| SV * |
| 3386 |
|
| header_values(self, stream_id, name) |
| 3387 |
|
| SV *self |
| 3388 |
|
| IV stream_id |
| 3389 |
|
| SV *name |
| 3390 |
|
| PREINIT: |
| 3391 |
|
| unblock_http3_native_conn *native; |
| 3392 |
|
| unblock_http3_header_block *block; |
| 3393 |
|
| STRLEN namelen; |
| 3394 |
|
| const char *name_bytes; |
| 3395 |
|
| AV *values; |
| 3396 |
|
| size_t i; |
| 3397 |
|
| CODE: |
| 3398 |
37 |
| native = unblock_http3_conn_from_sv(self); |
| 3399 |
37 |
| block = unblock_http3_header_block_find( |
| 3400 |
|
| native, |
| 3401 |
|
| (int64_t)stream_id |
| 3402 |
|
| ); |
| 3403 |
|
| |
| 3404 |
37 |
▶ | if (block == NULL) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (block == NULL) { |
0 |
37 |
37 |
|
| 3405 |
0 |
| croak("HTTP/3 stream has no pending header block"); |
| 3406 |
|
| } |
| 3407 |
|
| |
| 3408 |
37 |
| name_bytes = SvPVbyte(name, namelen); |
| 3409 |
37 |
| values = newAV(); |
| 3410 |
|
| |
| 3411 |
197 |
▶ | for (i = 0; i < block->count; ++i) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (i = 0; i < block->count; ++i) { |
160 |
37 |
197 |
|
| 3412 |
160 |
| const unblock_http3_captured_field *field = |
| 3413 |
160 |
| &block->fields[i]; |
| 3414 |
|
| |
| 3415 |
160 |
| if ( |
| 3416 |
160 |
▶ | field->namelen != 0 |
Branch: 1 branch
| Branch | True | False | Total |
| field->namelen != 0 |
160 |
0 |
160 |
|
| 3417 |
160 |
▶ | && field->name[0] == ':' |
Branch: 1 branch
| Branch | True | False | Total |
| && field->name[0] == ':' |
150 |
10 |
160 |
|
| 3418 |
|
| ) { |
| 3419 |
150 |
| continue; |
| 3420 |
|
| } |
| 3421 |
|
| |
| 3422 |
10 |
▶ | if ( |
Branch: 1 branch
| Branch | True | False | Total |
| if ( |
1 |
9 |
10 |
|
| 3423 |
10 |
| unblock_http3_captured_name_equal_ci( |
| 3424 |
|
| field, |
| 3425 |
|
| name_bytes, |
| 3426 |
|
| (size_t)namelen |
| 3427 |
|
| ) |
| 3428 |
|
| ) { |
| 3429 |
1 |
| av_push( |
| 3430 |
|
| values, |
| 3431 |
|
| newSVpvn( |
| 3432 |
|
| (const char *)field->value, |
| 3433 |
|
| (STRLEN)field->valuelen |
| 3434 |
|
| ) |
| 3435 |
|
| ); |
| 3436 |
|
| } |
| 3437 |
|
| } |
| 3438 |
|
| |
| 3439 |
37 |
| RETVAL = newRV_noinc((SV *)values); |
| 3440 |
|
| OUTPUT: |
| 3441 |
|
| RETVAL |
| 3442 |
|
| |
| 3443 |
|
| int |
| 3444 |
|
| has_header(self, stream_id, name) |
| 3445 |
|
| SV *self |
| 3446 |
|
| IV stream_id |
| 3447 |
|
| SV *name |
| 3448 |
|
| PREINIT: |
| 3449 |
|
| unblock_http3_native_conn *native; |
| 3450 |
|
| unblock_http3_header_block *block; |
| 3451 |
|
| STRLEN namelen; |
| 3452 |
|
| const char *name_bytes; |
| 3453 |
|
| size_t i; |
| 3454 |
|
| CODE: |
| 3455 |
31 |
| native = unblock_http3_conn_from_sv(self); |
| 3456 |
31 |
| block = unblock_http3_header_block_find( |
| 3457 |
|
| native, |
| 3458 |
|
| (int64_t)stream_id |
| 3459 |
|
| ); |
| 3460 |
|
| |
| 3461 |
31 |
▶ | if (block == NULL) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (block == NULL) { |
0 |
31 |
31 |
|
| 3462 |
0 |
| croak("HTTP/3 stream has no pending header block"); |
| 3463 |
|
| } |
| 3464 |
|
| |
| 3465 |
31 |
| name_bytes = SvPVbyte(name, namelen); |
| 3466 |
31 |
| RETVAL = 0; |
| 3467 |
|
| |
| 3468 |
69 |
▶ | for (i = 0; i < block->count; ++i) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (i = 0; i < block->count; ++i) { |
40 |
29 |
69 |
|
| 3469 |
40 |
| const unblock_http3_captured_field *field = |
| 3470 |
40 |
| &block->fields[i]; |
| 3471 |
|
| |
| 3472 |
40 |
| if ( |
| 3473 |
40 |
▶ | field->namelen != 0 |
Branch: 1 branch
| Branch | True | False | Total |
| field->namelen != 0 |
40 |
0 |
40 |
|
| 3474 |
40 |
▶ | && field->name[0] == ':' |
Branch: 1 branch
| Branch | True | False | Total |
| && field->name[0] == ':' |
31 |
9 |
40 |
|
| 3475 |
|
| ) { |
| 3476 |
31 |
| continue; |
| 3477 |
|
| } |
| 3478 |
|
| |
| 3479 |
9 |
▶ | if ( |
Branch: 1 branch
| Branch | True | False | Total |
| if ( |
2 |
7 |
9 |
|
| 3480 |
9 |
| unblock_http3_captured_name_equal_ci( |
| 3481 |
|
| field, |
| 3482 |
|
| name_bytes, |
| 3483 |
|
| (size_t)namelen |
| 3484 |
|
| ) |
| 3485 |
|
| ) { |
| 3486 |
2 |
| RETVAL = 1; |
| 3487 |
2 |
| break; |
| 3488 |
|
| } |
| 3489 |
|
| } |
| 3490 |
|
| OUTPUT: |
| 3491 |
|
| RETVAL |
| 3492 |
|
| |
| 3493 |
|
| SV * |
| 3494 |
|
| receive_uniform_request(self, stream_id, method, target, scheme, authority, protocol, fin) |
| 3495 |
|
| SV *self |
| 3496 |
|
| IV stream_id |
| 3497 |
|
| SV *method |
| 3498 |
|
| SV *target |
| 3499 |
|
| SV *scheme |
| 3500 |
|
| SV *authority |
| 3501 |
|
| SV *protocol |
| 3502 |
|
| IV fin |
| 3503 |
|
| PREINIT: |
| 3504 |
|
| unblock_http3_native_conn *native; |
| 3505 |
|
| unblock_http3_header_block *block; |
| 3506 |
|
| unblock_http3_header_block *removed; |
| 3507 |
|
| CODE: |
| 3508 |
36 |
| native = unblock_http3_conn_from_sv(self); |
| 3509 |
36 |
| block = unblock_http3_header_block_find( |
| 3510 |
|
| native, |
| 3511 |
|
| (int64_t)stream_id |
| 3512 |
|
| ); |
| 3513 |
|
| |
| 3514 |
36 |
▶ | if (block == NULL) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (block == NULL) { |
0 |
36 |
36 |
|
| 3515 |
0 |
| croak("HTTP/3 stream has no pending header block"); |
| 3516 |
|
| } |
| 3517 |
|
| |
| 3518 |
36 |
| RETVAL = unblock_http3_header_block_uniform_request( |
| 3519 |
|
| aTHX_ block, |
| 3520 |
|
| method, |
| 3521 |
|
| target, |
| 3522 |
|
| scheme, |
| 3523 |
|
| authority, |
| 3524 |
|
| protocol, |
| 3525 |
|
| fin ? 1 : 0 |
| 3526 |
|
| ); |
| 3527 |
|
| |
| 3528 |
36 |
| removed = unblock_http3_header_block_remove( |
| 3529 |
|
| native, |
| 3530 |
|
| (int64_t)stream_id |
| 3531 |
|
| ); |
| 3532 |
36 |
| unblock_http3_header_block_free(removed); |
| 3533 |
|
| OUTPUT: |
| 3534 |
|
| RETVAL |
| 3535 |
|
| |
| 3536 |
|
| SV * |
| 3537 |
|
| receive_uniform_response(self, stream_id, status, fin) |
| 3538 |
|
| SV *self |
| 3539 |
|
| IV stream_id |
| 3540 |
|
| IV status |
| 3541 |
|
| IV fin |
| 3542 |
|
| PREINIT: |
| 3543 |
|
| unblock_http3_native_conn *native; |
| 3544 |
|
| unblock_http3_header_block *block; |
| 3545 |
|
| unblock_http3_header_block *removed; |
| 3546 |
|
| CODE: |
| 3547 |
31 |
| native = unblock_http3_conn_from_sv(self); |
| 3548 |
31 |
| block = unblock_http3_header_block_find( |
| 3549 |
|
| native, |
| 3550 |
|
| (int64_t)stream_id |
| 3551 |
|
| ); |
| 3552 |
|
| |
| 3553 |
31 |
▶ | if (block == NULL) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (block == NULL) { |
0 |
31 |
31 |
|
| 3554 |
0 |
| croak("HTTP/3 stream has no pending header block"); |
| 3555 |
|
| } |
| 3556 |
|
| |
| 3557 |
31 |
| RETVAL = unblock_http3_header_block_uniform_response( |
| 3558 |
|
| aTHX_ block, |
| 3559 |
|
| status, |
| 3560 |
|
| fin ? 1 : 0 |
| 3561 |
|
| ); |
| 3562 |
|
| |
| 3563 |
31 |
| removed = unblock_http3_header_block_remove( |
| 3564 |
|
| native, |
| 3565 |
|
| (int64_t)stream_id |
| 3566 |
|
| ); |
| 3567 |
31 |
| unblock_http3_header_block_free(removed); |
| 3568 |
|
| OUTPUT: |
| 3569 |
|
| RETVAL |
| 3570 |
|
| |
| 3571 |
|
| void |
| 3572 |
|
| discard_header_block(self, stream_id) |
| 3573 |
|
| SV *self |
| 3574 |
|
| IV stream_id |
| 3575 |
|
| PREINIT: |
| 3576 |
|
| unblock_http3_native_conn *native; |
| 3577 |
|
| unblock_http3_header_block *block; |
| 3578 |
|
| CODE: |
| 3579 |
9 |
| native = unblock_http3_conn_from_sv(self); |
| 3580 |
9 |
| block = unblock_http3_header_block_remove( |
| 3581 |
|
| native, |
| 3582 |
|
| (int64_t)stream_id |
| 3583 |
|
| ); |
| 3584 |
9 |
| unblock_http3_header_block_free(block); |
| 3585 |
|
| |
| 3586 |
|
| const char * |
| 3587 |
|
| role(self) |
| 3588 |
|
| SV *self |
| 3589 |
|
| PREINIT: |
| 3590 |
|
| unblock_http3_native_conn *native; |
| 3591 |
|
| CODE: |
| 3592 |
3 |
| native = unblock_http3_conn_from_sv(self); |
| 3593 |
2 |
▶ | RETVAL = native->is_server ? "server" : "client"; |
Branch: 1 branch
| Branch | True | False | Total |
| RETVAL = native->is_server ? "server" : "client"; |
1 |
1 |
2 |
|
| 3594 |
|
| OUTPUT: |
| 3595 |
|
| RETVAL |
| 3596 |
|
| |
| 3597 |
|
| void |
| 3598 |
|
| set_max_client_streams_bidi(self, max_streams) |
| 3599 |
|
| SV *self |
| 3600 |
|
| UV max_streams |
| 3601 |
|
| PREINIT: |
| 3602 |
|
| unblock_http3_native_conn *native; |
| 3603 |
|
| CODE: |
| 3604 |
48 |
| native = unblock_http3_conn_from_sv(self); |
| 3605 |
|
| |
| 3606 |
48 |
▶ | if (!native->is_server) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (!native->is_server) { |
0 |
48 |
48 |
|
| 3607 |
0 |
| croak("client stream limit synchronization requires a server connection"); |
| 3608 |
|
| } |
| 3609 |
|
| |
| 3610 |
48 |
| nghttp3_conn_set_max_client_streams_bidi( |
| 3611 |
|
| native->conn, |
| 3612 |
|
| (uint64_t)max_streams |
| 3613 |
|
| ); |
| 3614 |
|
| |
| 3615 |
|
| void |
| 3616 |
|
| set_client_stream_priority(self, stream_id, value) |
| 3617 |
|
| SV *self |
| 3618 |
|
| IV stream_id |
| 3619 |
|
| SV *value |
| 3620 |
|
| PREINIT: |
| 3621 |
|
| unblock_http3_native_conn *native; |
| 3622 |
|
| STRLEN len; |
| 3623 |
|
| const uint8_t *bytes; |
| 3624 |
|
| int rv; |
| 3625 |
|
| CODE: |
| 3626 |
2 |
| native = unblock_http3_conn_from_sv(self); |
| 3627 |
|
| |
| 3628 |
2 |
▶ | if (native->is_server) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (native->is_server) { |
0 |
2 |
2 |
|
| 3629 |
0 |
| croak("client stream priority update requires a client connection"); |
| 3630 |
|
| } |
| 3631 |
|
| |
| 3632 |
2 |
| bytes = (const uint8_t *)SvPVbyte(value, len); |
| 3633 |
|
| |
| 3634 |
2 |
| rv = nghttp3_conn_set_client_stream_priority( |
| 3635 |
|
| native->conn, |
| 3636 |
|
| (int64_t)stream_id, |
| 3637 |
|
| bytes, |
| 3638 |
|
| (size_t)len |
| 3639 |
|
| ); |
| 3640 |
|
| |
| 3641 |
2 |
▶ | if (rv != 0) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (rv != 0) { |
0 |
2 |
2 |
|
| 3642 |
0 |
| unblock_http3_fail("could not update client HTTP priority", rv); |
| 3643 |
|
| } |
| 3644 |
|
| |
| 3645 |
|
| SV * |
| 3646 |
|
| get_server_stream_priority(self, stream_id) |
| 3647 |
|
| SV *self |
| 3648 |
|
| IV stream_id |
| 3649 |
|
| PREINIT: |
| 3650 |
|
| unblock_http3_native_conn *native; |
| 3651 |
|
| nghttp3_pri pri; |
| 3652 |
|
| AV *out; |
| 3653 |
|
| int rv; |
| 3654 |
|
| CODE: |
| 3655 |
9 |
| native = unblock_http3_conn_from_sv(self); |
| 3656 |
|
| |
| 3657 |
9 |
▶ | if (!native->is_server) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (!native->is_server) { |
0 |
9 |
9 |
|
| 3658 |
0 |
| croak("stream priority inspection requires a server connection"); |
| 3659 |
|
| } |
| 3660 |
|
| |
| 3661 |
9 |
| rv = nghttp3_conn_get_stream_priority2( |
| 3662 |
|
| native->conn, |
| 3663 |
|
| &pri, |
| 3664 |
|
| (int64_t)stream_id |
| 3665 |
|
| ); |
| 3666 |
|
| |
| 3667 |
9 |
▶ | if (rv != 0) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (rv != 0) { |
0 |
9 |
9 |
|
| 3668 |
0 |
| unblock_http3_fail("could not inspect HTTP stream priority", rv); |
| 3669 |
|
| } |
| 3670 |
|
| |
| 3671 |
9 |
| out = newAV(); |
| 3672 |
9 |
| av_push(out, newSVuv((UV)pri.urgency)); |
| 3673 |
9 |
| av_push(out, newSViv(pri.inc ? 1 : 0)); |
| 3674 |
|
| |
| 3675 |
9 |
| RETVAL = newRV_noinc((SV *)out); |
| 3676 |
|
| OUTPUT: |
| 3677 |
|
| RETVAL |
| 3678 |
|
| |
| 3679 |
|
| void |
| 3680 |
|
| set_server_stream_priority(self, stream_id, urgency, incremental) |
| 3681 |
|
| SV *self |
| 3682 |
|
| IV stream_id |
| 3683 |
|
| UV urgency |
| 3684 |
|
| IV incremental |
| 3685 |
|
| PREINIT: |
| 3686 |
|
| unblock_http3_native_conn *native; |
| 3687 |
|
| nghttp3_pri pri; |
| 3688 |
|
| int rv; |
| 3689 |
|
| CODE: |
| 3690 |
1 |
| native = unblock_http3_conn_from_sv(self); |
| 3691 |
|
| |
| 3692 |
1 |
▶ | if (!native->is_server) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (!native->is_server) { |
0 |
1 |
1 |
|
| 3693 |
0 |
| croak("server stream priority override requires a server connection"); |
| 3694 |
|
| } |
| 3695 |
|
| |
| 3696 |
1 |
▶ | if (urgency > NGHTTP3_URGENCY_LOW) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (urgency > NGHTTP3_URGENCY_LOW) { |
0 |
1 |
1 |
|
| 3697 |
0 |
| croak("HTTP urgency must be from 0 through 7"); |
| 3698 |
|
| } |
| 3699 |
|
| |
| 3700 |
1 |
▶ | if (incremental != 0 && incremental != 1) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (incremental != 0 && incremental != 1) { |
1 |
0 |
1 |
| if (incremental != 0 && incremental != 1) { |
0 |
1 |
1 |
|
| 3701 |
0 |
| croak("HTTP incremental priority must be 0 or 1"); |
| 3702 |
|
| } |
| 3703 |
|
| |
| 3704 |
1 |
| pri.urgency = (uint32_t)urgency; |
| 3705 |
1 |
| pri.inc = incremental ? 1 : 0; |
| 3706 |
|
| |
| 3707 |
1 |
| rv = nghttp3_conn_set_server_stream_priority( |
| 3708 |
|
| native->conn, |
| 3709 |
|
| (int64_t)stream_id, |
| 3710 |
|
| &pri |
| 3711 |
|
| ); |
| 3712 |
|
| |
| 3713 |
1 |
▶ | if (rv != 0) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (rv != 0) { |
0 |
1 |
1 |
|
| 3714 |
0 |
| unblock_http3_fail("could not override server HTTP priority", rv); |
| 3715 |
|
| } |
| 3716 |
|
| |
| 3717 |
|
| void |
| 3718 |
|
| bind_streams(self, control_stream_id, qenc_stream_id, qdec_stream_id) |
| 3719 |
|
| SV *self |
| 3720 |
|
| IV control_stream_id |
| 3721 |
|
| IV qenc_stream_id |
| 3722 |
|
| IV qdec_stream_id |
| 3723 |
|
| PREINIT: |
| 3724 |
|
| unblock_http3_native_conn *native; |
| 3725 |
|
| int rv; |
| 3726 |
|
| CODE: |
| 3727 |
30 |
| native = unblock_http3_conn_from_sv(self); |
| 3728 |
|
| |
| 3729 |
30 |
| rv = nghttp3_conn_bind_control_stream( |
| 3730 |
|
| native->conn, |
| 3731 |
|
| (int64_t)control_stream_id |
| 3732 |
|
| ); |
| 3733 |
30 |
▶ | if (rv != 0) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (rv != 0) { |
0 |
30 |
30 |
|
| 3734 |
0 |
| unblock_http3_fail("could not bind HTTP/3 control stream", rv); |
| 3735 |
|
| } |
| 3736 |
|
| |
| 3737 |
30 |
| rv = nghttp3_conn_bind_qpack_streams( |
| 3738 |
|
| native->conn, |
| 3739 |
|
| (int64_t)qenc_stream_id, |
| 3740 |
|
| (int64_t)qdec_stream_id |
| 3741 |
|
| ); |
| 3742 |
30 |
▶ | if (rv != 0) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (rv != 0) { |
0 |
30 |
30 |
|
| 3743 |
0 |
| unblock_http3_fail("could not bind HTTP/3 QPACK streams", rv); |
| 3744 |
|
| } |
| 3745 |
|
| |
| 3746 |
|
| SV * |
| 3747 |
|
| read_stream(self, stream_id, bytes, fin, timestamp) |
| 3748 |
|
| SV *self |
| 3749 |
|
| IV stream_id |
| 3750 |
|
| SV *bytes |
| 3751 |
|
| IV fin |
| 3752 |
|
| UV timestamp |
| 3753 |
|
| PREINIT: |
| 3754 |
|
| unblock_http3_native_conn *native; |
| 3755 |
|
| STRLEN len; |
| 3756 |
|
| const char *data; |
| 3757 |
|
| nghttp3_ssize rv; |
| 3758 |
|
| AV *out; |
| 3759 |
|
| uint64_t app_error_code; |
| 3760 |
|
| CODE: |
| 3761 |
314 |
| native = unblock_http3_conn_from_sv(self); |
| 3762 |
314 |
| data = SvPVbyte(bytes, len); |
| 3763 |
|
| |
| 3764 |
314 |
| rv = nghttp3_conn_read_stream2( |
| 3765 |
|
| native->conn, |
| 3766 |
|
| (int64_t)stream_id, |
| 3767 |
|
| (const uint8_t *)data, |
| 3768 |
|
| (size_t)len, |
| 3769 |
|
| fin ? 1 : 0, |
| 3770 |
|
| (nghttp3_tstamp)timestamp |
| 3771 |
|
| ); |
| 3772 |
|
| |
| 3773 |
314 |
| out = newAV(); |
| 3774 |
|
| |
| 3775 |
314 |
▶ | if (rv < 0) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (rv < 0) { |
23 |
291 |
314 |
|
| 3776 |
23 |
| native->fatal = 1; |
| 3777 |
|
| app_error_code = |
| 3778 |
23 |
| nghttp3_err_infer_quic_app_error_code((int)rv); |
| 3779 |
|
| |
| 3780 |
23 |
| av_push(out, newSV(0)); |
| 3781 |
23 |
| av_push(out, newSViv((IV)rv)); |
| 3782 |
23 |
| av_push(out, newSVuv((UV)app_error_code)); |
| 3783 |
23 |
| av_push(out, newSVpv(nghttp3_strerror((int)rv), 0)); |
| 3784 |
|
| } else { |
| 3785 |
291 |
| av_push(out, newSViv((IV)rv)); |
| 3786 |
|
| } |
| 3787 |
|
| |
| 3788 |
314 |
| RETVAL = newRV_noinc((SV *)out); |
| 3789 |
|
| OUTPUT: |
| 3790 |
|
| RETVAL |
| 3791 |
|
| |
| 3792 |
|
| SV * |
| 3793 |
|
| next_write(self) |
| 3794 |
|
| SV *self |
| 3795 |
|
| PREINIT: |
| 3796 |
|
| unblock_http3_native_conn *native; |
| 3797 |
|
| nghttp3_vec vec[16]; |
| 3798 |
|
| nghttp3_ssize nvec; |
| 3799 |
|
| int64_t stream_id; |
| 3800 |
|
| int fin; |
| 3801 |
|
| SV *payload; |
| 3802 |
|
| AV *out; |
| 3803 |
|
| nghttp3_ssize i; |
| 3804 |
|
| CODE: |
| 3805 |
942 |
| native = unblock_http3_conn_from_sv(self); |
| 3806 |
942 |
| stream_id = -1; |
| 3807 |
942 |
| fin = 0; |
| 3808 |
|
| |
| 3809 |
942 |
| nvec = nghttp3_conn_writev_stream( |
| 3810 |
|
| native->conn, |
| 3811 |
|
| &stream_id, |
| 3812 |
|
| &fin, |
| 3813 |
|
| vec, |
| 3814 |
|
| 16 |
| 3815 |
|
| ); |
| 3816 |
|
| |
| 3817 |
942 |
▶ | if (nvec < 0) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (nvec < 0) { |
0 |
942 |
942 |
|
| 3818 |
0 |
| unblock_http3_fail("could not obtain HTTP/3 output", (int)nvec); |
| 3819 |
|
| } |
| 3820 |
|
| |
| 3821 |
942 |
▶ | if (nvec == 0 && stream_id == -1) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (nvec == 0 && stream_id == -1) { |
686 |
256 |
942 |
| if (nvec == 0 && stream_id == -1) { |
675 |
11 |
686 |
|
| 3822 |
675 |
| XSRETURN_UNDEF; |
| 3823 |
|
| } |
| 3824 |
|
| |
| 3825 |
267 |
| payload = newSVpvn("", 0); |
| 3826 |
|
| |
| 3827 |
583 |
▶ | for (i = 0; i < nvec; ++i) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (i = 0; i < nvec; ++i) { |
316 |
267 |
583 |
|
| 3828 |
316 |
| sv_catpvn( |
| 3829 |
|
| payload, |
| 3830 |
|
| (const char *)vec[i].base, |
| 3831 |
|
| (STRLEN)vec[i].len |
| 3832 |
|
| ); |
| 3833 |
|
| } |
| 3834 |
|
| |
| 3835 |
267 |
| out = newAV(); |
| 3836 |
267 |
| av_push(out, newSViv((IV)stream_id)); |
| 3837 |
267 |
| av_push(out, payload); |
| 3838 |
267 |
| av_push(out, newSViv(fin ? 1 : 0)); |
| 3839 |
|
| |
| 3840 |
267 |
| RETVAL = newRV_noinc((SV *)out); |
| 3841 |
|
| OUTPUT: |
| 3842 |
|
| RETVAL |
| 3843 |
|
| |
| 3844 |
|
| void |
| 3845 |
|
| add_write_offset(self, stream_id, amount) |
| 3846 |
|
| SV *self |
| 3847 |
|
| IV stream_id |
| 3848 |
|
| UV amount |
| 3849 |
|
| PREINIT: |
| 3850 |
|
| unblock_http3_native_conn *native; |
| 3851 |
|
| int rv; |
| 3852 |
|
| CODE: |
| 3853 |
267 |
| native = unblock_http3_conn_from_sv(self); |
| 3854 |
|
| |
| 3855 |
267 |
| rv = nghttp3_conn_add_write_offset( |
| 3856 |
|
| native->conn, |
| 3857 |
|
| (int64_t)stream_id, |
| 3858 |
|
| (size_t)amount |
| 3859 |
|
| ); |
| 3860 |
|
| |
| 3861 |
267 |
▶ | if (rv != 0) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (rv != 0) { |
0 |
267 |
267 |
|
| 3862 |
0 |
| unblock_http3_fail("could not advance HTTP/3 write offset", rv); |
| 3863 |
|
| } |
| 3864 |
|
| |
| 3865 |
|
| void |
| 3866 |
|
| block_stream(self, stream_id) |
| 3867 |
|
| SV *self |
| 3868 |
|
| IV stream_id |
| 3869 |
|
| PREINIT: |
| 3870 |
|
| unblock_http3_native_conn *native; |
| 3871 |
|
| CODE: |
| 3872 |
10 |
| native = unblock_http3_conn_from_sv(self); |
| 3873 |
|
| |
| 3874 |
10 |
| nghttp3_conn_block_stream( |
| 3875 |
|
| native->conn, |
| 3876 |
|
| (int64_t)stream_id |
| 3877 |
|
| ); |
| 3878 |
|
| |
| 3879 |
|
| void |
| 3880 |
|
| unblock_stream(self, stream_id) |
| 3881 |
|
| SV *self |
| 3882 |
|
| IV stream_id |
| 3883 |
|
| PREINIT: |
| 3884 |
|
| unblock_http3_native_conn *native; |
| 3885 |
|
| int rv; |
| 3886 |
|
| CODE: |
| 3887 |
9 |
| native = unblock_http3_conn_from_sv(self); |
| 3888 |
|
| |
| 3889 |
9 |
| rv = nghttp3_conn_unblock_stream( |
| 3890 |
|
| native->conn, |
| 3891 |
|
| (int64_t)stream_id |
| 3892 |
|
| ); |
| 3893 |
|
| |
| 3894 |
9 |
▶ | if (rv != 0) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (rv != 0) { |
0 |
9 |
9 |
|
| 3895 |
0 |
| unblock_http3_fail("could not unblock HTTP/3 stream", rv); |
| 3896 |
|
| } |
| 3897 |
|
| |
| 3898 |
|
| void |
| 3899 |
|
| update_ack_offset(self, stream_id, offset) |
| 3900 |
|
| SV *self |
| 3901 |
|
| IV stream_id |
| 3902 |
|
| UV offset |
| 3903 |
|
| PREINIT: |
| 3904 |
|
| unblock_http3_native_conn *native; |
| 3905 |
|
| int rv; |
| 3906 |
|
| CODE: |
| 3907 |
414 |
| native = unblock_http3_conn_from_sv(self); |
| 3908 |
|
| |
| 3909 |
414 |
| rv = nghttp3_conn_update_ack_offset( |
| 3910 |
|
| native->conn, |
| 3911 |
|
| (int64_t)stream_id, |
| 3912 |
|
| (uint64_t)offset |
| 3913 |
|
| ); |
| 3914 |
|
| |
| 3915 |
414 |
▶ | if (rv != 0) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (rv != 0) { |
0 |
414 |
414 |
|
| 3916 |
0 |
| unblock_http3_fail("could not update HTTP/3 acknowledgement offset", rv); |
| 3917 |
|
| } |
| 3918 |
|
| |
| 3919 |
|
| void |
| 3920 |
|
| submit_shutdown_notice(self) |
| 3921 |
|
| SV *self |
| 3922 |
|
| PREINIT: |
| 3923 |
|
| unblock_http3_native_conn *native; |
| 3924 |
|
| int rv; |
| 3925 |
|
| CODE: |
| 3926 |
1 |
| native = unblock_http3_conn_from_sv(self); |
| 3927 |
|
| |
| 3928 |
1 |
| rv = nghttp3_conn_submit_shutdown_notice(native->conn); |
| 3929 |
|
| |
| 3930 |
1 |
▶ | if (rv != 0) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (rv != 0) { |
0 |
1 |
1 |
|
| 3931 |
0 |
| unblock_http3_fail("could not submit HTTP/3 shutdown notice", rv); |
| 3932 |
|
| } |
| 3933 |
|
| |
| 3934 |
|
| void |
| 3935 |
|
| begin_shutdown(self) |
| 3936 |
|
| SV *self |
| 3937 |
|
| PREINIT: |
| 3938 |
|
| unblock_http3_native_conn *native; |
| 3939 |
|
| int rv; |
| 3940 |
|
| CODE: |
| 3941 |
1 |
| native = unblock_http3_conn_from_sv(self); |
| 3942 |
|
| |
| 3943 |
1 |
| rv = nghttp3_conn_shutdown(native->conn); |
| 3944 |
|
| |
| 3945 |
1 |
▶ | if (rv != 0) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (rv != 0) { |
0 |
1 |
1 |
|
| 3946 |
0 |
| unblock_http3_fail("could not begin HTTP/3 shutdown", rv); |
| 3947 |
|
| } |
| 3948 |
|
| |
| 3949 |
|
| int |
| 3950 |
|
| is_drained(self) |
| 3951 |
|
| SV *self |
| 3952 |
|
| PREINIT: |
| 3953 |
|
| unblock_http3_native_conn *native; |
| 3954 |
|
| CODE: |
| 3955 |
1 |
| native = unblock_http3_conn_from_sv(self); |
| 3956 |
1 |
▶ | RETVAL = nghttp3_conn_is_drained2(native->conn) ? 1 : 0; |
Branch: 1 branch
| Branch | True | False | Total |
| RETVAL = nghttp3_conn_is_drained2(native->conn) ? 1 : 0; |
0 |
1 |
1 |
|
| 3957 |
|
| OUTPUT: |
| 3958 |
|
| RETVAL |
| 3959 |
|
| |
| 3960 |
|
| void |
| 3961 |
|
| shutdown_stream_read(self, stream_id) |
| 3962 |
|
| SV *self |
| 3963 |
|
| IV stream_id |
| 3964 |
|
| PREINIT: |
| 3965 |
|
| unblock_http3_native_conn *native; |
| 3966 |
|
| int rv; |
| 3967 |
|
| CODE: |
| 3968 |
19 |
| native = unblock_http3_conn_from_sv(self); |
| 3969 |
|
| |
| 3970 |
19 |
| rv = nghttp3_conn_shutdown_stream_read( |
| 3971 |
|
| native->conn, |
| 3972 |
|
| (int64_t)stream_id |
| 3973 |
|
| ); |
| 3974 |
|
| |
| 3975 |
19 |
▶ | if (rv != 0) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (rv != 0) { |
0 |
19 |
19 |
|
| 3976 |
0 |
| unblock_http3_fail("could not shut down HTTP/3 stream read side", rv); |
| 3977 |
|
| } |
| 3978 |
|
| |
| 3979 |
|
| void |
| 3980 |
|
| shutdown_stream_write(self, stream_id) |
| 3981 |
|
| SV *self |
| 3982 |
|
| IV stream_id |
| 3983 |
|
| PREINIT: |
| 3984 |
|
| unblock_http3_native_conn *native; |
| 3985 |
|
| CODE: |
| 3986 |
15 |
| native = unblock_http3_conn_from_sv(self); |
| 3987 |
|
| |
| 3988 |
15 |
| nghttp3_conn_shutdown_stream_write( |
| 3989 |
|
| native->conn, |
| 3990 |
|
| (int64_t)stream_id |
| 3991 |
|
| ); |
| 3992 |
|
| |
| 3993 |
|
| void |
| 3994 |
|
| close_stream(self, stream_id, rx_error = &PL_sv_undef, tx_error = &PL_sv_undef) |
| 3995 |
|
| SV *self |
| 3996 |
|
| IV stream_id |
| 3997 |
|
| SV *rx_error |
| 3998 |
|
| SV *tx_error |
| 3999 |
|
| PREINIT: |
| 4000 |
|
| unblock_http3_native_conn *native; |
| 4001 |
|
| uint32_t flags; |
| 4002 |
|
| uint64_t rx_code; |
| 4003 |
|
| uint64_t tx_code; |
| 4004 |
|
| int rv; |
| 4005 |
|
| CODE: |
| 4006 |
65 |
| native = unblock_http3_conn_from_sv(self); |
| 4007 |
65 |
| flags = 0; |
| 4008 |
65 |
| rx_code = 0; |
| 4009 |
65 |
| tx_code = 0; |
| 4010 |
|
| |
| 4011 |
65 |
▶ | if (SvOK(rx_error)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (SvOK(rx_error)) { |
11 |
54 |
65 |
|
| 4012 |
11 |
| flags |= NGHTTP3_STREAM_CLOSE_FLAG_RX_APP_ERROR_CODE_SET; |
| 4013 |
11 |
| rx_code = (uint64_t)SvUV(rx_error); |
| 4014 |
|
| } |
| 4015 |
|
| |
| 4016 |
65 |
▶ | if (SvOK(tx_error)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (SvOK(tx_error)) { |
7 |
58 |
65 |
|
| 4017 |
7 |
| flags |= NGHTTP3_STREAM_CLOSE_FLAG_TX_APP_ERROR_CODE_SET; |
| 4018 |
7 |
| tx_code = (uint64_t)SvUV(tx_error); |
| 4019 |
|
| } |
| 4020 |
|
| |
| 4021 |
65 |
| rv = nghttp3_conn_close_stream2( |
| 4022 |
|
| native->conn, |
| 4023 |
|
| flags, |
| 4024 |
|
| (int64_t)stream_id, |
| 4025 |
|
| rx_code, |
| 4026 |
|
| tx_code |
| 4027 |
|
| ); |
| 4028 |
|
| |
| 4029 |
65 |
▶ | if (rv != 0 && rv != NGHTTP3_ERR_STREAM_NOT_FOUND) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (rv != 0 && rv != NGHTTP3_ERR_STREAM_NOT_FOUND) { |
0 |
65 |
65 |
| if (rv != 0 && rv != NGHTTP3_ERR_STREAM_NOT_FOUND) { |
0 |
0 |
0 |
|
| 4030 |
0 |
| unblock_http3_fail("could not close HTTP/3 stream", rv); |
| 4031 |
|
| } |
| 4032 |
|
| |
| 4033 |
65 |
| unblock_http3_body_remove( |
| 4034 |
|
| native, |
| 4035 |
|
| (int64_t)stream_id |
| 4036 |
|
| ); |
| 4037 |
|
| |
| 4038 |
|
| |
| 4039 |
|
| UV |
| 4040 |
|
| uniform_request_field_section_size(self, message) |
| 4041 |
|
| SV *self |
| 4042 |
|
| SV *message |
| 4043 |
|
| PREINIT: |
| 4044 |
|
| unblock_http3_native_conn *native; |
| 4045 |
|
| uhttp_native_view view; |
| 4046 |
|
| size_t size; |
| 4047 |
|
| CODE: |
| 4048 |
38 |
| native = unblock_http3_conn_from_sv(self); |
| 4049 |
|
| (void)native; |
| 4050 |
38 |
| unblock_http3_uniform_view( |
| 4051 |
|
| aTHX_ message, |
| 4052 |
|
| UHTTP_KIND_REQUEST, |
| 4053 |
|
| &view |
| 4054 |
|
| ); |
| 4055 |
38 |
| unblock_http3_uniform_validate_section( |
| 4056 |
|
| aTHX_ &view.headers, |
| 4057 |
|
| 0 |
| 4058 |
|
| ); |
| 4059 |
38 |
| size = unblock_http3_uniform_request_size( |
| 4060 |
|
| aTHX_ &view |
| 4061 |
|
| ); |
| 4062 |
38 |
▶ | RETVAL = (UV)size; |
Branch: 1 branch
| Branch | True | False | Total |
| RETVAL = (UV)size; |
34 |
4 |
38 |
|
| 4063 |
|
| OUTPUT: |
| 4064 |
|
| RETVAL |
| 4065 |
|
| |
| 4066 |
|
| UV |
| 4067 |
|
| uniform_response_field_section_size(self, message) |
| 4068 |
|
| SV *self |
| 4069 |
|
| SV *message |
| 4070 |
|
| PREINIT: |
| 4071 |
|
| unblock_http3_native_conn *native; |
| 4072 |
|
| uhttp_native_view view; |
| 4073 |
|
| size_t size; |
| 4074 |
|
| CODE: |
| 4075 |
31 |
| native = unblock_http3_conn_from_sv(self); |
| 4076 |
|
| (void)native; |
| 4077 |
31 |
| unblock_http3_uniform_view( |
| 4078 |
|
| aTHX_ message, |
| 4079 |
|
| UHTTP_KIND_RESPONSE, |
| 4080 |
|
| &view |
| 4081 |
|
| ); |
| 4082 |
31 |
| unblock_http3_uniform_validate_section( |
| 4083 |
|
| aTHX_ &view.headers, |
| 4084 |
|
| 1 |
| 4085 |
|
| ); |
| 4086 |
31 |
| size = unblock_http3_uniform_response_size( |
| 4087 |
|
| aTHX_ &view |
| 4088 |
|
| ); |
| 4089 |
31 |
▶ | RETVAL = (UV)size; |
Branch: 1 branch
| Branch | True | False | Total |
| RETVAL = (UV)size; |
27 |
4 |
31 |
|
| 4090 |
|
| OUTPUT: |
| 4091 |
|
| RETVAL |
| 4092 |
|
| |
| 4093 |
|
| UV |
| 4094 |
|
| uniform_trailer_field_section_size(self, message) |
| 4095 |
|
| SV *self |
| 4096 |
|
| SV *message |
| 4097 |
|
| PREINIT: |
| 4098 |
|
| unblock_http3_native_conn *native; |
| 4099 |
|
| uhttp_native_view view; |
| 4100 |
|
| size_t size; |
| 4101 |
|
| CODE: |
| 4102 |
66 |
| native = unblock_http3_conn_from_sv(self); |
| 4103 |
|
| (void)native; |
| 4104 |
|
| |
| 4105 |
66 |
| unblock_http3_uniform_any_view( |
| 4106 |
|
| aTHX_ message, |
| 4107 |
|
| &view |
| 4108 |
|
| ); |
| 4109 |
|
| |
| 4110 |
66 |
| unblock_http3_uniform_validate_section( |
| 4111 |
|
| aTHX_ &view.trailers, |
| 4112 |
|
| 2 |
| 4113 |
|
| ); |
| 4114 |
66 |
| size = unblock_http3_uniform_section_size( |
| 4115 |
|
| aTHX_ &view.trailers |
| 4116 |
|
| ); |
| 4117 |
66 |
▶ | RETVAL = (UV)size; |
Branch: 1 branch
| Branch | True | False | Total |
| RETVAL = (UV)size; |
59 |
7 |
66 |
|
| 4118 |
|
| OUTPUT: |
| 4119 |
|
| RETVAL |
| 4120 |
|
| |
| 4121 |
|
| void |
| 4122 |
|
| submit_uniform_request(self, stream_id, message, streaming = 0) |
| 4123 |
|
| SV *self |
| 4124 |
|
| IV stream_id |
| 4125 |
|
| SV *message |
| 4126 |
|
| IV streaming |
| 4127 |
|
| PREINIT: |
| 4128 |
|
| unblock_http3_native_conn *native; |
| 4129 |
|
| uhttp_native_view view; |
| 4130 |
|
| unblock_http3_uniform_fields headers; |
| 4131 |
|
| unblock_http3_uniform_fields trailers; |
| 4132 |
|
| unblock_http3_body *body_ctx; |
| 4133 |
|
| const nghttp3_data_reader *reader; |
| 4134 |
|
| Size_t trailer_count; |
| 4135 |
|
| int rv; |
| 4136 |
|
| CODE: |
| 4137 |
37 |
| native = unblock_http3_conn_from_sv(self); |
| 4138 |
37 |
| unblock_http3_uniform_view( |
| 4139 |
|
| aTHX_ message, |
| 4140 |
|
| UHTTP_KIND_REQUEST, |
| 4141 |
|
| &view |
| 4142 |
|
| ); |
| 4143 |
37 |
| unblock_http3_uniform_request_fields( |
| 4144 |
|
| aTHX_ &view, |
| 4145 |
|
| &headers |
| 4146 |
|
| ); |
| 4147 |
37 |
| unblock_http3_uniform_trailer_fields( |
| 4148 |
|
| aTHX_ &view, |
| 4149 |
|
| &trailers |
| 4150 |
|
| ); |
| 4151 |
37 |
| trailer_count = uhttp_native_field_count( |
| 4152 |
|
| aTHX_ &view.trailers |
| 4153 |
|
| ); |
| 4154 |
37 |
| body_ctx = NULL; |
| 4155 |
37 |
| reader = NULL; |
| 4156 |
|
| |
| 4157 |
37 |
| if ( |
| 4158 |
37 |
▶ | (view.flags & UHTTP_HAS_BUFFERED_BODY) |
Branch: 1 branch
| Branch | True | False | Total |
| (view.flags & UHTTP_HAS_BUFFERED_BODY) |
26 |
11 |
37 |
|
| 4159 |
26 |
▶ | || streaming |
Branch: 1 branch
| Branch | True | False | Total |
| || streaming |
12 |
14 |
26 |
|
| 4160 |
12 |
▶ | || trailer_count != 0 |
Branch: 1 branch
| Branch | True | False | Total |
| || trailer_count != 0 |
0 |
12 |
12 |
|
| 4161 |
|
| ) { |
| 4162 |
25 |
| body_ctx = unblock_http3_body_create( |
| 4163 |
|
| native, |
| 4164 |
|
| (int64_t)stream_id, |
| 4165 |
|
| streaming ? 1 : 0 |
| 4166 |
|
| ); |
| 4167 |
|
| |
| 4168 |
25 |
▶ | if (view.flags & UHTTP_HAS_BUFFERED_BODY) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (view.flags & UHTTP_HAS_BUFFERED_BODY) { |
11 |
14 |
25 |
|
| 4169 |
11 |
| unblock_http3_body_append( |
| 4170 |
|
| native, |
| 4171 |
|
| body_ctx, |
| 4172 |
|
| view.body |
| 4173 |
|
| ); |
| 4174 |
|
| } |
| 4175 |
|
| |
| 4176 |
25 |
▶ | if (!streaming) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (!streaming) { |
11 |
14 |
25 |
|
| 4177 |
11 |
| body_ctx->eof = 1; |
| 4178 |
|
| } |
| 4179 |
|
| |
| 4180 |
25 |
| reader = &unblock_http3_body_reader; |
| 4181 |
|
| } |
| 4182 |
|
| |
| 4183 |
37 |
| rv = nghttp3_conn_submit_request( |
| 4184 |
|
| native->conn, |
| 4185 |
|
| (int64_t)stream_id, |
| 4186 |
37 |
| headers.nva, |
| 4187 |
|
| headers.nvlen, |
| 4188 |
|
| reader, |
| 4189 |
|
| body_ctx |
| 4190 |
|
| ); |
| 4191 |
|
| |
| 4192 |
37 |
| unblock_http3_uniform_fields_free(&headers); |
| 4193 |
|
| |
| 4194 |
37 |
▶ | if (rv != 0) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (rv != 0) { |
0 |
37 |
37 |
|
| 4195 |
0 |
| unblock_http3_uniform_fields_free(&trailers); |
| 4196 |
0 |
▶ | if (body_ctx != NULL) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (body_ctx != NULL) { |
0 |
0 |
0 |
|
| 4197 |
0 |
| unblock_http3_body_remove( |
| 4198 |
|
| native, |
| 4199 |
|
| (int64_t)stream_id |
| 4200 |
|
| ); |
| 4201 |
|
| } |
| 4202 |
0 |
| unblock_http3_fail("could not submit HTTP/3 request", rv); |
| 4203 |
|
| } |
| 4204 |
|
| |
| 4205 |
37 |
▶ | if (trailers.nvlen != 0) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (trailers.nvlen != 0) { |
2 |
35 |
37 |
|
| 4206 |
2 |
| rv = nghttp3_conn_submit_trailers( |
| 4207 |
|
| native->conn, |
| 4208 |
|
| (int64_t)stream_id, |
| 4209 |
2 |
| trailers.nva, |
| 4210 |
|
| trailers.nvlen |
| 4211 |
|
| ); |
| 4212 |
|
| |
| 4213 |
2 |
| unblock_http3_uniform_fields_free(&trailers); |
| 4214 |
|
| |
| 4215 |
2 |
▶ | if (rv != 0) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (rv != 0) { |
0 |
2 |
2 |
|
| 4216 |
0 |
| unblock_http3_fail( |
| 4217 |
|
| "could not submit HTTP/3 request trailers", |
| 4218 |
|
| rv |
| 4219 |
|
| ); |
| 4220 |
|
| } |
| 4221 |
|
| } else { |
| 4222 |
35 |
| unblock_http3_uniform_fields_free(&trailers); |
| 4223 |
|
| } |
| 4224 |
|
| |
| 4225 |
|
| void |
| 4226 |
|
| submit_uniform_info(self, stream_id, message) |
| 4227 |
|
| SV *self |
| 4228 |
|
| IV stream_id |
| 4229 |
|
| SV *message |
| 4230 |
|
| PREINIT: |
| 4231 |
|
| unblock_http3_native_conn *native; |
| 4232 |
|
| uhttp_native_view view; |
| 4233 |
|
| unblock_http3_uniform_fields fields; |
| 4234 |
|
| char status_buffer[4]; |
| 4235 |
|
| int rv; |
| 4236 |
|
| CODE: |
| 4237 |
2 |
| native = unblock_http3_conn_from_sv(self); |
| 4238 |
2 |
| unblock_http3_uniform_view( |
| 4239 |
|
| aTHX_ message, |
| 4240 |
|
| UHTTP_KIND_RESPONSE, |
| 4241 |
|
| &view |
| 4242 |
|
| ); |
| 4243 |
2 |
| unblock_http3_uniform_response_fields( |
| 4244 |
|
| aTHX_ &view, |
| 4245 |
|
| &fields, |
| 4246 |
|
| status_buffer |
| 4247 |
|
| ); |
| 4248 |
|
| |
| 4249 |
2 |
| rv = nghttp3_conn_submit_info( |
| 4250 |
|
| native->conn, |
| 4251 |
|
| (int64_t)stream_id, |
| 4252 |
2 |
| fields.nva, |
| 4253 |
|
| fields.nvlen |
| 4254 |
|
| ); |
| 4255 |
|
| |
| 4256 |
2 |
| unblock_http3_uniform_fields_free(&fields); |
| 4257 |
|
| |
| 4258 |
2 |
▶ | if (rv != 0) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (rv != 0) { |
0 |
2 |
2 |
|
| 4259 |
0 |
| unblock_http3_fail( |
| 4260 |
|
| "could not submit HTTP/3 informational response", |
| 4261 |
|
| rv |
| 4262 |
|
| ); |
| 4263 |
|
| } |
| 4264 |
|
| |
| 4265 |
|
| void |
| 4266 |
|
| submit_uniform_response(self, stream_id, message, streaming = 0) |
| 4267 |
|
| SV *self |
| 4268 |
|
| IV stream_id |
| 4269 |
|
| SV *message |
| 4270 |
|
| IV streaming |
| 4271 |
|
| PREINIT: |
| 4272 |
|
| unblock_http3_native_conn *native; |
| 4273 |
|
| uhttp_native_view view; |
| 4274 |
|
| unblock_http3_uniform_fields headers; |
| 4275 |
|
| unblock_http3_uniform_fields trailers; |
| 4276 |
|
| unblock_http3_body *body_ctx; |
| 4277 |
|
| const nghttp3_data_reader *reader; |
| 4278 |
|
| Size_t trailer_count; |
| 4279 |
|
| char status_buffer[4]; |
| 4280 |
|
| int rv; |
| 4281 |
|
| CODE: |
| 4282 |
29 |
| native = unblock_http3_conn_from_sv(self); |
| 4283 |
29 |
| unblock_http3_uniform_view( |
| 4284 |
|
| aTHX_ message, |
| 4285 |
|
| UHTTP_KIND_RESPONSE, |
| 4286 |
|
| &view |
| 4287 |
|
| ); |
| 4288 |
29 |
| unblock_http3_uniform_response_fields( |
| 4289 |
|
| aTHX_ &view, |
| 4290 |
|
| &headers, |
| 4291 |
|
| status_buffer |
| 4292 |
|
| ); |
| 4293 |
29 |
| unblock_http3_uniform_trailer_fields( |
| 4294 |
|
| aTHX_ &view, |
| 4295 |
|
| &trailers |
| 4296 |
|
| ); |
| 4297 |
29 |
| trailer_count = uhttp_native_field_count( |
| 4298 |
|
| aTHX_ &view.trailers |
| 4299 |
|
| ); |
| 4300 |
29 |
| body_ctx = NULL; |
| 4301 |
29 |
| reader = NULL; |
| 4302 |
|
| |
| 4303 |
29 |
| if ( |
| 4304 |
29 |
▶ | (view.flags & UHTTP_HAS_BUFFERED_BODY) |
Branch: 1 branch
| Branch | True | False | Total |
| (view.flags & UHTTP_HAS_BUFFERED_BODY) |
18 |
11 |
29 |
|
| 4305 |
18 |
▶ | || streaming |
Branch: 1 branch
| Branch | True | False | Total |
| || streaming |
10 |
8 |
18 |
|
| 4306 |
10 |
▶ | || trailer_count != 0 |
Branch: 1 branch
| Branch | True | False | Total |
| || trailer_count != 0 |
0 |
10 |
10 |
|
| 4307 |
|
| ) { |
| 4308 |
19 |
| body_ctx = unblock_http3_body_create( |
| 4309 |
|
| native, |
| 4310 |
|
| (int64_t)stream_id, |
| 4311 |
|
| streaming ? 1 : 0 |
| 4312 |
|
| ); |
| 4313 |
|
| |
| 4314 |
19 |
▶ | if (view.flags & UHTTP_HAS_BUFFERED_BODY) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (view.flags & UHTTP_HAS_BUFFERED_BODY) { |
11 |
8 |
19 |
|
| 4315 |
11 |
| unblock_http3_body_append( |
| 4316 |
|
| native, |
| 4317 |
|
| body_ctx, |
| 4318 |
|
| view.body |
| 4319 |
|
| ); |
| 4320 |
|
| } |
| 4321 |
|
| |
| 4322 |
19 |
▶ | if (!streaming) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (!streaming) { |
11 |
8 |
19 |
|
| 4323 |
11 |
| body_ctx->eof = 1; |
| 4324 |
|
| } |
| 4325 |
|
| |
| 4326 |
19 |
| reader = &unblock_http3_body_reader; |
| 4327 |
|
| |
| 4328 |
19 |
| rv = nghttp3_conn_set_stream_user_data( |
| 4329 |
|
| native->conn, |
| 4330 |
|
| (int64_t)stream_id, |
| 4331 |
|
| body_ctx |
| 4332 |
|
| ); |
| 4333 |
|
| |
| 4334 |
19 |
▶ | if (rv != 0) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (rv != 0) { |
0 |
19 |
19 |
|
| 4335 |
0 |
| unblock_http3_uniform_fields_free(&headers); |
| 4336 |
0 |
| unblock_http3_uniform_fields_free(&trailers); |
| 4337 |
0 |
| unblock_http3_body_remove( |
| 4338 |
|
| native, |
| 4339 |
|
| (int64_t)stream_id |
| 4340 |
|
| ); |
| 4341 |
0 |
| unblock_http3_fail( |
| 4342 |
|
| "could not attach HTTP/3 response body", |
| 4343 |
|
| rv |
| 4344 |
|
| ); |
| 4345 |
|
| } |
| 4346 |
|
| } |
| 4347 |
|
| |
| 4348 |
29 |
| rv = nghttp3_conn_submit_response( |
| 4349 |
|
| native->conn, |
| 4350 |
|
| (int64_t)stream_id, |
| 4351 |
29 |
| headers.nva, |
| 4352 |
|
| headers.nvlen, |
| 4353 |
|
| reader |
| 4354 |
|
| ); |
| 4355 |
|
| |
| 4356 |
29 |
| unblock_http3_uniform_fields_free(&headers); |
| 4357 |
|
| |
| 4358 |
29 |
▶ | if (rv != 0) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (rv != 0) { |
0 |
29 |
29 |
|
| 4359 |
0 |
| unblock_http3_uniform_fields_free(&trailers); |
| 4360 |
0 |
▶ | if (body_ctx != NULL) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (body_ctx != NULL) { |
0 |
0 |
0 |
|
| 4361 |
0 |
| unblock_http3_body_remove( |
| 4362 |
|
| native, |
| 4363 |
|
| (int64_t)stream_id |
| 4364 |
|
| ); |
| 4365 |
|
| } |
| 4366 |
0 |
| unblock_http3_fail("could not submit HTTP/3 response", rv); |
| 4367 |
|
| } |
| 4368 |
|
| |
| 4369 |
29 |
▶ | if (trailers.nvlen != 0) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (trailers.nvlen != 0) { |
2 |
27 |
29 |
|
| 4370 |
2 |
| rv = nghttp3_conn_submit_trailers( |
| 4371 |
|
| native->conn, |
| 4372 |
|
| (int64_t)stream_id, |
| 4373 |
2 |
| trailers.nva, |
| 4374 |
|
| trailers.nvlen |
| 4375 |
|
| ); |
| 4376 |
|
| |
| 4377 |
2 |
| unblock_http3_uniform_fields_free(&trailers); |
| 4378 |
|
| |
| 4379 |
2 |
▶ | if (rv != 0) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (rv != 0) { |
0 |
2 |
2 |
|
| 4380 |
0 |
| unblock_http3_fail( |
| 4381 |
|
| "could not submit HTTP/3 response trailers", |
| 4382 |
|
| rv |
| 4383 |
|
| ); |
| 4384 |
|
| } |
| 4385 |
|
| } else { |
| 4386 |
27 |
| unblock_http3_uniform_fields_free(&trailers); |
| 4387 |
|
| } |
| 4388 |
|
| |
| 4389 |
|
| void |
| 4390 |
|
| submit_request(self, stream_id, fields, body = &PL_sv_undef, streaming = 0) |
| 4391 |
|
| SV *self |
| 4392 |
|
| IV stream_id |
| 4393 |
|
| SV *fields |
| 4394 |
|
| SV *body |
| 4395 |
|
| IV streaming |
| 4396 |
|
| PREINIT: |
| 4397 |
|
| unblock_http3_native_conn *native; |
| 4398 |
|
| unblock_http3_body *body_ctx; |
| 4399 |
|
| const nghttp3_data_reader *reader; |
| 4400 |
|
| nghttp3_nv *nva; |
| 4401 |
|
| size_t nvlen; |
| 4402 |
|
| int rv; |
| 4403 |
|
| CODE: |
| 4404 |
6 |
| native = unblock_http3_conn_from_sv(self); |
| 4405 |
6 |
| nva = unblock_http3_fields_from_sv(fields, &nvlen); |
| 4406 |
6 |
| body_ctx = NULL; |
| 4407 |
6 |
| reader = NULL; |
| 4408 |
|
| |
| 4409 |
6 |
▶ | if (SvOK(body) || streaming) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (SvOK(body) || streaming) { |
6 |
0 |
6 |
| if (SvOK(body) || streaming) { |
4 |
2 |
6 |
|
| 4410 |
4 |
| body_ctx = unblock_http3_body_create( |
| 4411 |
|
| native, |
| 4412 |
|
| (int64_t)stream_id, |
| 4413 |
|
| streaming ? 1 : 0 |
| 4414 |
|
| ); |
| 4415 |
|
| |
| 4416 |
4 |
▶ | if (SvOK(body)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (SvOK(body)) { |
0 |
4 |
4 |
|
| 4417 |
0 |
| unblock_http3_body_append(native, body_ctx, body); |
| 4418 |
0 |
| body_ctx->eof = 1; |
| 4419 |
|
| } |
| 4420 |
|
| |
| 4421 |
4 |
| reader = &unblock_http3_body_reader; |
| 4422 |
|
| } |
| 4423 |
|
| |
| 4424 |
6 |
| rv = nghttp3_conn_submit_request( |
| 4425 |
|
| native->conn, |
| 4426 |
|
| (int64_t)stream_id, |
| 4427 |
|
| nva, |
| 4428 |
|
| nvlen, |
| 4429 |
|
| reader, |
| 4430 |
|
| body_ctx |
| 4431 |
|
| ); |
| 4432 |
|
| |
| 4433 |
6 |
▶ | if (nva != NULL) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (nva != NULL) { |
6 |
0 |
6 |
|
| 4434 |
6 |
| Safefree(nva); |
| 4435 |
|
| } |
| 4436 |
|
| |
| 4437 |
6 |
▶ | if (rv != 0) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (rv != 0) { |
0 |
6 |
6 |
|
| 4438 |
0 |
| unblock_http3_fail("could not submit HTTP/3 request", rv); |
| 4439 |
|
| } |
| 4440 |
|
| |
| 4441 |
|
| void |
| 4442 |
|
| submit_info(self, stream_id, fields) |
| 4443 |
|
| SV *self |
| 4444 |
|
| IV stream_id |
| 4445 |
|
| SV *fields |
| 4446 |
|
| PREINIT: |
| 4447 |
|
| unblock_http3_native_conn *native; |
| 4448 |
|
| nghttp3_nv *nva; |
| 4449 |
|
| size_t nvlen; |
| 4450 |
|
| int rv; |
| 4451 |
|
| CODE: |
| 4452 |
0 |
| native = unblock_http3_conn_from_sv(self); |
| 4453 |
0 |
| nva = unblock_http3_fields_from_sv(fields, &nvlen); |
| 4454 |
|
| |
| 4455 |
0 |
| rv = nghttp3_conn_submit_info( |
| 4456 |
|
| native->conn, |
| 4457 |
|
| (int64_t)stream_id, |
| 4458 |
|
| nva, |
| 4459 |
|
| nvlen |
| 4460 |
|
| ); |
| 4461 |
|
| |
| 4462 |
0 |
▶ | if (nva != NULL) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (nva != NULL) { |
0 |
0 |
0 |
|
| 4463 |
0 |
| Safefree(nva); |
| 4464 |
|
| } |
| 4465 |
|
| |
| 4466 |
0 |
▶ | if (rv != 0) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (rv != 0) { |
0 |
0 |
0 |
|
| 4467 |
0 |
| unblock_http3_fail( |
| 4468 |
|
| "could not submit HTTP/3 informational response", |
| 4469 |
|
| rv |
| 4470 |
|
| ); |
| 4471 |
|
| } |
| 4472 |
|
| |
| 4473 |
|
| void |
| 4474 |
|
| submit_response(self, stream_id, fields, body = &PL_sv_undef, streaming = 0) |
| 4475 |
|
| SV *self |
| 4476 |
|
| IV stream_id |
| 4477 |
|
| SV *fields |
| 4478 |
|
| SV *body |
| 4479 |
|
| IV streaming |
| 4480 |
|
| PREINIT: |
| 4481 |
|
| unblock_http3_native_conn *native; |
| 4482 |
|
| unblock_http3_body *body_ctx; |
| 4483 |
|
| const nghttp3_data_reader *reader; |
| 4484 |
|
| nghttp3_nv *nva; |
| 4485 |
|
| size_t nvlen; |
| 4486 |
|
| int rv; |
| 4487 |
|
| CODE: |
| 4488 |
0 |
| native = unblock_http3_conn_from_sv(self); |
| 4489 |
0 |
| nva = unblock_http3_fields_from_sv(fields, &nvlen); |
| 4490 |
0 |
| body_ctx = NULL; |
| 4491 |
0 |
| reader = NULL; |
| 4492 |
|
| |
| 4493 |
0 |
▶ | if (SvOK(body) || streaming) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (SvOK(body) || streaming) { |
0 |
0 |
0 |
| if (SvOK(body) || streaming) { |
0 |
0 |
0 |
|
| 4494 |
0 |
| body_ctx = unblock_http3_body_create( |
| 4495 |
|
| native, |
| 4496 |
|
| (int64_t)stream_id, |
| 4497 |
|
| streaming ? 1 : 0 |
| 4498 |
|
| ); |
| 4499 |
|
| |
| 4500 |
0 |
▶ | if (SvOK(body)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (SvOK(body)) { |
0 |
0 |
0 |
|
| 4501 |
0 |
| unblock_http3_body_append(native, body_ctx, body); |
| 4502 |
0 |
| body_ctx->eof = 1; |
| 4503 |
|
| } |
| 4504 |
|
| |
| 4505 |
0 |
| reader = &unblock_http3_body_reader; |
| 4506 |
|
| |
| 4507 |
0 |
| rv = nghttp3_conn_set_stream_user_data( |
| 4508 |
|
| native->conn, |
| 4509 |
|
| (int64_t)stream_id, |
| 4510 |
|
| body_ctx |
| 4511 |
|
| ); |
| 4512 |
|
| |
| 4513 |
0 |
▶ | if (rv != 0) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (rv != 0) { |
0 |
0 |
0 |
|
| 4514 |
0 |
▶ | if (nva != NULL) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (nva != NULL) { |
0 |
0 |
0 |
|
| 4515 |
0 |
| Safefree(nva); |
| 4516 |
|
| } |
| 4517 |
0 |
| unblock_http3_fail( |
| 4518 |
|
| "could not attach HTTP/3 response body", |
| 4519 |
|
| rv |
| 4520 |
|
| ); |
| 4521 |
|
| } |
| 4522 |
|
| } |
| 4523 |
|
| |
| 4524 |
0 |
| rv = nghttp3_conn_submit_response( |
| 4525 |
|
| native->conn, |
| 4526 |
|
| (int64_t)stream_id, |
| 4527 |
|
| nva, |
| 4528 |
|
| nvlen, |
| 4529 |
|
| reader |
| 4530 |
|
| ); |
| 4531 |
|
| |
| 4532 |
0 |
▶ | if (nva != NULL) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (nva != NULL) { |
0 |
0 |
0 |
|
| 4533 |
0 |
| Safefree(nva); |
| 4534 |
|
| } |
| 4535 |
|
| |
| 4536 |
0 |
▶ | if (rv != 0) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (rv != 0) { |
0 |
0 |
0 |
|
| 4537 |
0 |
| unblock_http3_fail("could not submit HTTP/3 response", rv); |
| 4538 |
|
| } |
| 4539 |
|
| |
| 4540 |
|
| UV |
| 4541 |
|
| append_body(self, stream_id, bytes, final) |
| 4542 |
|
| SV *self |
| 4543 |
|
| IV stream_id |
| 4544 |
|
| SV *bytes |
| 4545 |
|
| IV final |
| 4546 |
|
| PREINIT: |
| 4547 |
|
| unblock_http3_native_conn *native; |
| 4548 |
|
| unblock_http3_body *body; |
| 4549 |
|
| size_t appended; |
| 4550 |
|
| int rv; |
| 4551 |
|
| CODE: |
| 4552 |
43 |
| native = unblock_http3_conn_from_sv(self); |
| 4553 |
43 |
| body = unblock_http3_body_find(native, (int64_t)stream_id); |
| 4554 |
|
| |
| 4555 |
43 |
▶ | if (body == NULL || !body->streaming) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (body == NULL || !body->streaming) { |
43 |
0 |
43 |
| if (body == NULL || !body->streaming) { |
0 |
43 |
43 |
|
| 4556 |
0 |
| croak("HTTP/3 stream does not have an incremental body"); |
| 4557 |
|
| } |
| 4558 |
|
| |
| 4559 |
43 |
▶ | if (body->eof) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (body->eof) { |
0 |
43 |
43 |
|
| 4560 |
0 |
| croak("HTTP/3 incremental body is already complete"); |
| 4561 |
|
| } |
| 4562 |
|
| |
| 4563 |
43 |
| appended = unblock_http3_body_append(native, body, bytes); |
| 4564 |
|
| |
| 4565 |
43 |
▶ | if (final) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (final) { |
20 |
23 |
43 |
|
| 4566 |
20 |
| body->eof = 1; |
| 4567 |
|
| } |
| 4568 |
|
| |
| 4569 |
43 |
| rv = nghttp3_conn_resume_stream( |
| 4570 |
|
| native->conn, |
| 4571 |
|
| (int64_t)stream_id |
| 4572 |
|
| ); |
| 4573 |
|
| |
| 4574 |
43 |
▶ | if (rv != 0) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (rv != 0) { |
0 |
43 |
43 |
|
| 4575 |
0 |
| unblock_http3_fail("could not resume HTTP/3 body stream", rv); |
| 4576 |
|
| } |
| 4577 |
|
| |
| 4578 |
43 |
▶ | RETVAL = (UV)appended; |
Branch: 1 branch
| Branch | True | False | Total |
| RETVAL = (UV)appended; |
34 |
9 |
43 |
|
| 4579 |
|
| OUTPUT: |
| 4580 |
|
| RETVAL |
| 4581 |
|
| |
| 4582 |
|
| void |
| 4583 |
|
| discard_body(self, stream_id) |
| 4584 |
|
| SV *self |
| 4585 |
|
| IV stream_id |
| 4586 |
|
| PREINIT: |
| 4587 |
|
| unblock_http3_native_conn *native; |
| 4588 |
|
| unblock_http3_body *body; |
| 4589 |
|
| CODE: |
| 4590 |
18 |
| native = unblock_http3_conn_from_sv(self); |
| 4591 |
18 |
| body = unblock_http3_body_find(native, (int64_t)stream_id); |
| 4592 |
18 |
| unblock_http3_body_discard(native, body); |
| 4593 |
|
| |
| 4594 |
|
| UV |
| 4595 |
|
| streaming_retained_bytes(self) |
| 4596 |
|
| SV *self |
| 4597 |
|
| PREINIT: |
| 4598 |
|
| unblock_http3_native_conn *native; |
| 4599 |
|
| CODE: |
| 4600 |
7 |
| native = unblock_http3_conn_from_sv(self); |
| 4601 |
7 |
▶ | RETVAL = (UV)native->streaming_retained_bytes; |
Branch: 1 branch
| Branch | True | False | Total |
| RETVAL = (UV)native->streaming_retained_bytes; |
0 |
7 |
7 |
|
| 4602 |
|
| OUTPUT: |
| 4603 |
|
| RETVAL |
| 4604 |
|
| |
| 4605 |
|
| UV |
| 4606 |
|
| streaming_retained_bytes_for_stream(self, stream_id) |
| 4607 |
|
| SV *self |
| 4608 |
|
| IV stream_id |
| 4609 |
|
| PREINIT: |
| 4610 |
|
| unblock_http3_native_conn *native; |
| 4611 |
|
| unblock_http3_body *body; |
| 4612 |
|
| CODE: |
| 4613 |
466 |
| native = unblock_http3_conn_from_sv(self); |
| 4614 |
466 |
| body = unblock_http3_body_find(native, (int64_t)stream_id); |
| 4615 |
723 |
▶ | RETVAL = body != NULL && body->streaming |
Branch: 2 branches
| Branch | True | False | Total |
| RETVAL = body != NULL && body->streaming |
145 |
112 |
257 |
| RETVAL = body != NULL && body->streaming |
451 |
15 |
466 |
|
| 4616 |
723 |
▶ | ? (UV)body->retained_bytes : 0; |
Branch: 1 branch
| Branch | True | False | Total |
| ? (UV)body->retained_bytes : 0; |
257 |
209 |
466 |
|
| 4617 |
|
| OUTPUT: |
| 4618 |
|
| RETVAL |
| 4619 |
|
| |
| 4620 |
|
| UV |
| 4621 |
|
| active_streaming_body_count(self) |
| 4622 |
|
| SV *self |
| 4623 |
|
| PREINIT: |
| 4624 |
|
| unblock_http3_native_conn *native; |
| 4625 |
|
| unblock_http3_body *body; |
| 4626 |
|
| UV count; |
| 4627 |
|
| CODE: |
| 4628 |
455 |
| native = unblock_http3_conn_from_sv(self); |
| 4629 |
455 |
| count = 0; |
| 4630 |
843 |
▶ | for (body = native->bodies; body != NULL; body = body->next) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (body = native->bodies; body != NULL; body = body->next) { |
388 |
455 |
843 |
|
| 4631 |
388 |
▶ | if (body->streaming && !body->eof) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (body->streaming && !body->eof) { |
175 |
213 |
388 |
| if (body->streaming && !body->eof) { |
83 |
92 |
175 |
|
| 4632 |
83 |
| ++count; |
| 4633 |
|
| } |
| 4634 |
|
| } |
| 4635 |
455 |
▶ | RETVAL = count; |
Branch: 1 branch
| Branch | True | False | Total |
| RETVAL = count; |
445 |
10 |
455 |
|
| 4636 |
|
| OUTPUT: |
| 4637 |
|
| RETVAL |
| 4638 |
|
| |
| 4639 |
|
| void |
| 4640 |
|
| submit_trailers(self, stream_id, fields) |
| 4641 |
|
| SV *self |
| 4642 |
|
| IV stream_id |
| 4643 |
|
| SV *fields |
| 4644 |
|
| PREINIT: |
| 4645 |
|
| unblock_http3_native_conn *native; |
| 4646 |
|
| nghttp3_nv *nva; |
| 4647 |
|
| size_t nvlen; |
| 4648 |
|
| int rv; |
| 4649 |
|
| CODE: |
| 4650 |
0 |
| native = unblock_http3_conn_from_sv(self); |
| 4651 |
0 |
| nva = unblock_http3_fields_from_sv(fields, &nvlen); |
| 4652 |
|
| |
| 4653 |
0 |
| rv = nghttp3_conn_submit_trailers( |
| 4654 |
|
| native->conn, |
| 4655 |
|
| (int64_t)stream_id, |
| 4656 |
|
| nva, |
| 4657 |
|
| nvlen |
| 4658 |
|
| ); |
| 4659 |
|
| |
| 4660 |
0 |
▶ | if (nva != NULL) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (nva != NULL) { |
0 |
0 |
0 |
|
| 4661 |
0 |
| Safefree(nva); |
| 4662 |
|
| } |
| 4663 |
|
| |
| 4664 |
0 |
▶ | if (rv != 0) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (rv != 0) { |
0 |
0 |
0 |
|
| 4665 |
0 |
| unblock_http3_fail("could not submit HTTP/3 trailers", rv); |
| 4666 |
|
| } |
| 4667 |
|
| |
| 4668 |
|
| SV * |
| 4669 |
|
| next_event(self) |
| 4670 |
|
| SV *self |
| 4671 |
|
| PREINIT: |
| 4672 |
|
| unblock_http3_native_conn *native; |
| 4673 |
|
| SV *event; |
| 4674 |
|
| CODE: |
| 4675 |
1546 |
| native = unblock_http3_conn_from_sv(self); |
| 4676 |
|
| |
| 4677 |
1546 |
▶ | if (av_len(native->events) < 0) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (av_len(native->events) < 0) { |
1262 |
284 |
1546 |
|
| 4678 |
1262 |
| XSRETURN_UNDEF; |
| 4679 |
|
| } |
| 4680 |
|
| |
| 4681 |
284 |
| event = av_shift(native->events); |
| 4682 |
|
| |
| 4683 |
284 |
▶ | if (event == NULL) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (event == NULL) { |
0 |
284 |
284 |
|
| 4684 |
0 |
| XSRETURN_UNDEF; |
| 4685 |
|
| } |
| 4686 |
|
| |
| 4687 |
284 |
| RETVAL = event; |
| 4688 |
|
| OUTPUT: |
| 4689 |
|
| RETVAL |
| 4690 |
|
| |
| 4691 |
|
| void |
| 4692 |
|
| DESTROY(self) |
| 4693 |
|
| SV *self |
| 4694 |
|
| PREINIT: |
| 4695 |
|
| unblock_http3_native_conn *native; |
| 4696 |
|
| CODE: |
| 4697 |
63 |
▶ | if (!SvROK(self)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (!SvROK(self)) { |
0 |
63 |
63 |
|
| 4698 |
0 |
| XSRETURN_EMPTY; |
| 4699 |
|
| } |
| 4700 |
|
| |
| 4701 |
63 |
| native = INT2PTR( |
| 4702 |
|
| unblock_http3_native_conn *, |
| 4703 |
|
| SvIV(SvRV(self)) |
| 4704 |
|
| ); |
| 4705 |
|
| |
| 4706 |
63 |
▶ | if (native != NULL) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (native != NULL) { |
63 |
0 |
63 |
|
| 4707 |
63 |
▶ | if (native->conn != NULL) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (native->conn != NULL) { |
63 |
0 |
63 |
|
| 4708 |
63 |
| nghttp3_conn_del(native->conn); |
| 4709 |
63 |
| native->conn = NULL; |
| 4710 |
|
| } |
| 4711 |
|
| |
| 4712 |
63 |
▶ | if (native->events != NULL) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (native->events != NULL) { |
63 |
0 |
63 |
|
| 4713 |
63 |
| SvREFCNT_dec((SV *)native->events); |
| 4714 |
63 |
| native->events = NULL; |
| 4715 |
|
| } |
| 4716 |
|
| |
| 4717 |
63 |
▶ | if (native->origin_list_data != NULL) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (native->origin_list_data != NULL) { |
1 |
62 |
63 |
|
| 4718 |
1 |
| Safefree(native->origin_list_data); |
| 4719 |
1 |
| native->origin_list_data = NULL; |
| 4720 |
|
| } |
| 4721 |
|
| |
| 4722 |
63 |
| unblock_http3_body_free_all(native); |
| 4723 |
63 |
| unblock_http3_header_block_free_all(native); |
| 4724 |
63 |
| Safefree(native); |
| 4725 |
63 |
| sv_setiv(SvRV(self), 0); |
| 4726 |
|
| } |