]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: htx: Add BODYLESS flags on the HTX start-line and the HTTP message
authorChristopher Faulet <cfaulet@haproxy.com>
Tue, 27 Nov 2018 15:51:09 +0000 (16:51 +0100)
committerWilly Tarreau <w@1wt.eu>
Sat, 1 Dec 2018 16:37:27 +0000 (17:37 +0100)
the flags HTX_SL_F_BODYLESS and HTTP_MSGF_BODYLESS have been added. These flags
are set when the corresponding HTTP message has no body at all.

include/types/htx.h
include/types/proto_http.h
src/mux_h1.c
src/proto_htx.c

index 6d64c132e0e23996f16189a649a4977f76458b5a..1146b9af46e337baf7cd68bc5d3b3570420267e3 100644 (file)
@@ -81,6 +81,7 @@
 #define HTX_SL_F_CLEN          0x00000008 /* The content-length header was found in message */
 #define HTX_SL_F_CHNK          0x00000010 /* The message payload is chunked */
 #define HTX_SL_F_VER_11        0x00000020 /* The message indicates version 1.1 or above */
+#define HTX_SL_F_BODYLESS      0x00000040 /* The message has no body (content-length = 0) */
 
 /* HTX flags */
 #define HTX_FL_NONE              0x00000000
index 0f341e2ee45d797841187a178000553a6e5ac05d..9e8bbd5d183050947bc85f1b1a3198a2a810c747 100644 (file)
 #define HTTP_MSGF_WAIT_CONN   0x00000010  /* Wait for connect() to be confirmed before processing body */
 #define HTTP_MSGF_COMPRESSING 0x00000020  /* data compression is in progress */
 
+#define HTTP_MSGF_BODYLESS    0x00000040  /* The message has no body (content-length = 0) */
+
 
 /* Redirect flags */
 enum {
index ef92c394be2ccfbd6c4c9d3b24cc4bfa37efd67a..4620c640e31149fe1f3028831b8e56c5ad4a2214 100644 (file)
@@ -848,6 +848,8 @@ static size_t h1_process_headers(struct h1s *h1s, struct h1m *h1m, struct htx *h
                        flags |= HTX_SL_F_CHNK;
                else if (h1m->flags & H1_MF_CLEN)
                        flags |= HTX_SL_F_CLEN;
+               if (h1m->state == H1_MSG_DONE)
+                       flags |= HTX_SL_F_BODYLESS;
        }
 
        if (!(h1m->flags & H1_MF_RESP)) {
index ce9b45336d2aa5053903bfb6edf17f42c4bf5943..53b33232261e4ca24ed0bf63f77390ca274d3b2e 100644 (file)
@@ -307,6 +307,8 @@ int htx_wait_for_request(struct stream *s, struct channel *req, int an_bit)
                 msg->flags |= HTTP_MSGF_VER_11;
        msg->flags |= HTTP_MSGF_XFER_LEN;
        msg->flags |= ((sl->flags & HTX_SL_F_CHNK) ? HTTP_MSGF_TE_CHNK : HTTP_MSGF_CNT_LEN);
+       if (sl->flags & HTX_SL_F_BODYLESS)
+               msg->flags |= HTTP_MSGF_BODYLESS;
 
        /* we can make use of server redirect on GET and HEAD */
        if (txn->meth == HTTP_METH_GET || txn->meth == HTTP_METH_HEAD)
@@ -1610,6 +1612,8 @@ int htx_wait_for_response(struct stream *s, struct channel *rep, int an_bit)
        if (sl->flags & HTX_SL_F_XFER_LEN) {
                msg->flags |= HTTP_MSGF_XFER_LEN;
                msg->flags |= ((sl->flags & HTX_SL_F_CHNK) ? HTTP_MSGF_TE_CHNK : HTTP_MSGF_CNT_LEN);
+               if (sl->flags & HTX_SL_F_BODYLESS)
+                       msg->flags |= HTTP_MSGF_BODYLESS;
        }
 
        n = txn->status / 100;