MINOR: htx: Add BODYLESS flags on the HTX start-line and the HTTP message
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.
diff --git a/include/types/htx.h b/include/types/htx.h
index 6d64c13..1146b9a 100644
--- a/include/types/htx.h
+++ b/include/types/htx.h
@@ -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
diff --git a/include/types/proto_http.h b/include/types/proto_http.h
index 0f341e2..9e8bbd5 100644
--- a/include/types/proto_http.h
+++ b/include/types/proto_http.h
@@ -148,6 +148,8 @@
#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 {
diff --git a/src/mux_h1.c b/src/mux_h1.c
index ef92c39..4620c64 100644
--- a/src/mux_h1.c
+++ b/src/mux_h1.c
@@ -848,6 +848,8 @@
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)) {
diff --git a/src/proto_htx.c b/src/proto_htx.c
index ce9b453..53b3323 100644
--- a/src/proto_htx.c
+++ b/src/proto_htx.c
@@ -307,6 +307,8 @@
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 @@
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;