-*- coding: utf-8 -*-
Changes with Apache 2.5.0
+ *) core: New directive HttpProtocol which allows to disable HTTP/0.9
+ support. [Stefan Fritsch]
+
*) mod_allowhandlers: New module to forbid specific handlers for specific
directories. [Stefan Fritsch]
#define AP_TRACE_EXTENDED 2
int trace_enable;
+#define AP_HTTP09_UNSET 0
+#define AP_HTTP09_ENABLE 1
+#define AP_HTTP09_DISABLE 2
+ char http09_enable;
+
} core_server_config;
/* for AddOutputFiltersByType in core.c */
if (virt->trace_enable != AP_TRACE_UNSET)
conf->trace_enable = virt->trace_enable;
+ if (virt->http09_enable != AP_HTTP09_UNSET)
+ conf->http09_enable = virt->http09_enable;
+
/* no action for virt->accf_map, not allowed per-vhost */
if (virt->protocol)
return NULL;
}
+static const char *set_http_protocol(cmd_parms *cmd, void *dummy,
+ const char *arg1)
+{
+ core_server_config *conf =
+ ap_get_core_module_config(cmd->server->module_config);
+
+ if (strcmp(arg1, "+0.9") == 0) {
+ conf->http09_enable = AP_HTTP09_ENABLE;
+ }
+ else if (strcmp(arg1, "-0.9") == 0) {
+ conf->http09_enable = AP_HTTP09_DISABLE;
+ }
+ else {
+ return "HttpProtocol must be one of '+0.9' and '-0.9'";
+ }
+
+ return NULL;
+}
+
static apr_hash_t *errorlog_hash;
static int log_constant_item(const ap_errorlog_info *info, const char *arg,
#endif
AP_INIT_TAKE1("TraceEnable", set_trace_enable, NULL, RSRC_CONF,
"'on' (default), 'off' or 'extended' to trace request body content"),
+AP_INIT_TAKE1("HttpProtocol", set_http_protocol, NULL, RSRC_CONF,
+ "'+0.9' (default) or '-0.9' to allow/deny HTTP/0.9"),
{ NULL }
};
pro = ll;
len = strlen(ll);
} else {
+ core_server_config *conf;
+ conf = ap_get_core_module_config(r->server->module_config);
r->assbackwards = 1;
pro = "HTTP/0.9";
len = 8;
+ if (conf->http09_enable == AP_HTTP09_DISABLE) {
+ r->status = HTTP_VERSION_NOT_SUPPORTED;
+ r->protocol = apr_pstrmemdup(r->pool, pro, len);
+ r->proto_num = HTTP_VERSION(0, 9);
+ ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, APLOGNO(02401)
+ "HTTP/0.9 denied by server configuration");
+ return 0;
+ }
}
r->protocol = apr_pstrmemdup(r->pool, pro, len);
/* Get the request... */
if (!read_request_line(r, tmp_bb)) {
if (r->status == HTTP_REQUEST_URI_TOO_LARGE
- || r->status == HTTP_BAD_REQUEST) {
+ || r->status == HTTP_BAD_REQUEST
+ || r->status == HTTP_VERSION_NOT_SUPPORTED) {
if (r->status == HTTP_REQUEST_URI_TOO_LARGE) {
ap_log_rerror(APLOG_MARK, APLOG_INFO, 0, r, APLOGNO(00565)
"request failed: URI too long (longer than %d)",