#define HTX_FL_PROCESSING_ERROR 0x00000002 /* Set when a processing error occurred */
#define HTX_FL_UPGRADE 0x00000004 /* Set when an upgrade is in progress */
#define HTX_FL_PROXY_RESP 0x00000008 /* Set when the response was generated by HAProxy */
-
+#define HTX_FL_EOI 0x00000010 /* Set when end-of-input is reached from the HTX point of view
+ * (at worst, on the EOM block is missing)
+ */
/* HTX block's type (max 15). */
enum htx_blk_type {
return (htx->head != -1);
}
+/* Returns 1 if no more data are expected for the message <htx>. Otherwise it
+ * returns 0. Note that it is illegal to call this with htx == NULL. Note also
+ * the EOM block may be missing.
+ */
+static inline int htx_expect_more(const struct htx *htx)
+{
+ return !(htx->flags & HTX_FL_EOI);
+}
+
/* Copy an HTX message stored in the buffer <msg> to <htx>. We take care to
* not overwrite existing data. All the message is copied or nothing. It returns
* 1 on success and 0 on error.
}
if (appctx->st0 == HTX_CACHE_EOM) {
+ res_htx->flags |= HTX_FL_EOI; /* no more data are expected. Only EOM remains to add now */
if (!htx_add_endof(res_htx, HTX_BLK_EOM)) {
si_rx_room_blk(si);
goto out;
dsthtx->flags |= HTX_FL_PARSING_ERROR;
return 0;
}
+
+ dsthtx->flags |= HTX_FL_EOI; /* no more data are expected. Only EOM remains to add now */
if (max < sizeof(struct htx_blk) + 1 || !htx_add_endof(dsthtx, HTX_BLK_EOM))
return 0;
}
/* Finalize headers. */
+ htx->flags |= HTX_FL_EOI; /* no more data are expected. Only EOM remains to add now */
if (!htx_add_endof(htx, HTX_BLK_EOH)) {
hlua_pusherror(L, "Lua applet http '%s': Failed create the response.\n",
appctx->appctx->rule->arg.hlua_rule->fcn.name);
channel_auto_close(res);
channel_shutr_now(res);
res->flags |= CF_EOI; /* The response is terminated, add EOI */
+ htxbuf(&res->buf)->flags |= HTX_FL_EOI; /* no more data are expected */
}
else {
/* Send ASAP informational messages. Rely on CF_EOI for final
if ((h2c->dff & H2_F_HEADERS_END_STREAM)) {
/* Mark the end of message using EOM */
+ htx->flags |= HTX_FL_EOI; /* no more data are expected. Only EOM remains to add now */
if (!htx_add_endof(htx, HTX_BLK_EOM)) {
TRACE_STATE("failed to append HTX EOM block into rxbuf", H2_EV_RX_FRAME|H2_EV_RX_HDR|H2_EV_H2S_ERR, h2c->conn);
goto fail;
*/
if (h2c->dff & H2_F_DATA_END_STREAM) {
+ htx->flags |= HTX_FL_EOI; /* no more data are expected. Only EOM remains to add now */
if (!htx_add_endof(htx, HTX_BLK_EOM)) {
TRACE_STATE("h2s rxbuf is full, failed to add EOM", H2_EV_RX_FRAME|H2_EV_RX_DATA|H2_EV_H2S_BLK, h2c->conn, h2s);
h2c->flags |= H2_CF_DEM_SFULL;
if (htx_is_empty(buf_htx))
cs->flags |= CS_FL_EOI;
}
+ else if (htx_is_empty(h2s_htx))
+ buf_htx->flags |= (h2s_htx->flags & HTX_FL_EOI);
buf_htx->extra = (h2s_htx->extra ? (h2s_htx->data + h2s_htx->extra) : 0);
htx_to_buf(buf_htx, buf);
if (appctx->st0 == STAT_HTTP_DONE) {
/* Don't add TLR because mux-h1 will take care of it */
+ res_htx->flags |= HTX_FL_EOI; /* no more data are expected. Only EOM remains to add now */
if (!htx_add_endof(res_htx, HTX_BLK_EOM)) {
si_rx_room_blk(si);
goto out;
if (!htx_add_endof(htx, HTX_BLK_EOH) ||
- (istlen(body) && !htx_add_data_atonce(htx, body)) ||
- !htx_add_endof(htx, HTX_BLK_EOM))
+ (istlen(body) && !htx_add_data_atonce(htx, body)))
+ goto error_htx;
+
+ htx->flags |= HTX_FL_EOI; /* no more data are expected. Only EOM remains to add now */
+ if (!htx_add_endof(htx, HTX_BLK_EOM))
goto error_htx;
htx_to_buf(htx, &check->bo);