haproxy/src
Christopher Faulet 700d9e88ad MEDIUM: lua: Add ability for actions to intercept HTTP messages
It is now possible to intercept HTTP messages from a lua action and reply to
clients. To do so, a reply object must be provided to the function
txn:done(). It may contain a status code with a reason, a header list and a
body. By default, if an empty reply object is used, an empty 200 response is
returned. If no reply is passed when txn:done() is called, the previous
behaviour is respected, the transaction is terminated and nothing is returned to
the client. The same is done for TCP streams. When txn:done() is called, the
action is terminated with the code ACT_RET_DONE on success and ACT_RET_ERR on
error, interrupting the message analysis.

The reply object may be created for the lua, by hand. Or txn:reply() may be
called. If so, this object provides some methods to fill it:

  * Reply:set_status(<status> [  <reason>]) : Set the status and optionally the
   reason. If no reason is provided, the default one corresponding to the status
   code is used.

  * Reply:add_header(<name>, <value>) : Add a header. For a given name, the
    values are stored in an ordered list.

  * Reply:del_header(<name>) : Removes all occurrences of a header name.

  * Reply:set_body(<body>) : Set the reply body.

Here are some examples, all doing the same:

    -- ex. 1
    txn:done{
        status  = 400,
        reason  = "Bad request",
        headers = {
            ["content-type"]  = { "text/html" },
            ["cache-control"] = { "no-cache", "no-store" },
        },
        body = "<html><body><h1>invalid request<h1></body></html>"
    }

    -- ex. 2
    local reply = txn:reply{
        status  = 400,
        reason  = "Bad request",
        headers = {
            ["content-type"]  = { "text/html" },
            ["cache-control"] = { "no-cache", "no-store" }
        },
        body = "<html><body><h1>invalid request<h1></body></html>"
    }
    txn:done(reply)

    -- ex. 3
    local reply = txn:reply()
    reply:set_status(400, "Bad request")
    reply:add_header("content-length", "text/html")
    reply:add_header("cache-control", "no-cache")
    reply:add_header("cache-control", "no-store")
    reply:set_body("<html><body><h1>invalid request<h1></body></html>")
    txn:done(reply)
