From 7b7d507a5b97b33ddd53755927150efd4546b19f Mon Sep 17 00:00:00 2001 From: Christopher Faulet Date: Mon, 13 May 2019 15:22:59 +0200 Subject: [PATCH] MINOR: http/htx: Use sl_pos directly to replace the start-line Since the HTX start-line is now referenced by position instead of by its payload address, it is fairly easier to replace it. No need to search the rigth block to find the start-line comparing the payloads address. It just enough to get the block at the position sl_pos. --- src/http_htx.c | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/src/http_htx.c b/src/http_htx.c index e55420c40..8099071d4 100644 --- a/src/http_htx.c +++ b/src/http_htx.c @@ -174,23 +174,15 @@ int http_add_header(struct htx *htx, const struct ist n, const struct ist v) */ int http_replace_stline(struct htx *htx, const struct ist p1, const struct ist p2, const struct ist p3) { - int32_t pos; + struct htx_blk *blk; - for (pos = htx_get_head(htx); pos != -1; pos = htx_get_next(htx, pos)) { - struct htx_blk *blk = htx_get_blk(htx, pos); - enum htx_blk_type type = htx_get_blk_type(blk); + if (htx->sl_pos == -1) + return 0; - if (htx->sl_pos == pos) { - if (!htx_replace_stline(htx, blk, p1, p2, p3)) - return 0; - return 1; - } - - if (type == HTX_BLK_EOM) - break; - } - - return 0; + blk = htx_get_blk(htx, htx->sl_pos); + if (!htx_replace_stline(htx, blk, p1, p2, p3)) + return 0; + return 1; } /* Replace the request method in the HTX message by . It returns 1