Branch Coverage

feersum_h1.c.inc
Criterion Covered Total %
branch 298 420 70.9


line true false branch
5 624 16 if (likely(!req)) {
6 465 159 FEER_REQ_ALLOC(req);
37 105 626 if (unlikely(c->pipelined)) goto pipelined;
41 0 626 if (unlikely(revents & EV_ERROR && !(revents & EV_READ))) {
0 0 if (unlikely(revents & EV_ERROR && !(revents & EV_READ))) {
46 0 626 if (unlikely(c->receiving == RECEIVE_SHUTDOWN))
51 574 52 if (unlikely(!c->rbuf)) { // unlikely = optimize for keepalive requests
58 29 597 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 595 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 583 if (c->receiving == RECEIVE_WAIT)
100 136 595 if (unlikely(c->receiving == RECEIVE_PROXY_HEADER)) {
102 103 33 if (ret == -1) {
106 2 31 if (ret == -2) goto try_read_again_reset_timer;
110 31 0 if (remaining > 0)
115 0 31 feer_clear_remote_cache(c);
0 31 feer_clear_remote_cache(c);
119 31 0 if (remaining > 0) {
127 581 14 if (likely(c->receiving <= RECEIVE_HEADERS)) {
129 11 570 if (ret == -1) goto try_read_bad;
131 22 548 if (ret == -2) goto try_read_again_reset_timer;
139 17 531 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)
248 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) {
250 0 5 if (c->tls && !c->tls_handshake_done) {
0 0 if (c->tls && !c->tls_handshake_done) {
260 0 5 if (c->receiving == RECEIVE_PROXY_HEADER) {
263 2 3 else if (c->receiving == RECEIVE_HEADERS) {
289 8 0 if (unlikely(!(revents & EV_TIMER) || c->receiving == RECEIVE_SHUTDOWN)) {
0 8 if (unlikely(!(revents & EV_TIMER) || c->receiving == RECEIVE_SHUTDOWN)) {
290 0 0 if (revents & EV_ERROR)
297 0 8 if ((c->receiving == RECEIVE_HEADERS || c->receiving == RECEIVE_PROXY_HEADER)
0 0 if ((c->receiving == RECEIVE_HEADERS || c->receiving == RECEIVE_PROXY_HEADER)
298 0 8 && c->responding == RESPOND_NOT_STARTED) {
301 4 4 if (c->tls && !c->tls_handshake_done) {
4 0 if (c->tls && !c->tls_handshake_done) {
326 0 0 if (unlikely(!(revents & EV_TIMER) || c->responding == RESPOND_SHUTDOWN)) {
0 0 if (unlikely(!(revents & EV_TIMER) || c->responding == RESPOND_SHUTDOWN)) {
327 0 0 if (revents & EV_ERROR)
349 0 636 if (unlikely(prep_socket(fd, lsnr->is_tcp))) {
351 0 0 if (unlikely(close(fd) < 0))
359 635 1 if (srvr->header_timeout > 0.0) {
369 68 568 if (lsnr->tls_ctx_ref) {
402 0 0 if (lsnr->server->shutting_down) return;
424 560 637 if (fd == -1) {
425 0 560 if (errno == EINTR) return 1;
426 560 0 if (errno == EMFILE || errno == ENFILE) {
0 560 if (errno == EMFILE || errno == ENFILE) {
437 636 1 if (srvr->max_connections > 0 && srvr->active_conns >= srvr->max_connections) {
3 633 if (srvr->max_connections > 0 && srvr->active_conns >= srvr->max_connections) {
438 1 2 if (!feer_server_recycle_idle_conn(srvr)) {
458 0 0 if (unlikely(srvr->shutting_down)) {
463 0 0 if (unlikely(revents & EV_ERROR)) {
470 0 0 while (accept_count++ < srvr->max_accept_per_loop) {
471 0 0 if (epoll_wait(lsnr->epoll_fd, events, 1, 0) <= 0) break;
472 0 0 if (!try_accept_one(EV_A, lsnr, srvr)) break;
483 0 561 if (unlikely(srvr->shutting_down)) {
488 0 561 if (unlikely(revents & EV_ERROR)) {
497 1197 0 while (accept_count++ < srvr->max_accept_per_loop) {
498 561 636 if (!try_accept_one(EV_A, lsnr, srvr)) break;
508 2 213 if (srvr->use_epoll_exclusive) {
513 0 2 if (lsnr->epoll_fd < 0) {
520 0 2 if (epoll_ctl(lsnr->epoll_fd, EPOLL_CTL_ADD, listen_fd, &ev) < 0) {
522 0 0 if (unlikely(close(lsnr->epoll_fd) < 0))
558 368 164 if (!ev_is_active(&server->ei)) {
571 0 71 if (!c->rbuf) return 1; // need data
582 5523 2 while (read_pos < buf_len) {
583 2 5521 if (c->chunk_remaining == CHUNK_STATE_NEED_CRLF) {
586 0 2 if (remaining < 2)
588 2 0 if (buf[read_pos] != '\r' || buf[read_pos+1] != '\n') {
0 2 if (buf[read_pos] != '\r' || buf[read_pos+1] != '\n') {
596 2766 2755 else if (c->chunk_remaining == CHUNK_STATE_PARSE_SIZE) {
604 5856 0 for (i = 0; i + 1 < remaining; i++) {
605 2766 3090 if (line_start[i] == '\r' && line_start[i+1] == '\n') {
2766 0 if (line_start[i] == '\r' && line_start[i+1] == '\n') {
611 0 2766 if (!line_end) {
622 2798 2750 while (p < line_end) {
625 2783 15 if (val != 0xFF) {
628 1 2782 if (chunk_size > (UV_MAX >> 4)) {
634 8 7 else if (ch == ';' || ch == ' ' || ch == '\t') {
6 2 else if (ch == ';' || ch == ' ' || ch == '\t') {
6 0 else if (ch == ';' || ch == ' ' || ch == '\t') {
645 4 2755 if (hex_digits == 0) {
656 52 2703 if (chunk_size == 0) {
669 0 2703 if (unlikely(chunk_size > (UV)c->cached_max_body_len)) {
673 0 2703 if (unlikely(write_pos > (STRLEN)(c->cached_max_body_len - chunk_size))) {
681 0 2703 if (unlikely(c->chunk_count > MAX_CHUNK_COUNT)) {
686 0 2703 if (chunk_size > (UV)SSIZE_MAX) return -1;
689 52 2703 else if (c->chunk_remaining == 0) {
696 5794 0 while (i + 1 < remaining) {
697 317 5477 if (trailer_start[i] == '\r' && trailer_start[i+1] == '\n') {
317 0 if (trailer_start[i] == '\r' && trailer_start[i+1] == '\n') {
698 50 267 if (i == 0) {
701 2 48 STRLEN pipelined = (read_pos < buf_len) ? buf_len - read_pos : 0;
704 2 48 if (pipelined > 0)
710 2 265 if (unlikely(++c->trailer_count > MAX_TRAILER_HEADERS)) {
728 2 2701 if (to_copy > remaining)
732 2703 0 if (write_pos != read_pos && to_copy > 0) {
2703 0 if (write_pos != read_pos && to_copy > 0) {
740 2 2701 if (c->chunk_remaining > 0) {
747 2 2699 if (remaining < 2) {
752 2697 2 if (buf[read_pos] != '\r' || buf[read_pos+1] != '\n') {
0 2697 if (buf[read_pos] != '\r' || buf[read_pos+1] != '\n') {
763 4 2 if (read_pos > write_pos) {
764 0 4 if (read_pos < buf_len) {
804 254 353 c->is_keepalive = c->cached_keepalive_default && c->is_http11;
246 8 c->is_keepalive = c->cached_keepalive_default && c->is_http11;
816 433 1 if (likely(memcmp(req->method, "GET", 3) == 0)) {
818 1 0 } else if (memcmp(req->method, "PUT", 3) == 0) {
825 165 1 if (likely(memcmp(req->method, "POST", 4) == 0)) {
827 1 0 } else if (memcmp(req->method, "HEAD", 4) == 0) {
834 2 0 if (memcmp(req->method, "PATCH", 5) == 0) {
841 1 1 if (memcmp(req->method, "DELETE", 6) == 0) {
848 1 0 if (memcmp(req->method, "OPTIONS", 7) == 0) {
862 3 601 if (unlikely(req->uri_len > c->cached_max_uri_len)) {
881 601 0 if (unlikely(body_offset < 0 || (STRLEN)body_offset > from_len)) {
0 601 if (unlikely(body_offset < 0 || (STRLEN)body_offset > from_len)) {
890 249 352 SV *new_rbuf = newSVpvn(need > 0 ? from : "", need);
901 1485 556 for (i=0; i < req->num_headers; i++) {
904 1 1484 if (unlikely(!hdr->name)) {
911 2 1482 if (unlikely(hdr->name_len > MAX_HEADER_NAME_LEN)) {
916 88 1394 if (unlikely(hdr->name_len == 14 &&
88 0 if (unlikely(hdr->name_len == 14 &&
920 3 85 if (c->receive_chunked) {
927 83 2 if (likely(g == IS_NUMBER_IN_UV)) {
928 4 79 if (unlikely(new_expected > (UV)c->cached_max_body_len)) {
934 4 75 if (got_content_length && new_expected != expected) {
2 2 if (got_content_length && new_expected != expected) {
948 548 846 else if (unlikely(hdr->name_len == 10 &&
395 153 else if (unlikely(hdr->name_len == 10 &&
951 390 5 if (c->is_http11 && c->is_keepalive &&
92 298 if (c->is_http11 && c->is_keepalive &&
952 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))
957 5 307 else if (!c->is_http11 && c->cached_keepalive_default &&
5 0 else if (!c->is_http11 && c->cached_keepalive_default &&
958 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))
963 289 106 if (next_req_follows && c->receive_chunked && (!c->is_http11 || got_host)) break;
0 289 if (next_req_follows && c->receive_chunked && (!c->is_http11 || got_host)) break;
0 0 if (next_req_follows && c->receive_chunked && (!c->is_http11 || got_host)) break;
0 0 if (next_req_follows && c->receive_chunked && (!c->is_http11 || got_host)) break;
965 973 26 else if (unlikely(c->is_http11 && hdr->name_len == 6 &&
41 932 else if (unlikely(c->is_http11 && hdr->name_len == 6 &&
41 958 else if (unlikely(c->is_http11 && hdr->name_len == 6 &&
22 19 else if (unlikely(c->is_http11 && hdr->name_len == 6 &&
982 951 26 else if (unlikely(c->is_http11 && hdr->name_len == 17 &&
111 840 else if (unlikely(c->is_http11 && hdr->name_len == 17 &&
111 866 else if (unlikely(c->is_http11 && hdr->name_len == 17 &&
99 12 else if (unlikely(c->is_http11 && hdr->name_len == 17 &&
987 6 93 if (got_transfer_encoding) {
996 83 8 bool is_chunked = (hdr->value_len >= 7 &&
997 91 2 str_case_eq_fixed("chunked", hdr->value, 7) &&
998 3 80 (hdr->value_len == 7 ||
999 1 2 hdr->value[7] == ';' ||
1000 0 1 hdr->value[7] == ' ' ||
1001 0 0 hdr->value[7] == '\t'));
1007 83 10 if (is_chunked) {
1010 8 75 if (got_content_length) {
1018 6 4 else if (is_identity) {
1029 602 276 else if (unlikely(hdr->name_len == 4 &&
602 0 else if (unlikely(hdr->name_len == 4 &&
1032 2 600 if (unlikely(got_host)) {
1042 541 15 if (unlikely(c->is_http11 && !got_host)) {
1 540 if (unlikely(c->is_http11 && !got_host)) {
1048 27 528 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) {
1053 427 128 if (likely(next_req_follows) && !got_content_length && !c->receive_chunked) goto got_it_all;
427 0 if (likely(next_req_follows) && !got_content_length && !c->receive_chunked) goto got_it_all;
427 0 if (likely(next_req_follows) && !got_content_length && !c->receive_chunked) goto got_it_all;
1054 57 71 else if (likely(got_content_length)) goto got_cl;
1055 67 4 else if (unlikely(c->receive_chunked)) goto got_chunked;
1070 57 0 SvGROW(c->rbuf, c->expected_cl + 1);
3 54 SvGROW(c->rbuf, c->expected_cl + 1);
1074 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 617 741 if (c->in_callback) {
1130 50 691 if (c->tls) {
1175 67 13 if (likely(!c->expect_continue))
1180 2 11 if (c->tls) {
1183 0 2 if (c->tls_wbuf.off > 0)
1192 0 11 if (likely(wr > 0)) {
1195 0 0 else if (wr < 0 && errno != EAGAIN && errno != EINTR) {
0 0 else if (wr < 0 && errno != EAGAIN && errno != EINTR) {
1204 148 622 if (unlikely(!req))
1207 457 165 if (req->buf)
1209 317 305 if (likely(req->path))
1211 317 305 if (likely(req->query))
1219 622 0 FEER_REQ_FREE(req);
1242 1 196 if (unlikely(c->responding != RESPOND_NOT_STARTED)) {