Branch Coverage

feersum_h1.c.inc
Criterion Covered Total %
branch 299 422 70.8


line true false branch
5 654 16 if (likely(!req)) {
6 495 159 FEER_REQ_ALLOC(req);
37 105 650 if (unlikely(c->pipelined)) goto pipelined;
41 0 650 if (unlikely(revents & EV_ERROR && !(revents & EV_READ))) {
0 0 if (unlikely(revents & EV_ERROR && !(revents & EV_READ))) {
46 0 650 if (unlikely(c->receiving == RECEIVE_SHUTDOWN))
51 600 50 if (unlikely(!c->rbuf)) { // unlikely = optimize for keepalive requests
58 28 622 if (unlikely(space_free < READ_BUFSZ)) { // unlikely = optimize for small
61 0 28 if (unlikely(cur_len + READ_GROW_FACTOR*READ_BUFSZ > c->cached_max_read_buf)) {
70 28 0 SvGROW(c->rbuf, new_len);
28 0 SvGROW(c->rbuf, new_len);
77 29 621 if (unlikely(got_n <= 0)) {
78 27 2 if (unlikely(got_n == 0)) {
82 2 0 if (likely(errno == EAGAIN || errno == EINTR))
0 2 if (likely(errno == EAGAIN || errno == EINTR))
90 12 609 if (c->receiving == RECEIVE_WAIT)
100 138 625 if (unlikely(c->receiving == RECEIVE_PROXY_HEADER)) {
102 100 38 if (ret == -1) {
106 1 37 if (ret == -2) goto try_read_again_reset_timer;
110 37 0 if (remaining > 0)
115 0 37 feer_clear_remote_cache(c);
0 37 feer_clear_remote_cache(c);
119 37 0 if (remaining > 0) {
127 611 14 if (likely(c->receiving <= RECEIVE_HEADERS)) {
129 14 597 if (ret == -1) goto try_read_bad;
131 22 575 if (ret == -2) goto try_read_again_reset_timer;
139 17 558 if (process_request_headers(c, ret))
144 10 4 else if (likely(c->receiving == RECEIVE_BODY)) {
146 1 9 if (c->received_cl < c->expected_cl)
152 4 0 else if (c->receiving == RECEIVE_CHUNKED) {
155 0 4 if (ret == 1)
157 0 4 if (ret == -1) {
165 0 0 else if (c->receiving == RECEIVE_STREAMING) {
168 0 0 if (c->poll_read_cb) {
172 0 0 if (c->receiving >= RECEIVE_SHUTDOWN)
175 0 0 if (c->expected_cl > 0 && c->received_cl >= c->expected_cl) {
0 0 if (c->expected_cl > 0 && c->received_cl >= c->expected_cl) {
219 6 0 if (unlikely(!(revents & EV_TIMER) || c->receiving == RECEIVE_SHUTDOWN)) {
0 6 if (unlikely(!(revents & EV_TIMER) || c->receiving == RECEIVE_SHUTDOWN)) {
221 0 0 if (revents & EV_ERROR)
246 6 0 if (likely(c->responding == RESPOND_NOT_STARTED) && c->receiving >= RECEIVE_HEADERS) {
5 1 if (likely(c->responding == RESPOND_NOT_STARTED) && c->receiving >= RECEIVE_HEADERS) {
248 0 5 if (c->tls && !c->tls_handshake_done) {
0 0 if (c->tls && !c->tls_handshake_done) {
254 0 5 if (c->receiving == RECEIVE_PROXY_HEADER) {
257 2 3 else if (c->receiving == RECEIVE_HEADERS) {
281 8 0 if (unlikely(!(revents & EV_TIMER) || c->receiving == RECEIVE_SHUTDOWN)) {
0 8 if (unlikely(!(revents & EV_TIMER) || c->receiving == RECEIVE_SHUTDOWN)) {
282 0 0 if (revents & EV_ERROR)
289 0 8 if ((c->receiving == RECEIVE_HEADERS || c->receiving == RECEIVE_PROXY_HEADER)
0 0 if ((c->receiving == RECEIVE_HEADERS || c->receiving == RECEIVE_PROXY_HEADER)
290 0 8 && c->responding == RESPOND_NOT_STARTED) {
293 4 4 if (c->tls && !c->tls_handshake_done) {
4 0 if (c->tls && !c->tls_handshake_done) {
314 0 0 if (unlikely(!(revents & EV_TIMER) || c->responding == RESPOND_SHUTDOWN)) {
0 0 if (unlikely(!(revents & EV_TIMER) || c->responding == RESPOND_SHUTDOWN)) {
315 0 0 if (revents & EV_ERROR)
335 0 662 if (unlikely(prep_socket(fd, lsnr->is_tcp))) {
337 0 0 if (unlikely(close(fd) < 0))
345 661 1 if (srvr->header_timeout > 0.0) {
355 68 594 if (lsnr->tls_ctx_ref) {
389 0 0 if (lsnr->server->shutting_down) return;
393 0 0 if (!lsnr->pause_flags && lsnr->fd >= 0)
0 0 if (!lsnr->pause_flags && lsnr->fd >= 0)
413 585 663 if (fd == -1) {
414 0 585 if (errno == EINTR) return 1;
415 585 0 if (errno == EMFILE || errno == ENFILE) {
0 585 if (errno == EMFILE || errno == ENFILE) {
426 662 1 if (srvr->max_connections > 0 && srvr->active_conns >= srvr->max_connections) {
3 659 if (srvr->max_connections > 0 && srvr->active_conns >= srvr->max_connections) {
427 1 2 if (!feer_server_recycle_idle_conn(srvr)) {
452 0 0 if (unlikely(srvr->shutting_down)) {
457 0 0 if (unlikely(revents & EV_ERROR)) {
464 0 0 while (accept_count++ < srvr->max_accept_per_loop) {
465 0 0 if (epoll_wait(lsnr->epoll_fd, events, 1, 0) <= 0) break;
466 0 0 if (!try_accept_one(EV_A, lsnr, srvr)) break;
477 0 586 if (unlikely(srvr->shutting_down)) {
482 0 586 if (unlikely(revents & EV_ERROR)) {
491 1248 0 while (accept_count++ < srvr->max_accept_per_loop) {
492 586 662 if (!try_accept_one(EV_A, lsnr, srvr)) break;
502 2 222 if (srvr->use_epoll_exclusive) {
507 0 2 if (lsnr->epoll_fd < 0) {
514 0 2 if (epoll_ctl(lsnr->epoll_fd, EPOLL_CTL_ADD, listen_fd, &ev) < 0) {
516 0 0 if (unlikely(close(lsnr->epoll_fd) < 0))
552 388 165 if (!ev_is_active(&server->ei)) {
565 0 71 if (!c->rbuf) return 1; // need data
576 5523 2 while (read_pos < buf_len) {
577 2 5521 if (c->chunk_remaining == CHUNK_STATE_NEED_CRLF) {
580 0 2 if (remaining < 2)
582 2 0 if (buf[read_pos] != '\r' || buf[read_pos+1] != '\n') {
0 2 if (buf[read_pos] != '\r' || buf[read_pos+1] != '\n') {
590 2766 2755 else if (c->chunk_remaining == CHUNK_STATE_PARSE_SIZE) {
598 5856 0 for (i = 0; i + 1 < remaining; i++) {
599 2766 3090 if (line_start[i] == '\r' && line_start[i+1] == '\n') {
2766 0 if (line_start[i] == '\r' && line_start[i+1] == '\n') {
605 0 2766 if (!line_end) {
616 2798 2750 while (p < line_end) {
619 2783 15 if (val != 0xFF) {
622 1 2782 if (chunk_size > (UV_MAX >> 4)) {
628 8 7 else if (ch == ';' || ch == ' ' || ch == '\t') {
6 2 else if (ch == ';' || ch == ' ' || ch == '\t') {
6 0 else if (ch == ';' || ch == ' ' || ch == '\t') {
639 4 2755 if (hex_digits == 0) {
650 52 2703 if (chunk_size == 0) {
663 0 2703 if (unlikely(chunk_size > (UV)c->cached_max_body_len)) {
667 0 2703 if (unlikely(write_pos > (STRLEN)(c->cached_max_body_len - chunk_size))) {
675 0 2703 if (unlikely(c->chunk_count > MAX_CHUNK_COUNT)) {
680 0 2703 if (chunk_size > (UV)SSIZE_MAX) return -1;
683 52 2703 else if (c->chunk_remaining == 0) {
689 5794 0 while (i + 1 < remaining) {
690 317 5477 if (trailer_start[i] == '\r' && trailer_start[i+1] == '\n') {
317 0 if (trailer_start[i] == '\r' && trailer_start[i+1] == '\n') {
691 50 267 if (i == 0) {
694 2 48 STRLEN pipelined = (read_pos < buf_len) ? buf_len - read_pos : 0;
697 2 48 if (pipelined > 0)
703 2 265 if (unlikely(++c->trailer_count > MAX_TRAILER_HEADERS)) {
721 2 2701 if (to_copy > remaining)
725 2703 0 if (write_pos != read_pos && to_copy > 0) {
2703 0 if (write_pos != read_pos && to_copy > 0) {
733 2 2701 if (c->chunk_remaining > 0) {
740 2 2699 if (remaining < 2) {
745 2697 2 if (buf[read_pos] != '\r' || buf[read_pos+1] != '\n') {
0 2697 if (buf[read_pos] != '\r' || buf[read_pos+1] != '\n') {
756 4 2 if (read_pos > write_pos) {
757 0 4 if (read_pos < buf_len) {
798 254 380 c->is_keepalive = c->cached_keepalive_default && c->is_http11;
246 8 c->is_keepalive = c->cached_keepalive_default && c->is_http11;
810 455 1 if (likely(memcmp(req->method, "GET", 3) == 0)) {
812 1 0 } else if (memcmp(req->method, "PUT", 3) == 0) {
819 165 2 if (likely(memcmp(req->method, "POST", 4) == 0)) {
821 2 0 } else if (memcmp(req->method, "HEAD", 4) == 0) {
828 2 0 if (memcmp(req->method, "PATCH", 5) == 0) {
835 2 1 if (memcmp(req->method, "DELETE", 6) == 0) {
842 2 0 if (memcmp(req->method, "OPTIONS", 7) == 0) {
856 3 626 if (unlikely(req->uri_len > c->cached_max_uri_len)) {
875 626 0 if (unlikely(body_offset < 0 || (STRLEN)body_offset > from_len)) {
0 626 if (unlikely(body_offset < 0 || (STRLEN)body_offset > from_len)) {
884 253 373 SV *new_rbuf = newSVpvn(need > 0 ? from : "", need);
894 1539 577 for (size_t i = 0; i < req->num_headers; i++) {
897 1 1538 if (unlikely(!hdr->name)) {
904 2 1536 if (unlikely(hdr->name_len > MAX_HEADER_NAME_LEN)) {
909 88 1448 if (unlikely(hdr->name_len == 14 &&
88 0 if (unlikely(hdr->name_len == 14 &&
913 3 85 if (c->receive_chunked) {
920 83 2 if (likely(g == IS_NUMBER_IN_UV)) {
921 4 79 if (unlikely(new_expected > (UV)c->cached_max_body_len)) {
927 4 75 if (got_content_length && new_expected != expected) {
2 2 if (got_content_length && new_expected != expected) {
941 573 875 else if (unlikely(hdr->name_len == 10 &&
420 153 else if (unlikely(hdr->name_len == 10 &&
944 415 5 if (c->is_http11 && c->is_keepalive &&
92 323 if (c->is_http11 && c->is_keepalive &&
945 83 9 hdr->value_len == 5 && str_case_eq_fixed("close", hdr->value, 5))
83 0 hdr->value_len == 5 && str_case_eq_fixed("close", hdr->value, 5))
950 5 332 else if (!c->is_http11 && c->cached_keepalive_default &&
5 0 else if (!c->is_http11 && c->cached_keepalive_default &&
951 1 4 hdr->value_len == 10 && str_case_eq_fixed("keep-alive", hdr->value, 10))
1 0 hdr->value_len == 10 && str_case_eq_fixed("keep-alive", hdr->value, 10))
956 314 106 if (next_req_follows && c->receive_chunked && (!c->is_http11 || got_host)) break;
4 310 if (next_req_follows && c->receive_chunked && (!c->is_http11 || got_host)) break;
4 0 if (next_req_follows && c->receive_chunked && (!c->is_http11 || got_host)) break;
0 4 if (next_req_follows && c->receive_chunked && (!c->is_http11 || got_host)) break;
958 1002 26 else if (unlikely(c->is_http11 && hdr->name_len == 6 &&
41 961 else if (unlikely(c->is_http11 && hdr->name_len == 6 &&
41 987 else if (unlikely(c->is_http11 && hdr->name_len == 6 &&
22 19 else if (unlikely(c->is_http11 && hdr->name_len == 6 &&
975 980 26 else if (unlikely(c->is_http11 && hdr->name_len == 17 &&
115 865 else if (unlikely(c->is_http11 && hdr->name_len == 17 &&
115 891 else if (unlikely(c->is_http11 && hdr->name_len == 17 &&
103 12 else if (unlikely(c->is_http11 && hdr->name_len == 17 &&
980 6 97 if (got_transfer_encoding) {
989 87 8 bool is_chunked = (hdr->value_len >= 7 &&
990 95 2 str_case_eq_fixed("chunked", hdr->value, 7) &&
991 3 84 (hdr->value_len == 7 ||
992 1 2 hdr->value[7] == ';' ||
993 0 1 hdr->value[7] == ' ' ||
994 0 0 hdr->value[7] == '\t'));
1000 87 10 if (is_chunked) {
1003 8 79 if (got_content_length) {
1011 6 4 else if (is_identity) {
1022 627 276 else if (unlikely(hdr->name_len == 4 &&
627 0 else if (unlikely(hdr->name_len == 4 &&
1025 2 625 if (unlikely(got_host)) {
1035 566 15 if (unlikely(c->is_http11 && !got_host)) {
1 565 if (unlikely(c->is_http11 && !got_host)) {
1041 27 553 if (c->cached_max_conn_reqs > 0 && c->reqs >= c->cached_max_conn_reqs) {
1 26 if (c->cached_max_conn_reqs > 0 && c->reqs >= c->cached_max_conn_reqs) {
1050 71 509 if (unlikely(c->receive_chunked && next_req_follows)) {
4 67 if (unlikely(c->receive_chunked && next_req_follows)) {
1056 448 128 if (likely(next_req_follows) && !got_content_length && !c->receive_chunked) goto got_it_all;
448 0 if (likely(next_req_follows) && !got_content_length && !c->receive_chunked) goto got_it_all;
448 0 if (likely(next_req_follows) && !got_content_length && !c->receive_chunked) goto got_it_all;
1057 57 71 else if (likely(got_content_length)) goto got_cl;
1058 67 4 else if (unlikely(c->receive_chunked)) goto got_chunked;
1073 57 0 SvGROW(c->rbuf, c->expected_cl + 1);
3 54 SvGROW(c->rbuf, c->expected_cl + 1);
1077 55 2 if (unlikely(c->expected_cl && c->received_cl < c->expected_cl)) {
13 42 if (unlikely(c->expected_cl && c->received_cl < c->expected_cl)) {
1099 6 61 if (ret == 1)
1101 15 46 if (ret == -1) {
1124 639 768 if (c->in_callback) {
1132 50 718 if (c->tls) {
1173 67 13 if (likely(!c->expect_continue))
1178 2 11 if (c->tls) {
1181 0 2 if (c->tls_wbuf.off > 0)
1190 0 11 if (likely(wr > 0)) {
1193 0 0 else if (wr < 0 && errno != EAGAIN && errno != EINTR) {
0 0 else if (wr < 0 && errno != EAGAIN && errno != EINTR) {
1202 143 652 if (unlikely(!req))
1213 652 0 FEER_REQ_FREE(req);
1236 1 215 if (unlikely(c->responding != RESPOND_NOT_STARTED)) {