Our URL parser. * * This is designed to be shared by http_parser_execute() for URL validation, * hence it has a state transition + byte-for-byte interface. In addition, it * is meant to be embedded in http_parser_parse_url(), which does the dirty * work of turning state transitions URL components for its API. * * This function should only be invoked with non-space characters. It is * assum
| 548 | * URL and non-URL states by looking for these. |
| 549 | */ |
| 550 | static enum state |
| 551 | parse_url_char(enum state s, const char ch) |
| 552 | { |
| 553 | if (ch == ' ' || ch == '\r' || ch == '\n') { |
| 554 | return s_dead; |
| 555 | } |
| 556 | |
| 557 | #if BRPC_HTTP_PARSER_STRICT |
| 558 | if (ch == '\t' || ch == '\f') { |
| 559 | return s_dead; |
| 560 | } |
| 561 | #endif |
| 562 | |
| 563 | switch (s) { |
| 564 | case s_req_spaces_before_url: |
| 565 | /* Proxied requests are followed by scheme of an absolute URI (alpha). |
| 566 | * All methods except CONNECT are followed by '/' or '*'. |
| 567 | */ |
| 568 | |
| 569 | if (ch == '/' || ch == '*') { |
| 570 | return s_req_path; |
| 571 | } |
| 572 | |
| 573 | if (IS_ALPHA(ch)) { |
| 574 | return s_req_scheme; |
| 575 | } |
| 576 | |
| 577 | break; |
| 578 | |
| 579 | case s_req_scheme: |
| 580 | if (IS_ALPHA(ch)) { |
| 581 | return s; |
| 582 | } |
| 583 | |
| 584 | if (ch == ':') { |
| 585 | return s_req_scheme_slash; |
| 586 | } |
| 587 | |
| 588 | break; |
| 589 | |
| 590 | case s_req_scheme_slash: |
| 591 | if (ch == '/') { |
| 592 | return s_req_scheme_slash_slash; |
| 593 | } |
| 594 | |
| 595 | break; |
| 596 | |
| 597 | case s_req_scheme_slash_slash: |
| 598 | if (ch == '/') { |
| 599 | return s_req_server_start; |
| 600 | } |
| 601 | |
| 602 | break; |
| 603 | |
| 604 | case s_req_server_with_at: |
| 605 | if (ch == '@') { |
| 606 | return s_dead; |
| 607 | } |
no outgoing calls
no test coverage detected