| 756 | #define UNKNOWN_METHOD (-1) |
| 757 | |
| 758 | static int lookup_builtin_method(const char *method, apr_size_t len) |
| 759 | { |
| 760 | /* Note: the following code was generated by the "shilka" tool from |
| 761 | the "cocom" parsing/compilation toolkit. It is an optimized lookup |
| 762 | based on analysis of the input keywords. Postprocessing was done |
| 763 | on the shilka output, but the basic structure and analysis is |
| 764 | from there. Should new HTTP methods be added, then manual insertion |
| 765 | into this code is fine, or simply re-running the shilka tool on |
| 766 | the appropriate input. */ |
| 767 | |
| 768 | /* Note: it is also quite reasonable to just use our method_registry, |
| 769 | but I'm assuming (probably incorrectly) we want more speed here |
| 770 | (based on the optimizations the previous code was doing). */ |
| 771 | |
| 772 | switch (len) |
| 773 | { |
| 774 | case 3: |
| 775 | switch (method[0]) |
| 776 | { |
| 777 | case 'P': |
| 778 | return (method[1] == 'U' |
| 779 | && method[2] == 'T' |
| 780 | ? M_PUT : UNKNOWN_METHOD); |
| 781 | case 'G': |
| 782 | return (method[1] == 'E' |
| 783 | && method[2] == 'T' |
| 784 | ? M_GET : UNKNOWN_METHOD); |
| 785 | default: |
| 786 | return UNKNOWN_METHOD; |
| 787 | } |
| 788 | |
| 789 | case 4: |
| 790 | switch (method[0]) |
| 791 | { |
| 792 | case 'H': |
| 793 | return (method[1] == 'E' |
| 794 | && method[2] == 'A' |
| 795 | && method[3] == 'D' |
| 796 | ? M_GET : UNKNOWN_METHOD); |
| 797 | case 'P': |
| 798 | return (method[1] == 'O' |
| 799 | && method[2] == 'S' |
| 800 | && method[3] == 'T' |
| 801 | ? M_POST : UNKNOWN_METHOD); |
| 802 | case 'M': |
| 803 | return (method[1] == 'O' |
| 804 | && method[2] == 'V' |
| 805 | && method[3] == 'E' |
| 806 | ? M_MOVE : UNKNOWN_METHOD); |
| 807 | case 'L': |
| 808 | return (method[1] == 'O' |
| 809 | && method[2] == 'C' |
| 810 | && method[3] == 'K' |
| 811 | ? M_LOCK : UNKNOWN_METHOD); |
| 812 | case 'C': |
| 813 | return (method[1] == 'O' |
| 814 | && method[2] == 'P' |
| 815 | && method[3] == 'Y' |
no outgoing calls
no test coverage detected