Branch Coverage

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


line true false branch
5 646 16 if (likely(!req)) {
6 487 159 FEER_REQ_ALLOC(req);
37 105 646 if (unlikely(c->pipelined)) goto pipelined;
41 0 646 if (unlikely(revents & EV_ERROR && !(revents & EV_READ))) {
0 0 if (unlikely(revents & EV_ERROR && !(revents & EV_READ))) {
46 0 646 if (unlikely(c->receiving == RECEIVE_SHUTDOWN))
51 594 52 if (unlikely(!c->rbuf)) { // unlikely = optimize for keepalive requests
58 29 617 if (unlikely(space_free < READ_BUFSZ)) { // unlikely = optimize for small
61 0 29 if (unlikely(cur_len + READ_GROW_FACTOR*READ_BUFSZ > c->cached_max_read_buf)) {
70 29 0 SvGROW(c->rbuf, new_len);
29 0 SvGROW(c->rbuf, new_len);
77 31 615 if (unlikely(got_n <= 0)) {
78 29 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 603 if (c->receiving == RECEIVE_WAIT)
100 136 617 if (unlikely(c->receiving == RECEIVE_PROXY_HEADER)) {
102 101 35 if (ret == -1) {
106 2 33 if (ret == -2) goto try_read_again_reset_timer;
110 33 0 if (remaining > 0)
115 0 33 feer_clear_remote_cache(c);
0 33 feer_clear_remote_cache(c);
119 33 0 if (remaining > 0) {
127 603 14 if (likely(c->receiving <= RECEIVE_HEADERS)) {
129 13 590 if (ret == -1) goto try_read_bad;
131 22 568 if (ret == -2) goto try_read_again_reset_timer;
139 17 551 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 656 if (unlikely(prep_socket(fd, lsnr->is_tcp))) {
337 0 0 if (unlikely(close(fd) < 0))
345 655 1 if (srvr->header_timeout > 0.0) {
355 68 588 if (lsnr->tls_ctx_ref) {
388 0 0 if (lsnr->server->shutting_down) return;
392 0 0 if (!lsnr->pause_flags && lsnr->fd >= 0)
0 0 if (!lsnr->pause_flags && lsnr->fd >= 0)
412 580 657 if (fd == -1) {
413 0 580 if (errno == EINTR) return 1;
414 580 0 if (errno == EMFILE || errno == ENFILE) {
0 580 if (errno == EMFILE || errno == ENFILE) {
425 656 1 if (srvr->max_connections > 0 && srvr->active_conns >= srvr->max_connections) {
3 653 if (srvr->max_connections > 0 && srvr->active_conns >= srvr->max_connections) {
426 1 2 if (!feer_server_recycle_idle_conn(srvr)) {
451 0 0 if (unlikely(srvr->shutting_down)) {
456 0 0 if (unlikely(revents & EV_ERROR)) {
463 0 0 while (accept_count++ < srvr->max_accept_per_loop) {
464 0 0 if (epoll_wait(lsnr->epoll_fd, events, 1, 0) <= 0) break;
465 0 0 if (!try_accept_one(EV_A, lsnr, srvr)) break;
476 0 581 if (unlikely(srvr->shutting_down)) {
481 0 581 if (unlikely(revents & EV_ERROR)) {
490 1237 0 while (accept_count++ < srvr->max_accept_per_loop) {
491 581 656 if (!try_accept_one(EV_A, lsnr, srvr)) break;
501 2 218 if (srvr->use_epoll_exclusive) {
506 0 2 if (lsnr->epoll_fd < 0) {
513 0 2 if (epoll_ctl(lsnr->epoll_fd, EPOLL_CTL_ADD, listen_fd, &ev) < 0) {
515 0 0 if (unlikely(close(lsnr->epoll_fd) < 0))
551 384 164 if (!ev_is_active(&server->ei)) {
564 0 71 if (!c->rbuf) return 1; // need data
575 5523 2 while (read_pos < buf_len) {
576 2 5521 if (c->chunk_remaining == CHUNK_STATE_NEED_CRLF) {
579 0 2 if (remaining < 2)
581 2 0 if (buf[read_pos] != '\r' || buf[read_pos+1] != '\n') {
0 2 if (buf[read_pos] != '\r' || buf[read_pos+1] != '\n') {
589 2766 2755 else if (c->chunk_remaining == CHUNK_STATE_PARSE_SIZE) {
597 5856 0 for (i = 0; i + 1 < remaining; i++) {
598 2766 3090 if (line_start[i] == '\r' && line_start[i+1] == '\n') {
2766 0 if (line_start[i] == '\r' && line_start[i+1] == '\n') {
604 0 2766 if (!line_end) {
615 2798 2750 while (p < line_end) {
618 2783 15 if (val != 0xFF) {
621 1 2782 if (chunk_size > (UV_MAX >> 4)) {
627 8 7 else if (ch == ';' || ch == ' ' || ch == '\t') {
6 2 else if (ch == ';' || ch == ' ' || ch == '\t') {
6 0 else if (ch == ';' || ch == ' ' || ch == '\t') {
638 4 2755 if (hex_digits == 0) {
649 52 2703 if (chunk_size == 0) {
662 0 2703 if (unlikely(chunk_size > (UV)c->cached_max_body_len)) {
666 0 2703 if (unlikely(write_pos > (STRLEN)(c->cached_max_body_len - chunk_size))) {
674 0 2703 if (unlikely(c->chunk_count > MAX_CHUNK_COUNT)) {
679 0 2703 if (chunk_size > (UV)SSIZE_MAX) return -1;
682 52 2703 else if (c->chunk_remaining == 0) {
688 5794 0 while (i + 1 < remaining) {
689 317 5477 if (trailer_start[i] == '\r' && trailer_start[i+1] == '\n') {
317 0 if (trailer_start[i] == '\r' && trailer_start[i+1] == '\n') {
690 50 267 if (i == 0) {
693 2 48 STRLEN pipelined = (read_pos < buf_len) ? buf_len - read_pos : 0;
696 2 48 if (pipelined > 0)
702 2 265 if (unlikely(++c->trailer_count > MAX_TRAILER_HEADERS)) {
720 2 2701 if (to_copy > remaining)
724 2703 0 if (write_pos != read_pos && to_copy > 0) {
2703 0 if (write_pos != read_pos && to_copy > 0) {
732 2 2701 if (c->chunk_remaining > 0) {
739 2 2699 if (remaining < 2) {
744 2697 2 if (buf[read_pos] != '\r' || buf[read_pos+1] != '\n') {
0 2697 if (buf[read_pos] != '\r' || buf[read_pos+1] != '\n') {
755 4 2 if (read_pos > write_pos) {
756 0 4 if (read_pos < buf_len) {
796 254 373 c->is_keepalive = c->cached_keepalive_default && c->is_http11;
246 8 c->is_keepalive = c->cached_keepalive_default && c->is_http11;
808 450 1 if (likely(memcmp(req->method, "GET", 3) == 0)) {
810 1 0 } else if (memcmp(req->method, "PUT", 3) == 0) {
817 165 2 if (likely(memcmp(req->method, "POST", 4) == 0)) {
819 2 0 } else if (memcmp(req->method, "HEAD", 4) == 0) {
826 2 0 if (memcmp(req->method, "PATCH", 5) == 0) {
833 2 1 if (memcmp(req->method, "DELETE", 6) == 0) {
840 2 0 if (memcmp(req->method, "OPTIONS", 7) == 0) {
854 3 621 if (unlikely(req->uri_len > c->cached_max_uri_len)) {
873 621 0 if (unlikely(body_offset < 0 || (STRLEN)body_offset > from_len)) {
0 621 if (unlikely(body_offset < 0 || (STRLEN)body_offset > from_len)) {
882 253 368 SV *new_rbuf = newSVpvn(need > 0 ? from : "", need);
892 1529 572 for (size_t i = 0; i < req->num_headers; i++) {
895 1 1528 if (unlikely(!hdr->name)) {
902 2 1526 if (unlikely(hdr->name_len > MAX_HEADER_NAME_LEN)) {
907 88 1438 if (unlikely(hdr->name_len == 14 &&
88 0 if (unlikely(hdr->name_len == 14 &&
911 3 85 if (c->receive_chunked) {
918 83 2 if (likely(g == IS_NUMBER_IN_UV)) {
919 4 79 if (unlikely(new_expected > (UV)c->cached_max_body_len)) {
925 4 75 if (got_content_length && new_expected != expected) {
2 2 if (got_content_length && new_expected != expected) {
939 568 870 else if (unlikely(hdr->name_len == 10 &&
415 153 else if (unlikely(hdr->name_len == 10 &&
942 410 5 if (c->is_http11 && c->is_keepalive &&
92 318 if (c->is_http11 && c->is_keepalive &&
943 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))
948 5 327 else if (!c->is_http11 && c->cached_keepalive_default &&
5 0 else if (!c->is_http11 && c->cached_keepalive_default &&
949 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))
954 309 106 if (next_req_follows && c->receive_chunked && (!c->is_http11 || got_host)) break;
4 305 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;
956 997 26 else if (unlikely(c->is_http11 && hdr->name_len == 6 &&
41 956 else if (unlikely(c->is_http11 && hdr->name_len == 6 &&
41 982 else if (unlikely(c->is_http11 && hdr->name_len == 6 &&
22 19 else if (unlikely(c->is_http11 && hdr->name_len == 6 &&
973 975 26 else if (unlikely(c->is_http11 && hdr->name_len == 17 &&
115 860 else if (unlikely(c->is_http11 && hdr->name_len == 17 &&
115 886 else if (unlikely(c->is_http11 && hdr->name_len == 17 &&
103 12 else if (unlikely(c->is_http11 && hdr->name_len == 17 &&
978 6 97 if (got_transfer_encoding) {
987 87 8 bool is_chunked = (hdr->value_len >= 7 &&
988 95 2 str_case_eq_fixed("chunked", hdr->value, 7) &&
989 3 84 (hdr->value_len == 7 ||
990 1 2 hdr->value[7] == ';' ||
991 0 1 hdr->value[7] == ' ' ||
992 0 0 hdr->value[7] == '\t'));
998 87 10 if (is_chunked) {
1001 8 79 if (got_content_length) {
1009 6 4 else if (is_identity) {
1020 622 276 else if (unlikely(hdr->name_len == 4 &&
622 0 else if (unlikely(hdr->name_len == 4 &&
1023 2 620 if (unlikely(got_host)) {
1033 561 15 if (unlikely(c->is_http11 && !got_host)) {
1 560 if (unlikely(c->is_http11 && !got_host)) {
1039 27 548 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) {
1048 71 504 if (unlikely(c->receive_chunked && next_req_follows)) {
4 67 if (unlikely(c->receive_chunked && next_req_follows)) {
1054 443 128 if (likely(next_req_follows) && !got_content_length && !c->receive_chunked) goto got_it_all;
443 0 if (likely(next_req_follows) && !got_content_length && !c->receive_chunked) goto got_it_all;
443 0 if (likely(next_req_follows) && !got_content_length && !c->receive_chunked) goto got_it_all;
1055 57 71 else if (likely(got_content_length)) goto got_cl;
1056 67 4 else if (unlikely(c->receive_chunked)) goto got_chunked;
1071 57 0 SvGROW(c->rbuf, c->expected_cl + 1);
3 54 SvGROW(c->rbuf, c->expected_cl + 1);
1075 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)) {
1097 6 61 if (ret == 1)
1099 15 46 if (ret == -1) {
1122 633 761 if (c->in_callback) {
1130 50 711 if (c->tls) {
1171 67 13 if (likely(!c->expect_continue))
1176 2 11 if (c->tls) {
1179 0 2 if (c->tls_wbuf.off > 0)
1188 0 11 if (likely(wr > 0)) {
1191 0 0 else if (wr < 0 && errno != EAGAIN && errno != EINTR) {
0 0 else if (wr < 0 && errno != EAGAIN && errno != EINTR) {
1200 146 644 if (unlikely(!req))
1211 644 0 FEER_REQ_FREE(req);
1234 1 213 if (unlikely(c->responding != RESPOND_NOT_STARTED)) {