2020-02-06 15:13:04 +01:00
..
51d.c BUG/MINOR: 51d: Fix bug when HTX is enabled 2020-01-20 14:01:52 +01:00
acl.c BUG/MINOR: acl: Fix memory leaks when an ACL expression is parsed 2019-09-13 10:08:44 +02:00
action.c MINOR: tcp-rules: Make tcp-request capture a custom action 2020-01-20 15:18:45 +01:00
activity.c CLEANUP: cli: replace all occurrences of manual handling of return messages 2019-08-09 11:26:10 +02:00
applet.c BUG/MEDIUM: applet: always check a fast running applet's activity before killing 2019-10-11 16:05:57 +02:00
arg.c MEDIUM: tools: improve time format error detection 2019-06-07 19:32:02 +02:00
auth.c BUILD/MINOR: auth: enabling for osx 2019-09-08 12:20:13 +02:00
backend.c BUG/MEDIUM: connections: Don't forget to unlock when killing a connection. 2020-01-31 17:25:37 +01:00
base64.c BUG/MINOR: base64: dec func ignores padding for output size checking 2019-01-14 19:32:15 +01:00
buffer.c MEDIUM: memory: use pool_destroy_all() to destroy all pools on deinit() 2018-11-26 19:50:32 +01:00
cache.c BUG/MINOR: cache: Fix leak of cache name in error path 2020-01-18 06:45:54 +01:00
calltrace.c REORG: trace: rename trace.c to calltrace.c and mention it's not thread-safe 2019-08-22 20:21:00 +02:00
cfgparse-global.c MEDIUM: init: set NO_NEW_PRIVS by default when supported 2019-12-06 17:20:26 +01:00
cfgparse-listen.c MEDIUM: http: Add a ruleset evaluated on all responses just before forwarding 2020-02-06 14:55:34 +01:00
cfgparse.c MEDIUM: http: Add a ruleset evaluated on all responses just before forwarding 2020-02-06 14:55:34 +01:00
channel.c BUG/MINOR: channel: inject output data at the end of output 2020-01-07 10:51:15 +01:00
checks.c BUG/MINOR: tcpchecks: fix the connect() flags regarding delayed ack 2020-01-24 17:52:37 +01:00
chunk.c Revert "MINOR: chunks: Make sure trash_size is only set once." 2019-06-07 15:37:47 +02:00
cli.c CLEANUP: cli: deduplicate the code in _getsocks 2020-01-16 16:26:41 +01:00
compression.c MINOR: time: move the cpu, mono, and idle time to thread_info 2019-05-20 21:14:14 +02:00
connection.c BUG/MINOR: connection: fix ip6 dst_port copy in make_proxy_line_v2 2020-01-28 13:02:58 +01:00
da.c REORG: proto_htx: Move HTX analyzers & co to http_ana.{c,h} files 2019-07-19 09:24:12 +02:00
debug.c MEDIUM: tasks: implement 3 different tasklet classes with their own queues 2020-01-30 18:59:33 +01:00
dict.c BUG/MINOR: dict: race condition fix when inserting dictionary entries. 2019-06-11 09:54:12 +02:00
dns.c MINOR: dns: Add function to release memory allocated for a do-resolve rule 2020-02-06 14:55:34 +01:00
ev_epoll.c OPTIM: epoll: always poll for recv if neither active nor ready 2019-12-27 16:38:47 +01:00
ev_evports.c MINOR: pollers: add a new flag to indicate pollers reporting ERR & HUP 2019-12-27 14:04:33 +01:00
ev_kqueue.c MINOR: pollers: add a new flag to indicate pollers reporting ERR & HUP 2019-12-27 14:04:33 +01:00
ev_poll.c MINOR: pollers: add a new flag to indicate pollers reporting ERR & HUP 2019-12-27 14:04:33 +01:00
ev_select.c MEDIUM: fd: do not use the FD_POLL_* flags in the pollers anymore 2019-09-06 19:09:56 +02:00
fcgi-app.c MINOR: counters: Review conditions to increment counters from analysers 2020-01-20 15:18:45 +01:00
fcgi.c MINOR: fcgi: Add code related to FCGI protocol 2019-09-17 10:18:54 +02:00
fd.c BUG/MEDIUM: fd/threads: fix a concurrency issue between add and rm on the same fd 2019-12-20 08:09:28 +01:00
filters.c MEDIUM: filters: Adapt filters API to allow again TCP filtering on HTX streams 2019-11-15 13:43:08 +01:00
flt_http_comp.c CLEANUP: compression: remove unused deinit_comp_ctx section 2020-01-15 10:58:17 +01:00
flt_spoe.c MINOR: actions: Rename the act_flag enum into act_opt 2020-01-20 15:18:45 +01:00
flt_trace.c MEDIUM: filters: Adapt filters API to allow again TCP filtering on HTX streams 2019-11-15 13:43:08 +01:00
freq_ctr.c BUG/MAJOR: threads/freq_ctr: use a memory barrier to detect changes 2017-10-31 18:01:18 +01:00
frontend.c MINOR: frontend: switch from conn->addr.{from,to} to conn->{src,dst} 2019-07-19 13:50:09 +02:00
h1.c BUG/MINOR: h1: Report the right error position when a header value is invalid 2020-01-06 13:58:21 +01:00
h1_htx.c MEDIUM: h1-htx: Add HTX EOM block when the message is in H1_MSG_DONE state 2019-12-11 16:46:16 +01:00
h2.c BUG/MAJOR: h2: make header field name filtering stronger 2019-11-25 11:11:32 +01:00
haproxy.c MEDIUM: http: Add a ruleset evaluated on all responses just before forwarding 2020-02-06 14:55:34 +01:00
hash.c BUG/MAJOR: hashes: fix the signedness of the hash inputs 2020-01-16 08:23:42 +01:00
hathreads.c BUILD/MEDIUM: threads: rename thread_info struct to ha_thread_info 2019-10-17 07:15:17 +02:00
hlua.c MEDIUM: lua: Add ability for actions to intercept HTTP messages 2020-02-06 15:13:04 +01:00
hlua_fcn.c MEDIUM: cli: Allow multiple filter entries for "show table" 2020-01-22 14:33:17 +01:00
hpack-dec.c CLEANUP: hpack: remove a redundant test in the decoder 2020-02-05 15:39:08 +01:00
hpack-enc.c BUILD: use inttypes.h instead of stdint.h 2019-04-01 07:44:56 +02:00
hpack-huff.c BUILD: use inttypes.h instead of stdint.h 2019-04-01 07:44:56 +02:00
hpack-tbl.c BUILD: use inttypes.h instead of stdint.h 2019-04-01 07:44:56 +02:00
http.c MINOR: http: Add 404 to http-request deny 2020-01-08 16:15:23 +01:00
http_acl.c MEDIUM: init: convert all trivial registration calls to initcalls 2018-11-26 19:50:32 +01:00
http_act.c MEDIUM: http-rules: Support extra headers for HTTP return actions 2020-02-06 15:13:03 +01:00
http_ana.c BUG/MINOR: http-ana: Increment failed_resp counters on invalid response 2020-02-06 15:13:03 +01:00
http_conv.c MINOR: sample: add us/ms support to date/http_date 2019-10-31 08:47:31 +01:00
http_fetch.c CLEANUP: h1-htx: Move htx-to-h1 formatting functions from htx.c to h1_htx.c 2019-10-14 22:28:50 +02:00
http_htx.c MEDIUM: http: Add a ruleset evaluated on all responses just before forwarding 2020-02-06 14:55:34 +01:00
http_rules.c MEDIUM: http: Add a ruleset evaluated on all responses just before forwarding 2020-02-06 14:55:34 +01:00
htx.c MINOR: htx: Add a function to append an HTX message to another one 2020-02-06 14:54:47 +01:00
i386-linux-vsys.c MEDIUM: listener: add support for linux's accept4() syscall 2012-10-08 20:11:03 +02:00
lb_chash.c BUG/MEDIUM: lb-chash: Ensure the tree integrity when server weight is increased 2019-08-01 11:35:29 +02:00
lb_fas.c BUG/MEDIUM: lb_fas: Don't test the server's lb_tree from outside the lock 2019-07-05 14:26:15 +02:00
lb_fwlc.c BUG/MINOR: lb/leastconn: ignore the server weights for empty servers 2019-09-06 17:13:44 +02:00
lb_fwrr.c BUG/MAJOR: lb/threads: make sure the avoided server is not full on second pass 2019-05-27 10:29:59 +02:00
lb_map.c MEDIUM: lb/threads: Use the new _HA_ATOMIC_* macros. 2019-03-11 17:02:38 +01:00
listener.c BUG/MAJOR: listener: do not schedule a task-less proxy 2020-01-08 19:39:09 +01:00
log.c BUG/MINOR: log: fix minor resource leaks on logformat error path 2019-12-11 12:05:39 +01:00
lru.c MINOR: lru: new function to delete <nb> least recently used keys 2016-01-11 07:31:35 +01:00
mailers.c MEDIUM: Add parsing of mailers section 2015-02-03 00:24:16 +01:00
map.c CLEANUP: cli: replace all occurrences of manual handling of return messages 2019-08-09 11:26:10 +02:00
memory.c BUG/MEDIUM: memory: Add a rwlock before freeing memory. 2020-02-01 18:08:34 +01:00
mux_fcgi.c MEDIUM: connection: use CO_FL_WAIT_XPRT more consistently than L4/L6/HANDSHAKE 2020-01-23 16:34:26 +01:00
mux_h1.c MEDIUM: connection: use CO_FL_WAIT_XPRT more consistently than L4/L6/HANDSHAKE 2020-01-23 16:34:26 +01:00
mux_h2.c BUG/MEDIUM: mux-h2: make sure we don't emit TE headers with anything but "trailers" 2020-01-24 09:07:53 +01:00
mux_pt.c MINOR: connection: remove checks for CO_FL_HANDSHAKE before I/O 2020-01-23 17:30:42 +01:00
mworker-prog.c MEDIUM: mworker-prog: Add user/group options to program section 2019-07-15 16:43:16 +02:00
mworker.c BUG/MINOR: mworker: properly pass SIGTTOU/SIGTTIN to workers 2019-12-11 14:26:53 +01:00
namespace.c BUG/MEDIUM: namespace: close open namespaces during soft shutdown 2019-09-25 23:33:52 +02:00
pattern.c BUILD: pattern: include errno.h 2020-01-17 18:30:06 +01:00
payload.c REORG: proto_htx: Move HTX analyzers & co to http_ana.{c,h} files 2019-07-19 09:24:12 +02:00
peers.c CLEANUP: peers: Remove unused static function free_dcache_tx 2020-02-05 23:40:17 +01:00
pipe.c BUG/MEDIUM: pipe/thread: fix atomicity of pipe counters 2020-01-30 09:15:37 +01:00
proto_sockpair.c BUG/MEDIUM: protocols: add a global lock for the init/deinit stuff 2019-07-24 16:45:02 +02:00
proto_tcp.c REORG: connection: move tcp_connect_probe() to conn_fd_check() 2019-12-27 16:38:43 +01:00
proto_udp.c BUG/MEDIUM: proto_udp/threads: recv() and send() must not be exclusive. 2019-12-10 19:09:15 +01:00
proto_uxst.c BUILD/MINOR: unix sockets: silence an absurd gcc warning about strncpy() 2019-12-11 16:29:10 +01:00
protocol.c BUG/MEDIUM: protocols: add a global lock for the init/deinit stuff 2019-07-24 16:45:02 +02:00
proxy.c MEDIUM: http: Add a ruleset evaluated on all responses just before forwarding 2020-02-06 14:55:34 +01:00
queue.c BUG/MINOR: queue/threads: make the queue unlinking atomic 2019-11-14 14:58:39 +01:00
raw_sock.c MEDIUM: raw-sock: remove obsolete calls to fd_{cant,cond,done}_{send,recv} 2020-01-28 19:06:41 +01:00
regex.c MEDIUM: regex: modify regex_comp() to atomically allocate/free the my_regex struct 2019-05-07 06:58:15 +02:00
ring.c MINOR: ring: make the parse function automatically set the handler/release 2019-11-15 15:48:12 +01:00
sample.c MINOR: debug: support logging to various sinks 2019-12-19 09:19:13 +01:00
server.c MEDIUM: dns: use Additional records from SRV responses 2020-01-22 07:19:54 +01:00
session.c MEDIUM: connection: use CO_FL_WAIT_XPRT more consistently than L4/L6/HANDSHAKE 2020-01-23 16:34:26 +01:00
sha1.c BUILD: use inttypes.h instead of stdint.h 2019-04-01 07:44:56 +02:00
shctx.c CLEANUP: Fix typos in the shctx subsystem 2018-12-02 18:40:29 +01:00
signal.c CLEANUP: Fix a typo in the signal subsystem 2018-12-02 18:39:52 +01:00
sink.c MINOR: ring: make the parse function automatically set the handler/release 2019-11-15 15:48:12 +01:00
ssl_sock.c BUG/MINOR: ssl: clear the SSL errors on DH loading failure 2020-02-05 15:32:24 +01:00
standard.c BUILD/MINOR: tools: shut up the format truncation warning in get_gmt_offset() 2019-10-29 10:19:34 +01:00
stats.c CLEANUP: stats: shut up a wrong null-deref warning from gcc 9.2 2020-01-23 11:49:02 +01:00
stick_table.c MINOR: cli: Report location of errors or any extra data for "show table" 2020-01-23 10:43:52 +01:00
stream.c BUG/MINOR: stream: Be sure to have a listener to increment its counters 2020-01-24 11:55:17 +01:00
stream_interface.c MINOR: connection: remove some unneeded checks for CO_FL_SOCK_WR_SH 2020-01-23 19:01:37 +01:00
task.c MINOR: task: don't set TASK_RUNNING on tasklets 2020-01-31 18:37:03 +01:00
tcp_rules.c MINOR: connection: remove CO_FL_SSL_WAIT_HS from CO_FL_HANDSHAKE 2020-01-23 16:34:26 +01:00
time.c MINOR: time: add timeofday_as_iso_us() to return instant time as ISO 2019-09-26 08:13:38 +02:00
trace.c BUG/MEDIUM: trace: fix a typo causing an incorrect startup error 2019-11-25 19:47:22 +01:00
uri_auth.c MINOR: stats: replace the ST_* uri_auth flags with STAT_* 2019-10-10 11:30:07 +02:00
vars.c MEDIUM: http: Add a ruleset evaluated on all responses just before forwarding 2020-02-06 14:55:34 +01:00
version.c MINOR: version: make the version strings variables, not constants 2019-10-16 09:56:57 +02:00
wdt.c BUILD/MEDIUM: threads: rename thread_info struct to ha_thread_info 2019-10-17 07:15:17 +02:00
wurfl.c BUG/MINOR: WURFL: fix send_log() function arguments 2019-10-15 10:47:31 +02:00
xprt_handshake.c MINOR: connection: remove CO_FL_SSL_WAIT_HS from CO_FL_HANDSHAKE 2020-01-23 16:34:26 +01:00
xxhash.c BUILD: use inttypes.h instead of stdint.h 2019-04-01 07:44:56 +02:00