cgi: allow conf.cgi_docroot_path to be NULL
[project/uhttpd.git] / proc.c
diff --git a/proc.c b/proc.c
index 5be6232..4819e08 100644 (file)
--- a/proc.c
+++ b/proc.c
@@ -33,7 +33,8 @@
        __header(referer, referer) \
        __header(user_agent, user-agent) \
        __header(content_type, content-type) \
-       __header(content_length, content-length)
+       __header(content_length, content-length) \
+       __header(x_http_method_override, x-http-method-override)
 
 #undef __header
 #define __header __enum_header
@@ -62,6 +63,7 @@ static const struct {
        { "HTTP_HOST", HDR_host },
        { "HTTP_REFERER", HDR_referer },
        { "HTTP_USER_AGENT", HDR_user_agent },
+       { "HTTP_X_HTTP_METHOD_OVERRIDE", HDR_x_http_method_override },
        { "CONTENT_TYPE", HDR_content_type },
        { "CONTENT_LENGTH", HDR_content_length },
 };
@@ -81,6 +83,7 @@ enum extra_vars {
        VAR_METHOD,
        VAR_PATH_INFO,
        VAR_USER,
+       VAR_HTTPS,
        VAR_REDIRECT,
        VAR_SERVER_NAME,
        VAR_SERVER_ADDR,
@@ -108,6 +111,7 @@ static struct env_var extra_vars[] = {
        [VAR_METHOD] = { "REQUEST_METHOD" },
        [VAR_PATH_INFO] = { "PATH_INFO" },
        [VAR_USER] = { "REMOTE_USER" },
+       [VAR_HTTPS] = { "HTTPS" },
        [VAR_REDIRECT] = { "REDIRECT_STATUS", redirect_status },
        [VAR_SERVER_NAME] = { "SERVER_NAME", local_addr },
        [VAR_SERVER_ADDR] = { "SERVER_ADDR", local_addr },
@@ -143,6 +147,7 @@ struct env_var *uh_get_process_vars(struct client *cl, struct path_info *pi)
        extra_vars[VAR_METHOD].value = http_methods[req->method];
        extra_vars[VAR_PATH_INFO].value = pi->info;
        extra_vars[VAR_USER].value = req->realm ? req->realm->user : NULL;
+       extra_vars[VAR_HTTPS].value = cl->tls ? "on" : NULL;
 
        snprintf(redirect_status, sizeof(redirect_status),
                 "%d", req->redirect_status);
@@ -224,6 +229,9 @@ static void proc_handle_header_end(struct relay *r)
                ustream_printf(cl->us, "%s: %s\r\n", blobmsg_name(cur), blobmsg_data(cur));
 
        ustream_printf(cl->us, "\r\n");
+
+       if (cl->request.method == UH_HTTP_MSG_HEAD)
+               r->skip_data = true;
 }
 
 static void proc_write_close(struct client *cl)