]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: applet: Add HTX versions for applet_input_data() and applet_output_room()
authorChristopher Faulet <cfaulet@haproxy.com>
Thu, 17 Jul 2025 13:45:36 +0000 (15:45 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Thu, 24 Jul 2025 07:16:56 +0000 (09:16 +0200)
It will be useful for HTX applets because availale data in the input buffer and
available space in the output buffer are computed from the HTX message and not
the buffer itself. So now, applet_htx_input_data() and applet_htx_output_room()
functions can be used.

include/haproxy/applet.h

index 6eec621b4f38572a206ffed0d6327f86861d6a14..2b1a5af7f5fe9c38d929fd6e5b237aa20ad2cc65 100644 (file)
@@ -315,6 +315,15 @@ static inline size_t applet_input_data(const struct appctx *appctx)
                return co_data(sc_oc(appctx_sc(appctx)));
 }
 
+/* Returns the amount of HTX data in the input buffer (see applet_get_inbuf) */
+static inline size_t applet_htx_input_data(const struct appctx *appctx)
+{
+       if (appctx->flags & APPCTX_FL_INOUT_BUFS)
+               return htx_used_space(htxbuf(&appctx->inbuf));
+       else
+               return co_data(sc_oc(appctx_sc(appctx)));
+}
+
 /* Skips <len> bytes from the input buffer (see applet_get_inbuf).
  *
  * This is useful when data have been read directly from the buffer. It is
@@ -354,6 +363,16 @@ static inline size_t applet_output_room(const struct appctx *appctx)
                return channel_recv_max(sc_ic(appctx_sc(appctx)));
 }
 
+/* Returns the amout of space available at the HTX output buffer (see applet_get_outbuf).
+ */
+static inline size_t applet_htx_output_room(const struct appctx *appctx)
+{
+       if (appctx->flags & APPCTX_FL_INOUT_BUFS)
+               return htx_free_data_space(htxbuf(&appctx->outbuf));
+       else
+               return channel_recv_max(sc_ic(appctx_sc(appctx)));
+}
+
 /*Indicates that the applet have more data to deliver and it needs more room in
  * the output buffer to do so (see applet_get_outbuf).
  *