Http-response set-header

Hi, I am experimenting with using the http-response command, specifically the following line:
http-response set-header X-Server %s

The configuration is as follows:

listen proxies-in
  bind 0.0.0.0:18509
  bind :::18509
  mode tcp
  default_backend proxies
  balance roundrobin

backend proxies
  mode HTTP
  http-response set-header X-Server %s
  server 127.0.0.1:15050 127.0.0.1:15050 check
  server 127.0.0.1:15051 127.0.0.1:15051 check

The goal here is that I would like to see the X-Server header added to the header and should indicate the server used to handle the request. I’ve seen configurations doing this but the X-Server is not added for my requests.

Client -> HaProxy Load balancing -> HTTPS Page --> HaProxy add header --> client.

Is this possible?

If this is not possible, How can I perform tasks given a specific HTTP Status code? For example run commands if i get status code 400 (lua or python)