return (blk ? htx_get_blk_type(blk) : HTX_BLK_UNUSED);
}
-/* Return true if the HTX message is not empty and the HTX_BLK_FL_EOM flag is set
- * on the tail block, which means the message is complete. Otherwise, false is
- * returned.
+/* Returns true if the end of the message was reached, i.e. if the HTX message is
+ * not empty and the HTX_BLK_FL_EOM flag is set on the tail block. Otherwise,
+ * false is returned.
*/
-static inline int htx_has_eom(const struct htx *htx)
+static inline int htx_msg_ended(const struct htx *htx)
{
struct htx_blk *blk = htx_get_tail_blk(htx);
if (name.len > HTX_HDR_NAME_MAX_LEN || value.len > HTX_HDR_VALUE_MAX_LEN)
return NULL;
- eom = htx_has_eom(htx);
+ eom = htx_msg_ended(htx);
blk = __htx_add_blk(htx, HTX_BLK_HDR, name.len + value.len);
if (!blk)
return NULL;
* EOM flag can only be carried by such a block. So a message already
* ended must still be ended.
*/
- BUG_ON_HOT(eom && !htx_has_eom(htx));
+ BUG_ON_HOT(eom && !htx_msg_ended(htx));
return blk;
}
if (name.len > HTX_HDR_NAME_MAX_LEN || value.len > HTX_HDR_VALUE_MAX_LEN)
return NULL;
- eom = htx_has_eom(htx);
+ eom = htx_msg_ended(htx);
blk = __htx_add_blk(htx, HTX_BLK_TLR, name.len + value.len);
if (!blk)
return NULL;
* EOM flag can only be carried by such a block. So a message already
* ended must still be ended.
*/
- BUG_ON_HOT(eom && !htx_has_eom(htx));
+ BUG_ON_HOT(eom && !htx_msg_ended(htx));
return blk;
}
/* Returns 1 if more data are expected for the message <htx>. Otherwise it
* returns 0. Note that it is illegal to call this with htx == NULL. This
- * function relies on htx_has_eom() function. It means more data are always
- * expected on tunnel mode.
+ * function relies on htx_msg_ended(). It means tunneled data are not
+ * considered here.
*/
static inline int htx_expect_more(const struct htx *htx)
{
- return !htx_has_eom(htx);
+ return !htx_msg_ended(htx);
}
/* Set EOM flag in <htx>. This function must always be called to report the end
sl = http_get_stline(htx);
if (s->txn.http->meth != HTTP_METH_HEAD && sl &&
(msg->flags & (HTTP_MSGF_XFER_LEN|HTTP_MSGF_CNT_LEN|HTTP_MSGF_TE_CHNK)) == HTTP_MSGF_XFER_LEN &&
- htx_has_eom(htx)) {
+ htx_msg_ended(htx)) {
struct htx_blk * blk;
char *end;
size_t len = 0;
/* The decompression is finished and we must now be sure to
* restore EOM on last block (possibly by adding an EOT).
*/
- if ((st->flags & DECOMP_STATE_EOM_SEEN) && !htx_has_eom(htx)) {
+ if ((st->flags & DECOMP_STATE_EOM_SEEN) && !htx_msg_ended(htx)) {
unsigned int data = htx->data;
BUG_ON(!(st->decomp_ctx->flags & DECOMP_CTX_FL_DONE) || st->decomp_ctx->drain_len);
comp_type = NULL;
/* compress only if body size is >= than the min size */
- if (((msg->flags & HTTP_MSGF_CNT_LEN) || htx_has_eom(htx)) &&
+ if (((msg->flags & HTTP_MSGF_CNT_LEN) || htx_msg_ended(htx)) &&
((s->be->comp && (comp_minsize = s->be->comp->minsize_req)) ||
(strm_fe(s)->comp && (comp_minsize = strm_fe(s)->comp->minsize_req)))) {
/* small requests should not be compressed */
* message. In this case, it must be restored,
* adding an EOT block to support it.
*/
- if (!htx_has_eom(htx)) {
+ if (!htx_msg_ended(htx)) {
unsigned int data = htx->data;
htx_set_eom(htx);
goto fail;
/* compress only if body size is >= than the min size */
- if (((msg->flags & HTTP_MSGF_CNT_LEN) || htx_has_eom(htx)) &&
+ if (((msg->flags & HTTP_MSGF_CNT_LEN) || htx_msg_ended(htx)) &&
((s->be->comp && (comp_minsize = s->be->comp->minsize_res)) ||
(strm_fe(s)->comp && (comp_minsize = strm_fe(s)->comp->minsize_res)))) {
/* small responses should not be compressed */
/* Removed blocks may carry the EOM flag. In this case, the flag must be
* set again on the last remaining block to keep the message complete.
*/
- eom = htx_has_eom(htx);
+ eom = htx_msg_ended(htx);
/* Be sure <len> is always the amount of DATA to remove */
if (htx->data == offset+len && htx_get_tail_type(htx) == HTX_BLK_DATA) {
}
end:
- if (eom && !htx_has_eom(htx)) {
+ if (eom && !htx_msg_ended(htx)) {
unsigned int data = htx->data;
/* Restore the EOM flag. An EOT block may be added to carry it if
MAY_LJMP(check_args(L, 1, "set_eom"));
msg = MAY_LJMP(hlua_checkhttpmsg(L, 1));
htx = htxbuf(&msg->chn->buf);
- if (!htx_has_eom(htx))
+ if (!htx_msg_ended(htx))
return 0;
for (blk = htx_get_tail_blk(htx); blk; blk = htx_get_prev_blk(htx, blk)) {
*fin = 0;
htx = htx_from_buf(buf);
/* EOM is saved here, useful if 0-copy is performed with HTX buf. */
- eom = htx_has_eom(htx);
+ eom = htx_msg_ended(htx);
while (count && !htx_is_empty(htx) && qcc_stream_can_send(qcs)) {
/* Not implemented : QUIC on backend side */
* in case we previously disabled it, otherwise we might cause
* the client to delay further data.
*/
- if ((sess->listener && (sess->listener->bind_conf->options & BC_O_NOQUICKACK)) && !htx_has_eom(htx))
+ if ((sess->listener && (sess->listener->bind_conf->options & BC_O_NOQUICKACK)) && !htx_msg_ended(htx))
conn_set_quickack(cli_conn, 1);
/*************************************************************
else {
c_adv(req, htx->data - co_data(req));
if ((global.tune.options & GTUNE_USE_FAST_FWD) && (msg->flags & HTTP_MSGF_XFER_LEN) &&
- (!(msg->flags & HTTP_MSGF_CONN_UPG) || htx_has_eom(htx)))
+ (!(msg->flags & HTTP_MSGF_CONN_UPG) || htx_msg_ended(htx)))
channel_htx_forward_forever(req, htx);
}
* in HTTP_MSG_ENDING state. Then if all data was marked to be
* forwarded, set the state to HTTP_MSG_DONE.
*/
- if (!htx_has_eom(htx))
+ if (!htx_msg_ended(htx))
goto missing_data_or_waiting;
msg->msg_state = HTTP_MSG_ENDING;
* in HTTP_MSG_ENDING state. Then if all data was marked to be
* forwarded, set the state to HTTP_MSG_DONE.
*/
- if (!htx_has_eom(htx))
+ if (!htx_msg_ended(htx))
goto missing_data_or_waiting;
msg->msg_state = HTTP_MSG_ENDING;
/* Now we're are waiting for the payload. We just need to know if all
* data have been received or if the buffer is full.
*/
- if (htx_has_eom(htx) || htx_get_tail_type(htx) > HTX_BLK_DATA)
+ if (htx_msg_ended(htx) || htx_get_tail_type(htx) > HTX_BLK_DATA)
goto end; /* all data received */
if (bytes) {
goto out;
}
- if (htx_has_eom(htx)) { /* check if a body need to be added */
+ if (htx_msg_ended(htx)) { /* check if a body need to be added */
appctx->st0 = HTTPCLIENT_S_RES_STLINE;
applet_set_eoi(appctx);
goto out; /* we need to leave the IO handler once we wrote the request */
htx = htxbuf(outbuf);
/* if the request contains the EOM, we finished the request part. */
- if (htx_has_eom(htx)) {
+ if (htx_msg_ended(htx)) {
appctx->st0 = HTTPCLIENT_S_RES_STLINE;
applet_set_eoi(appctx);
goto out; /* we need to leave the IO handler once we wrote the request */
htx = htxbuf(inbuf);
if (htx_get_head_type(htx) != HTX_BLK_RES_SL)
goto error;
- res_has_eom = htx_has_eom(htx);
+ res_has_eom = htx_msg_ended(htx);
blk = DISGUISE(htx_get_head_blk(htx));
sl = htx_get_blk_ptr(htx, blk);
htx = htxbuf(inbuf);
BUG_ON(htx_is_empty(htx));
- res_has_eom = htx_has_eom(htx);
+ res_has_eom = htx_msg_ended(htx);
if (hc->options & HTTPCLIENT_O_RES_HTX) {
/* HTX mode transfers the header to the hc buffer */
struct htx *hc_htx;
applet_need_more_data(appctx);
goto out;
}
- res_has_eom = htx_has_eom(htx);
+ res_has_eom = htx_msg_ended(htx);
if (!b_alloc(&hc->res.buf, DB_MUX_TX)) {
applet_wont_consume(appctx);
if (!htx)
return 0;
- smp->data.u.sint = htx_has_eom(htx);
+ smp->data.u.sint = htx_msg_ended(htx);
smp->data.type = SMP_T_BOOL;
smp->flags = SMP_F_VOLATILE | SMP_F_MAY_CHANGE;
return 1;
*/
struct htx_blk *htx_add_blk(struct htx *htx, enum htx_blk_type type, uint32_t blksz)
{
- BUG_ON(htx_has_eom(htx));
+ BUG_ON(htx_msg_ended(htx));
return __htx_add_blk(htx, type, blksz);
}
*/
struct htx_blk *htx_add_data_atonce(struct htx *htx, struct ist data)
{
- BUG_ON(htx_has_eom(htx));
+ BUG_ON(htx_msg_ended(htx));
return __htx_add_data_atonce(htx, data);
}
uint32_t max, last_dstblk_sz;
int dst_full = 0;
- BUG_ON(htx_has_eom(dst));
+ BUG_ON(htx_msg_ended(dst));
last_dstblk = NULL;
last_dstblk_sz = 0;
int32_t len = htx_free_data_space(htx);
uint32_t flags = 0;
- BUG_ON(htx_has_eom(htx));
+ BUG_ON(htx_msg_ended(htx));
if (!len)
return (struct htx_ret){.ret = 0, .blk = NULL};
int32_t len = data.len;
uint32_t flags = 0;
- BUG_ON(htx_has_eom(htx));
+ BUG_ON(htx_msg_ended(htx));
/* Not enough space to store data */
if (len > htx_free_data_space(htx))
struct htx_blk *htx_add_last_data(struct htx *htx, struct ist data)
{
struct htx_blk *blk, *pblk;
- int eom = htx_has_eom(htx);
+ int eom = htx_msg_ended(htx);
/* Data may be added in a message already ended. In this case, the block
* is first appended, after the block carrying the EOM flag, and then
/* The EOM flag was transferred on the new DATA block, or moved with the
* blocks placed after it. So a message already ended must still be ended.
*/
- BUG_ON_HOT(eom && !htx_has_eom(htx));
+ BUG_ON_HOT(eom && !htx_msg_ended(htx));
return blk;
}
enum htx_blk_type type;
uint32_t blksz, offset = dst->data;
- BUG_ON(htx_has_eom(dst));
+ BUG_ON(htx_msg_ended(dst));
for (blk = htx_get_head_blk(src); blk; blk = htx_get_next_blk(src, blk)) {
type = htx_get_blk_type(blk);
* headers. So tunneled data must be stored in a separate buffer to
* never mix HTTP data and tunneled data.
*/
- if (htx_has_eom(htx))
+ if (htx_msg_ended(htx))
return 0;
return !!htx_free_data_space(htx);
* these data must be transferred only once the upper layer has
* consumed the HTTP part.
*/
- if (htx_has_eom(buf_htx)) {
+ if (htx_msg_ended(buf_htx)) {
htx_to_buf(buf_htx, buf);
htx_to_buf(h2s_htx, rxbuf);
goto end;
cs_htx = htx_from_buf(buf);
if (htx_is_empty_noerr(cs_htx) && htx_used_space(qcs_htx) <= count) {
/* EOM will be copied to cs_htx via b_xfer(). */
- if (htx_has_eom(qcs_htx) && !(qcs->flags & QC_SF_EOI_SUSPENDED)) {
+ if (htx_msg_ended(qcs_htx) && !(qcs->flags & QC_SF_EOI_SUSPENDED)) {
*fin = 1;
}
BUG_ON(qcs_htx->flags & HTX_FL_PARSING_ERROR);
/* EOM was copied to cs_htx if all data were copied. */
- if (htx_has_eom(cs_htx)) {
+ if (htx_msg_ended(cs_htx)) {
if (!(qcs->flags & QC_SF_EOI_SUSPENDED))
*fin = 1;
}
TRACE_ENTER(CHK_EV_TCPCHK_EXP, check);
- last_read |= (!htx_free_data_space(htx) || htx_has_eom(htx));
+ last_read |= (!htx_free_data_space(htx) || htx_msg_ended(htx));
if (htx->flags & HTX_FL_PARSING_ERROR) {
TRACE_ERROR("invalid response", CHK_EV_TCPCHK_EXP|CHK_EV_TCPCHK_ERR, check);