]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: proto_htx: Add the internal function htx_fmt_res_line
authorChristopher Faulet <cfaulet@haproxy.com>
Wed, 24 Oct 2018 09:06:58 +0000 (11:06 +0200)
committerWilly Tarreau <w@1wt.eu>
Sun, 18 Nov 2018 21:08:55 +0000 (22:08 +0100)
src/proto_htx.c

index 19ab0a3709b8d0054ce5975a8e4d23610eed6e35..dec02f197e6ebffeaf432823b02935561ba52bf6 100644 (file)
@@ -40,6 +40,7 @@ static void htx_end_response(struct stream *s);
 static void htx_capture_headers(struct htx *htx, char **cap, struct cap_hdr *cap_hdr);
 static int htx_del_hdr_value(char *start, char *end, char **from, char *next);
 static size_t htx_fmt_req_line(const union h1_sl sl, char *str, size_t len);
+static size_t htx_fmt_res_line(const union h1_sl sl, char *str, size_t len);
 static void htx_debug_stline(const char *dir, struct stream *s, const union h1_sl sl);
 static void htx_debug_hdr(const char *dir, struct stream *s, const struct ist n, const struct ist v);
 
@@ -2956,6 +2957,31 @@ static size_t htx_fmt_req_line(const union h1_sl sl, char *str, size_t len)
        return dst.len;
 }
 
+/* Formats the start line of the response (without CRLF) and puts it in <str> and
+ * return the written lenght. The line can be truncated if it exceeds <len>.
+ */
+static size_t htx_fmt_res_line(const union h1_sl sl, char *str, size_t len)
+{
+       struct ist dst = ist2(str, 0);
+
+       if (istcat(&dst, sl.st.v, len) == -1)
+               goto end;
+       if (dst.len + 1 > len)
+               goto end;
+       dst.ptr[dst.len++] = ' ';
+
+       if (istcat(&dst, sl.st.c, len) == -1)
+               goto end;
+       if (dst.len + 1 > len)
+               goto end;
+       dst.ptr[dst.len++] = ' ';
+
+       istcat(&dst, sl.st.r, len);
+  end:
+       return dst.len;
+}
+
+
 /*
  * Print a debug line with a start line.
  */