add support for sending HTTP/1.1 100 Continue
authorFelix Fietkau <nbd@openwrt.org>
Wed, 2 Jan 2013 18:07:17 +0000 (19:07 +0100)
committerFelix Fietkau <nbd@openwrt.org>
Wed, 2 Jan 2013 18:07:17 +0000 (19:07 +0100)
client.c
uhttpd.h

index 3dc40e8315b4d80185c6e94ce8351e1fb5edcb88..c5b82d22917c02d7fd8452173f79066c05f531ce 100644 (file)
--- a/client.c
+++ b/client.c
@@ -141,6 +141,7 @@ static int client_parse_request(struct client *cl, char *data)
        if (!type || !path || !version)
                return CLIENT_STATE_DONE;
 
+       memset(&cl->request, 0, sizeof(cl->request));
        req->url = path;
        req->method = find_idx(http_methods, ARRAY_SIZE(http_methods), type);
        if (req->method < 0)
@@ -191,6 +192,9 @@ static void client_header_complete(struct client *cl)
        if (!rfc1918_filter_check(cl))
                return;
 
+       if (cl->request.expect_cont)
+               ustream_printf(cl->us, "HTTP/1.1 100 Continue\r\n\r\n");
+
        uh_handle_request(cl);
 }
 
@@ -216,6 +220,10 @@ static void client_parse_header(struct client *cl, char *data)
                if (isupper(*name))
                        *name = tolower(*name);
 
+       if (!strcasecmp(data, "Expect") &&
+           !strcasecmp(val, "100-continue"))
+               cl->request.expect_cont = true;
+
        blobmsg_add_string(&cl->hdr, data, val);
 
        cl->state = CLIENT_STATE_HEADER;
index f47c7430fc155eef2587061303d4d56c297e7f53..4c09c129422aebee0bba242b27f768f36f3d1b88 100644 (file)
--- a/uhttpd.h
+++ b/uhttpd.h
@@ -78,6 +78,7 @@ enum http_version {
 struct http_request {
        enum http_method method;
        enum http_version version;
+       bool expect_cont;
        int redirect_status;
        const char *url;
        const struct auth_realm *realm;