]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: htx: Add a flag on HTX to known when a response was generated by HAProxy
authorChristopher Faulet <cfaulet@haproxy.com>
Wed, 16 Oct 2019 07:38:27 +0000 (09:38 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Wed, 16 Oct 2019 08:03:12 +0000 (10:03 +0200)
The flag HTX_FL_PROXY_RESP is now set on responses generated by HAProxy,
excluding responses returned by applets and services. It is an informative flag
set by the applicative layer.

include/common/htx.h
src/http_ana.c

index 5527a473fcab5d33de75d7da498a9bc03b17aa11..b22da99b4f8e7b2685c8bb0a06fb9888b0caf986 100644 (file)
 #define HTX_FL_PARSING_ERROR     0x00000001 /* Set when a parsing error occurred */
 #define HTX_FL_PROCESSING_ERROR  0x00000002 /* Set when a processing error occurred */
 #define HTX_FL_UPGRADE           0x00000004 /* Set when an upgrade is in progress */
+#define HTX_FL_PROXY_RESP        0x00000008 /* Set when the response was generated by HAProxy */
 
 
 /* HTX block's type (max 15). */
index f1546fdd720e7766e95777ac0a0f292ef84cc71e..c16d61f9bd8957a535c0253457132f18a134c811 100644 (file)
@@ -2527,6 +2527,7 @@ int http_apply_redirect_rule(struct redirect_rule *rule, struct stream *s, struc
        /* let's log the request time */
        s->logs.tv_request = now;
 
+       htx->flags |= HTX_FL_PROXY_RESP;
        data = htx->data - co_data(res);
        c_adv(res, data);
        res->total += data;
@@ -4879,6 +4880,7 @@ void http_server_error(struct stream *s, struct stream_interface *si, int err,
                chn->buf.data = msg->data;
                memcpy(chn->buf.area, msg->area, msg->data);
                htx = htx_from_buf(&chn->buf);
+               htx->flags |= HTX_FL_PROXY_RESP;
                c_adv(chn, htx->data);
                chn->total += htx->data;
        }
@@ -4909,6 +4911,7 @@ void http_reply_and_close(struct stream *s, short status, struct buffer *msg)
                chn->buf.data = msg->data;
                memcpy(chn->buf.area, msg->area, msg->data);
                htx = htx_from_buf(&chn->buf);
+               htx->flags |= HTX_FL_PROXY_RESP;
                c_adv(chn, htx->data);
                chn->total += htx->data;
        }
@@ -5103,6 +5106,7 @@ static int http_reply_40x_unauthorized(struct stream *s, const char *auth_realm)
        if (!htx_add_endof(htx, HTX_BLK_EOM))
                goto fail;
 
+       htx->flags |= HTX_FL_PROXY_RESP;
        data = htx->data - co_data(res);
        c_adv(res, data);
        res->total += data;