f0d6ab
diff --git a/mod_wsgi.c b/mod_wsgi.c
f0d6ab
index c65344e..b32fc5c 100644
f0d6ab
--- a/mod_wsgi.c
f0d6ab
+++ b/mod_wsgi.c
f0d6ab
@@ -500,6 +500,7 @@ typedef struct {
f0d6ab
     int script_reloading;
f0d6ab
     int error_override;
f0d6ab
     int chunked_request;
f0d6ab
+    int map_head_to_get;
f0d6ab
 
f0d6ab
     int enable_sendfile;
f0d6ab
 
f0d6ab
@@ -669,6 +670,11 @@ static void *wsgi_merge_server_config(apr_pool_t *p, void *base_conf,
f0d6ab
     else
f0d6ab
         config->chunked_request = parent->chunked_request;
f0d6ab
 
f0d6ab
+    if (child->map_head_to_get != -1)
f0d6ab
+        config->map_head_to_get = child->map_head_to_get;
f0d6ab
+    else
f0d6ab
+        config->map_head_to_get = parent->map_head_to_get;
f0d6ab
+
f0d6ab
     if (child->enable_sendfile != -1)
f0d6ab
         config->enable_sendfile = child->enable_sendfile;
f0d6ab
     else
f0d6ab
@@ -704,6 +710,7 @@ typedef struct {
f0d6ab
     int script_reloading;
f0d6ab
     int error_override;
f0d6ab
     int chunked_request;
f0d6ab
+    int map_head_to_get;
f0d6ab
 
f0d6ab
     int enable_sendfile;
f0d6ab
 
f0d6ab
@@ -737,6 +744,7 @@ static WSGIDirectoryConfig *newWSGIDirectoryConfig(apr_pool_t *p)
f0d6ab
     object->script_reloading = -1;
f0d6ab
     object->error_override = -1;
f0d6ab
     object->chunked_request = -1;
f0d6ab
+    object->map_head_to_get = -1;
f0d6ab
 
f0d6ab
     object->enable_sendfile = -1;
f0d6ab
 
f0d6ab
@@ -820,6 +828,11 @@ static void *wsgi_merge_dir_config(apr_pool_t *p, void *base_conf,
f0d6ab
     else
f0d6ab
         config->chunked_request = parent->chunked_request;
f0d6ab
 
f0d6ab
+    if (child->map_head_to_get != -1)
f0d6ab
+        config->map_head_to_get = child->map_head_to_get;
f0d6ab
+    else
f0d6ab
+        config->map_head_to_get = parent->map_head_to_get;
f0d6ab
+
f0d6ab
     if (child->enable_sendfile != -1)
f0d6ab
         config->enable_sendfile = child->enable_sendfile;
f0d6ab
     else
f0d6ab
@@ -880,6 +893,7 @@ typedef struct {
f0d6ab
     int script_reloading;
f0d6ab
     int error_override;
f0d6ab
     int chunked_request;
f0d6ab
+    int map_head_to_get;
f0d6ab
 
f0d6ab
     int enable_sendfile;
f0d6ab
 
f0d6ab
@@ -1229,6 +1243,14 @@ static WSGIRequestConfig *wsgi_create_req_config(apr_pool_t *p, request_rec *r)
f0d6ab
             config->chunked_request = 0;
f0d6ab
     }
f0d6ab
 
f0d6ab
+    config->map_head_to_get = dconfig->map_head_to_get;
f0d6ab
+
f0d6ab
+    if (config->map_head_to_get < 0) {
f0d6ab
+        config->map_head_to_get = sconfig->map_head_to_get;
f0d6ab
+        if (config->map_head_to_get < 0)
f0d6ab
+            config->map_head_to_get = 2;
f0d6ab
+    }
f0d6ab
+
f0d6ab
     config->enable_sendfile = dconfig->enable_sendfile;
f0d6ab
 
f0d6ab
     if (config->enable_sendfile < 0) {
f0d6ab
@@ -7993,6 +8015,40 @@ static const char *wsgi_set_chunked_request(cmd_parms *cmd, void *mconfig,
f0d6ab
     return NULL;
f0d6ab
 }
f0d6ab
 
f0d6ab
+static const char *wsgi_set_map_head_to_get(cmd_parms *cmd, void *mconfig,
f0d6ab
+                                            const char *f)
f0d6ab
+{
f0d6ab
+    if (cmd->path) {
f0d6ab
+        WSGIDirectoryConfig *dconfig = NULL;
f0d6ab
+        dconfig = (WSGIDirectoryConfig *)mconfig;
f0d6ab
+
f0d6ab
+        if (strcasecmp(f, "Off") == 0)
f0d6ab
+            dconfig->map_head_to_get = 0;
f0d6ab
+        else if (strcasecmp(f, "On") == 0)
f0d6ab
+            dconfig->map_head_to_get = 1;
f0d6ab
+        else if (strcasecmp(f, "Auto") == 0)
f0d6ab
+            dconfig->map_head_to_get = 2;
f0d6ab
+        else
f0d6ab
+            return "WSGIMapHEADToGET must be one of: Off | On | Auto";
f0d6ab
+    }
f0d6ab
+    else {
f0d6ab
+        WSGIServerConfig *sconfig = NULL;
f0d6ab
+        sconfig = ap_get_module_config(cmd->server->module_config,
f0d6ab
+                                       &wsgi_module);
f0d6ab
+
f0d6ab
+        if (strcasecmp(f, "Off") == 0)
f0d6ab
+            sconfig->map_head_to_get = 0;
f0d6ab
+        else if (strcasecmp(f, "On") == 0)
f0d6ab
+            sconfig->map_head_to_get = 1;
f0d6ab
+        else if (strcasecmp(f, "Auto") == 0)
f0d6ab
+            sconfig->map_head_to_get = 2;
f0d6ab
+        else
f0d6ab
+            return "WSGIMapHEADToGET must be one of: Off | On | Auto";
f0d6ab
+    }
f0d6ab
+
f0d6ab
+    return NULL;
f0d6ab
+}
f0d6ab
+
f0d6ab
 static const char *wsgi_set_enable_sendfile(cmd_parms *cmd, void *mconfig,
f0d6ab
                                             const char *f)
f0d6ab
 {
f0d6ab
@@ -8463,14 +8519,15 @@ static void wsgi_build_environment(request_rec *r)
f0d6ab
      * might change the content and/or headers.
f0d6ab
      */
f0d6ab
 
f0d6ab
-#if AP_SERVER_MAJORVERSION_NUMBER >= 2
f0d6ab
-    if (r->method_number == M_GET && r->header_only &&
f0d6ab
-        r->output_filters->frec->ftype < AP_FTYPE_PROTOCOL)
f0d6ab
-        apr_table_setn(r->subprocess_env, "REQUEST_METHOD", "GET");
f0d6ab
-#else
f0d6ab
-    if (r->method_number == M_GET && r->header_only)
f0d6ab
-        apr_table_setn(r->subprocess_env, "REQUEST_METHOD", "GET");
f0d6ab
-#endif
f0d6ab
+    if (config->map_head_to_get == 2) {
f0d6ab
+        if (r->method_number == M_GET && r->header_only &&
f0d6ab
+            r->output_filters->frec->ftype < AP_FTYPE_PROTOCOL)
f0d6ab
+            apr_table_setn(r->subprocess_env, "REQUEST_METHOD", "GET");
f0d6ab
+    }
f0d6ab
+    else if (config->map_head_to_get == 1) {
f0d6ab
+        if (r->method_number == M_GET)
f0d6ab
+            apr_table_setn(r->subprocess_env, "REQUEST_METHOD", "GET");
f0d6ab
+    }
f0d6ab
 
f0d6ab
     /* Determine whether connection uses HTTPS protocol. */
f0d6ab
 
f0d6ab
@@ -15856,6 +15913,8 @@ static const command_rec wsgi_commands[] =
f0d6ab
         NULL, OR_FILEINFO, "Enable/Disable overriding of error pages."),
f0d6ab
     AP_INIT_TAKE1("WSGIChunkedRequest", wsgi_set_chunked_request,
f0d6ab
         NULL, OR_FILEINFO, "Enable/Disable support for chunked requests."),
f0d6ab
+    AP_INIT_TAKE1("WSGIMapHEADToGET", wsgi_set_map_head_to_get,
f0d6ab
+        NULL, OR_FILEINFO, "Enable/Disable mapping of HEAD to GET."),
f0d6ab
 
f0d6ab
 #ifndef WIN32
f0d6ab
 #if AP_SERVER_MAJORVERSION_NUMBER >= 2