| 862 | -------------------------------------------------------------------------*/ |
| 863 | |
| 864 | inline static HTTPKeepAlive |
| 865 | is_header_keep_alive(const HTTPVersion &http_version, const MIMEField *con_hdr) |
| 866 | { |
| 867 | enum { |
| 868 | CON_TOKEN_NONE = 0, |
| 869 | CON_TOKEN_KEEP_ALIVE, |
| 870 | CON_TOKEN_CLOSE, |
| 871 | }; |
| 872 | |
| 873 | int con_token = CON_TOKEN_NONE; |
| 874 | HTTPKeepAlive keep_alive = HTTP_NO_KEEPALIVE; |
| 875 | // *unknown_tokens = false; |
| 876 | |
| 877 | if (con_hdr) { |
| 878 | if (con_hdr->value_get_index("keep-alive", 10) >= 0) |
| 879 | con_token = CON_TOKEN_KEEP_ALIVE; |
| 880 | else if (con_hdr->value_get_index("close", 5) >= 0) |
| 881 | con_token = CON_TOKEN_CLOSE; |
| 882 | } |
| 883 | |
| 884 | if (HTTP_1_0 == http_version) { |
| 885 | keep_alive = (con_token == CON_TOKEN_KEEP_ALIVE) ? (HTTP_KEEPALIVE) : (HTTP_NO_KEEPALIVE); |
| 886 | } else if (HTTP_1_1 == http_version) { |
| 887 | // We deviate from the spec here. If the we got a response where |
| 888 | // where there is no Connection header and the request 1.0 was |
| 889 | // 1.0 don't treat this as keep-alive since Netscape-Enterprise/3.6 SP1 |
| 890 | // server doesn't |
| 891 | keep_alive = ((con_token == CON_TOKEN_KEEP_ALIVE) || (con_token == CON_TOKEN_NONE && HTTP_1_1 == http_version)) ? |
| 892 | (HTTP_KEEPALIVE) : |
| 893 | (HTTP_NO_KEEPALIVE); |
| 894 | } else { |
| 895 | keep_alive = HTTP_NO_KEEPALIVE; |
| 896 | } |
| 897 | return (keep_alive); |
| 898 | } |
| 899 | |
| 900 | inline HTTPKeepAlive |
| 901 | HTTPHdr::keep_alive_get() const |
no test coverage detected