client: store http code of last emitted response
authorJo-Philipp Wich <jow@openwrt.org>
Mon, 27 Oct 2014 10:15:35 +0000 (11:15 +0100)
committerJo-Philipp Wich <jow@openwrt.org>
Mon, 27 Oct 2014 10:16:44 +0000 (11:16 +0100)
Certain response types (notably 204 and 304) require a slightly different
handling like emitting the response body entirely, therfore record the last
code to act on it in the appropriate places.

Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
client.c
uhttpd.h

index 9b8fb07025037a30c52548f1e006bb4042a01c81..0d7029bbccfbe0233455fa97123679d38a09ca69 100644 (file)
--- a/client.c
+++ b/client.c
@@ -48,6 +48,8 @@ void uh_http_header(struct client *cl, int code, const char *summary)
        const char *enc = "Transfer-Encoding: chunked\r\n";
        const char *conn;
 
+       cl->http_code = code;
+
        if (!uh_use_chunked(cl))
                enc = "";
 
index 6ef28d922a5f2f90842149387528addd6a1e15db..9bf8cbb63250d759d024f4a641b3cbfb7caced67 100644 (file)
--- a/uhttpd.h
+++ b/uhttpd.h
@@ -243,6 +243,7 @@ struct client {
        enum client_state state;
        bool tls;
 
+       int http_code;
        struct http_request request;
        struct uh_addr srv_addr, peer_addr;