From c59ff23804dcb9726c18e16f13f8af6bd85dcb46 Mon Sep 17 00:00:00 2001 From: Christopher Faulet Date: Mon, 3 Dec 2018 13:58:44 +0100 Subject: [PATCH] MINOR: htx: Rename functions htx_*_to_str() to be H1 specific "_to_h1" suffix is now used because these function produce H1 strings. It avoids any ambiguity on the output format. --- include/proto/htx.h | 10 +++++----- src/http_fetch.c | 6 +++--- src/htx.c | 20 ++++++++++---------- src/mux_h1.c | 12 ++++++------ 4 files changed, 24 insertions(+), 24 deletions(-) diff --git a/include/proto/htx.h b/include/proto/htx.h index f15d9312b..e59bb4f48 100644 --- a/include/proto/htx.h +++ b/include/proto/htx.h @@ -56,11 +56,11 @@ struct htx_blk *htx_add_trailer(struct htx *htx, const struct ist tlr); struct htx_blk *htx_add_oob(struct htx *htx, const struct ist oob); struct htx_blk *htx_add_data_before(struct htx *htx, const struct htx_blk *ref, const struct ist data); -int htx_reqline_to_str(const struct htx_sl *sl, struct buffer *chk); -int htx_stline_to_str(const struct htx_sl *sl, struct buffer *chk); -int htx_hdr_to_str(const struct ist n, const struct ist v, struct buffer *chk); -int htx_data_to_str(const struct ist data, struct buffer *chk, int chunked); -int htx_trailer_to_str(const struct ist tlr, struct buffer *chk); +int htx_reqline_to_h1(const struct htx_sl *sl, struct buffer *chk); +int htx_stline_to_h1(const struct htx_sl *sl, struct buffer *chk); +int htx_hdr_to_h1(const struct ist n, const struct ist v, struct buffer *chk); +int htx_data_to_h1(const struct ist data, struct buffer *chk, int chunked); +int htx_trailer_to_h1(const struct ist tlr, struct buffer *chk); /* Functions and macros to get parts of the start-line or legnth of these * parts diff --git a/src/http_fetch.c b/src/http_fetch.c index 884a32049..81f6669c9 100644 --- a/src/http_fetch.c +++ b/src/http_fetch.c @@ -628,7 +628,7 @@ static int smp_fetch_hdrs(const struct arg *args, struct sample *smp, const char struct ist n = htx_get_blk_name(htx, blk); struct ist v = htx_get_blk_value(htx, blk); - if (!htx_hdr_to_str(n, v, temp)) + if (!htx_hdr_to_h1(n, v, temp)) return 0; } else if (type == HTX_BLK_EOH) { @@ -856,7 +856,7 @@ static int smp_fetch_body(const struct arg *args, struct sample *smp, const char if (type == HTX_BLK_EOM || type == HTX_BLK_EOD) break; if (type == HTX_BLK_DATA) { - if (!htx_data_to_str(htx_get_blk_value(htx, blk), temp, 0)) + if (!htx_data_to_h1(htx_get_blk_value(htx, blk), temp, 0)) return 0; } } @@ -2531,7 +2531,7 @@ static int smp_fetch_body_param(const struct arg *args, struct sample *smp, cons if (type == HTX_BLK_EOM || type == HTX_BLK_EOD) break; if (type == HTX_BLK_DATA) { - if (!htx_data_to_str(htx_get_blk_value(htx, blk), temp, 0)) + if (!htx_data_to_h1(htx_get_blk_value(htx, blk), temp, 0)) return 0; } } diff --git a/src/htx.c b/src/htx.c index a57c57d15..d5285eb6d 100644 --- a/src/htx.c +++ b/src/htx.c @@ -801,11 +801,11 @@ struct htx_blk *htx_add_data_before(struct htx *htx, const struct htx_blk *ref, return blk; } -/* Appends the string representation of the request line block to the +/* Appends the H1 representation of the request line block to the * chunk . It returns 1 if data are successfully appended, otherwise it * returns 0. */ -int htx_reqline_to_str(const struct htx_sl *sl, struct buffer *chk) +int htx_reqline_to_h1(const struct htx_sl *sl, struct buffer *chk) { if (HTX_SL_LEN(sl) + 4 > b_room(chk)) return 0; @@ -820,11 +820,11 @@ int htx_reqline_to_str(const struct htx_sl *sl, struct buffer *chk) return 1; } -/* Appends the string representation of the status line block to the chunk +/* Appends the H1 representation of the status line block to the chunk * . It returns 1 if data are successfully appended, otherwise it * returns 0. */ -int htx_stline_to_str(const struct htx_sl *sl, struct buffer *chk) +int htx_stline_to_h1(const struct htx_sl *sl, struct buffer *chk) { if (HTX_SL_LEN(sl) + 4 > b_size(chk)) return 0; @@ -839,11 +839,11 @@ int htx_stline_to_str(const struct htx_sl *sl, struct buffer *chk) return 1; } -/* Appends the string representation of the header block to the chunk +/* Appends the H1 representation of the header block to the chunk * . It returns 1 if data are successfully appended, otherwise it returns * 0. */ -int htx_hdr_to_str(const struct ist n, const struct ist v, struct buffer *chk) +int htx_hdr_to_h1(const struct ist n, const struct ist v, struct buffer *chk) { if (n.len + v.len + 4 > b_room(chk)) return 0; @@ -856,11 +856,11 @@ int htx_hdr_to_str(const struct ist n, const struct ist v, struct buffer *chk) return 1; } -/* Appends the string representation of the data block to the chunk +/* Appends the H1 representation of the data block to the chunk * . If is non-zero, it emits HTTP/1 chunk-encoded data. It * returns 1 if data are successfully appended, otherwise it returns 0. */ -int htx_data_to_str(const struct ist data, struct buffer *chk, int chunked) +int htx_data_to_h1(const struct ist data, struct buffer *chk, int chunked) { if (chunked) { uint32_t chksz; @@ -890,11 +890,11 @@ int htx_data_to_str(const struct ist data, struct buffer *chk, int chunked) return 1; } -/* Appends the string representation of the trailer block to the chunk +/* Appends the h1 representation of the trailer block to the chunk * . It returns 1 if data are successfully appended, otherwise it returns * 0. */ -int htx_trailer_to_str(const struct ist tlr, struct buffer *chk) +int htx_trailer_to_h1(const struct ist tlr, struct buffer *chk) { /* FIXME: be sure the CRLF is here or remove it when inserted */ if (!chunk_memcat(chk, tlr.ptr, tlr.len)) diff --git a/src/mux_h1.c b/src/mux_h1.c index ae0b54b21..b01e5d768 100644 --- a/src/mux_h1.c +++ b/src/mux_h1.c @@ -1316,7 +1316,7 @@ static size_t h1_process_output(struct h1c *h1c, struct buffer *buf, size_t coun sl = htx_get_blk_ptr(chn_htx, blk); h1s->meth = sl->info.req.meth; h1_parse_req_vsn(h1m, sl); - if (!htx_reqline_to_str(sl, tmp)) + if (!htx_reqline_to_h1(sl, tmp)) goto copy; h1m->flags |= H1_MF_XFER_LEN; h1m->state = H1_MSG_HDR_FIRST; @@ -1328,7 +1328,7 @@ static size_t h1_process_output(struct h1c *h1c, struct buffer *buf, size_t coun sl = htx_get_blk_ptr(chn_htx, blk); h1s->status = sl->info.res.status; h1_parse_res_vsn(h1m, sl); - if (!htx_stline_to_str(sl, tmp)) + if (!htx_stline_to_h1(sl, tmp)) goto copy; if (sl->flags & HTX_SL_F_XFER_LEN) h1m->flags |= H1_MF_XFER_LEN; @@ -1353,7 +1353,7 @@ static size_t h1_process_output(struct h1c *h1c, struct buffer *buf, size_t coun goto skip_hdr; } - if (!htx_hdr_to_str(n, v, tmp)) + if (!htx_hdr_to_h1(n, v, tmp)) goto copy; skip_hdr: h1m->state = H1_MSG_HDR_L2_LWS; @@ -1374,7 +1374,7 @@ static size_t h1_process_output(struct h1c *h1c, struct buffer *buf, size_t coun h1_process_conn_mode(h1s, h1m, NULL, &v); process_conn_mode = 0; if (v.len) { - if (!htx_hdr_to_str(n, v, tmp)) + if (!htx_hdr_to_h1(n, v, tmp)) goto copy; } } @@ -1387,7 +1387,7 @@ static size_t h1_process_output(struct h1c *h1c, struct buffer *buf, size_t coun case HTX_BLK_DATA: v = htx_get_blk_value(chn_htx, blk); - if (!htx_data_to_str(v, tmp, !!(h1m->flags & H1_MF_CHNK))) + if (!htx_data_to_h1(v, tmp, !!(h1m->flags & H1_MF_CHNK))) goto copy; break; @@ -1405,7 +1405,7 @@ static size_t h1_process_output(struct h1c *h1c, struct buffer *buf, size_t coun h1s->flags |= H1S_F_HAVE_EOD; } v = htx_get_blk_value(chn_htx, blk); - if (!htx_trailer_to_str(v, tmp)) + if (!htx_trailer_to_h1(v, tmp)) goto copy; h1s->flags |= H1S_F_HAVE_TLR; break;