From: Graham Leggett Date: Wed, 1 Apr 2015 10:03:56 +0000 (+0000) Subject: http: Add support for RFC2324/RFC7168. X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=7269d65ecba74867b4fc63dd405c451773f66a62;p=thirdparty%2Fapache%2Fhttpd.git http: Add support for RFC2324/RFC7168. Sample implementation: http://people.apache.org/~minfrin/mod_teapot.c git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1670594 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/CHANGES b/CHANGES index 6646e29697d..1ea17b7fcfc 100644 --- a/CHANGES +++ b/CHANGES @@ -1,6 +1,8 @@ -*- coding: utf-8 -*- Changes with Apache 2.5.0 + *) http: Add support for RFC2324/RFC7168. [Graham Leggett] + *) mod_proxy_wstunnel: Avoid an empty response by failing with 502 (Bad Gateway) when no response is ever received from the backend. [Jan Kaluza] diff --git a/include/ap_mmn.h b/include/ap_mmn.h index 280835d6535..816810968f0 100644 --- a/include/ap_mmn.h +++ b/include/ap_mmn.h @@ -481,6 +481,7 @@ * 20150121.2 (2.5.0-dev) Add response_code_exprs to http_core.h * 20150222.0 (2.5.0-dev) ssl pre_handshake hook now indicates proxy|client * 20150222.1 (2.5.0-dev) Add keep_alive_timeout_set to server_rec + * 20150222.2 (2.5.0-dev) Add response code 418 as per RFC2324/RFC7168 */ #define MODULE_MAGIC_COOKIE 0x41503235UL /* "AP25" */ @@ -488,7 +489,7 @@ #ifndef MODULE_MAGIC_NUMBER_MAJOR #define MODULE_MAGIC_NUMBER_MAJOR 20150222 #endif -#define MODULE_MAGIC_NUMBER_MINOR 1 /* 0...n */ +#define MODULE_MAGIC_NUMBER_MINOR 2 /* 0...n */ /** * Determine if the server's current MODULE_MAGIC_NUMBER is at least a diff --git a/include/httpd.h b/include/httpd.h index e6cf10fe80f..6e6eab57a7c 100644 --- a/include/httpd.h +++ b/include/httpd.h @@ -518,6 +518,7 @@ AP_DECLARE(const char *) ap_get_server_built(void); #define HTTP_UNSUPPORTED_MEDIA_TYPE 415 #define HTTP_RANGE_NOT_SATISFIABLE 416 #define HTTP_EXPECTATION_FAILED 417 +#define HTTP_IM_A_TEAPOT 418 #define HTTP_UNPROCESSABLE_ENTITY 422 #define HTTP_LOCKED 423 #define HTTP_FAILED_DEPENDENCY 424 @@ -605,6 +606,8 @@ AP_DECLARE(const char *) ap_get_server_built(void); #define M_BASELINE_CONTROL 24 #define M_MERGE 25 #define M_INVALID 26 /** no valid method */ +#define M_BREW 27 /** RFC 2324: HTCPCP/1.0 */ +#define M_WHEN 28 /** RFC 2324: HTCPCP/1.0 */ /** * METHODS needs to be equal to the number of bits diff --git a/modules/http/http_protocol.c b/modules/http/http_protocol.c index fc7ec6ccbe7..8cdcc6e65fa 100644 --- a/modules/http/http_protocol.c +++ b/modules/http/http_protocol.c @@ -132,7 +132,7 @@ static const char * const status_lines[RESPONSE_CODES] = "415 Unsupported Media Type", "416 Requested Range Not Satisfiable", "417 Expectation Failed", - NULL, /* 418 */ + "418 I'm A Teapot", NULL, /* 419 */ NULL, /* 420 */ NULL, /* 421 */ @@ -695,6 +695,8 @@ AP_DECLARE(void) ap_method_registry_init(apr_pool_t *p) register_one_method(p, "MKACTIVITY", M_MKACTIVITY); register_one_method(p, "BASELINE-CONTROL", M_BASELINE_CONTROL); register_one_method(p, "MERGE", M_MERGE); + register_one_method(p, "BREW", M_BREW); + register_one_method(p, "WHEN", M_WHEN); } AP_DECLARE(int) ap_method_register(apr_pool_t *p, const char *methname) @@ -793,6 +795,16 @@ static int lookup_builtin_method(const char *method, apr_size_t len) && method[2] == 'P' && method[3] == 'Y' ? M_COPY : UNKNOWN_METHOD); + case 'B': + return (method[1] == 'R' + && method[2] == 'E' + && method[3] == 'W' + ? M_BREW : UNKNOWN_METHOD); + case 'W': + return (method[1] == 'H' + && method[2] == 'E' + && method[3] == 'N' + ? M_WHEN : UNKNOWN_METHOD); default: return UNKNOWN_METHOD; } @@ -1293,6 +1305,9 @@ static const char *get_canned_error_string(int status, case HTTP_NETWORK_AUTHENTICATION_REQUIRED: return("

The client needs to authenticate to gain\n" "network access.

\n"); + case HTTP_IM_A_TEAPOT: + return("

The resulting entity body MAY be short and\n" + "stout.

\n"); default: /* HTTP_INTERNAL_SERVER_ERROR */ /* * This comparison to expose error-notes could be modified to