MINOR: htx: Add an HTX flag to know when a message is fragmented

HTX_FL_FRAGMENTED flag is now set on an HTX message when it is
fragmented. It happens when an HTX block is removed in the middle of the
message and flagged as unused. HTX_FL_FRAGMENTED flag is removed when all
data are removed from the message or when the message is defragmented.

Note that some optimisations are still possible because the flag can be
avoided in other situations. For instance when the last header of a bodyless
message is removed.
diff --git a/include/haproxy/htx-t.h b/include/haproxy/htx-t.h
index 0070341..404a66e 100644
--- a/include/haproxy/htx-t.h
+++ b/include/haproxy/htx-t.h
@@ -142,7 +142,7 @@
 #define HTX_FL_NONE              0x00000000
 #define HTX_FL_PARSING_ERROR     0x00000001 /* Set when a parsing error occurred */
 #define HTX_FL_PROCESSING_ERROR  0x00000002 /* Set when a processing error occurred */
-/* 0x00000004 unused */
+#define HTX_FL_FRAGMENTED        0x00000004 /* Set when the HTX buffer is fragmented */
 #define HTX_FL_PROXY_RESP        0x00000008 /* Set when the response was generated by HAProxy */
 #define HTX_FL_EOM               0x00000010 /* Set when end-of-message is reached from the HTTP point of view
 					     * (at worst, on the EOM block is missing)
diff --git a/src/htx.c b/src/htx.c
index 05ba03b..8c6e368 100644
--- a/src/htx.c
+++ b/src/htx.c
@@ -79,6 +79,7 @@
 	htx->tail = new - 1;
 	htx->head_addr = htx->end_addr = 0;
 	htx->tail_addr = addr;
+	htx->flags &= ~HTX_FL_FRAGMENTED;
 	memcpy((void *)htx->blocks, (void *)tmp->blocks, htx->size);
 
 	return ((blkpos == -1) ? NULL : htx_get_blk(htx, blkpos));
@@ -339,10 +340,10 @@
 
 	/* This is the last block in use */
 	if (htx->head == htx->tail) {
-		uint32_t flags = htx->flags; /* Preserve flags */
+		uint32_t flags = (htx->flags & ~HTX_FL_FRAGMENTED); /* Preserve flags except FRAGMENTED */
 
 		htx_reset(htx);
-		htx->flags |= flags;
+		htx->flags = flags; /* restore flags */
 		return NULL;
 	}
 
@@ -368,6 +369,9 @@
 		blk = NULL;
 		goto end;
 	}
+	else
+		htx->flags |= HTX_FL_FRAGMENTED;
+
 	blk = htx_get_blk(htx, pos+1);
 
   end:
@@ -459,7 +463,7 @@
 	struct htx_ret htxret = { .blk = NULL, .ret = 0 };
 
 	if (count == htx->data) {
-		uint32_t flags = htx->flags;
+		uint32_t flags = (htx->flags & ~HTX_FL_FRAGMENTED); /* Preserve flags except FRAGMENTED */
 
 		htx_reset(htx);
 		htx->flags = flags; /* restore flags */