relay: do forward data if the http request type was HEAD
authorFelix Fietkau <nbd@openwrt.org>
Fri, 21 Mar 2014 20:27:30 +0000 (21:27 +0100)
committerFelix Fietkau <nbd@openwrt.org>
Fri, 21 Mar 2014 20:27:33 +0000 (21:27 +0100)
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
proc.c
relay.c
uhttpd.h

diff --git a/proc.c b/proc.c
index 5be6232e79849843ef6d1422af3a29a3a683aee0..9c4b685ad1bc75c11dc7eac93255cbb0f2168d4c 100644 (file)
--- a/proc.c
+++ b/proc.c
@@ -224,6 +224,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)
diff --git a/relay.c b/relay.c
index 619534970c7c5b948031b877a50e52aa7138b103..7331a0a59d2eedbe25e984b8b60a0d62580581c9 100644 (file)
--- a/relay.c
+++ b/relay.c
@@ -142,7 +142,9 @@ static void relay_read_cb(struct ustream *s, int bytes)
        if (!buf || !len)
                return;
 
-       uh_chunk_write(cl, buf, len);
+       if (!r->skip_data)
+               uh_chunk_write(cl, buf, len);
+
        ustream_consume(s, len);
 }
 
index a620030ae20962684a360d1f2c8cd6664f451c00..cace950fc41b0d4bc26b907ff2f4c0f9f38f0004 100644 (file)
--- a/uhttpd.h
+++ b/uhttpd.h
@@ -152,6 +152,8 @@ struct relay {
 
        bool process_done;
        bool error;
+       bool skip_data;
+
        int ret;
        int header_ofs;