Retry and redispatch to specific backend based on a header


In HAProxy HTTP mode, is it possible to retry and redispatch a request to a specific backend based on a HTTP header?

For example, if the request has a HTTP header (say x-trybackup: yes) and the first try to a backend (named primary1) errors out (say conn-failure) then can that request be retried and re-dispatched to another specific backend (named backup1) only if the header value is valid?

Any help or suggestion is appreciated.