On Tue, Jan 10, 2017 at 9:36 AM, Cyril Bonté <[email protected]> wrote:
> This is because haproxy behaves differently depending on the the Location
> URL :
> - beginning with /, it will allow HTTP keep-alived connections (Location:
> /redir/foo)
> - otherwise it unconditionnally won't, and there's no option to change this
> (Location: http://mysite/redir)
Quickly looking through the latest HAProxy code on the 1.7 branch, I
think I found the piece of code which is responsible for closing the
connections on redirects that do not start with `/`:
~~~~ [starting with line 4225] ~~~~
if (*location == '/' &&
(req->flags & HTTP_MSGF_XFER_LEN) &&
((!(req->flags & HTTP_MSGF_TE_CHNK) && !req->body_len) ||
(req->msg_state == HTTP_MSG_DONE)) &&
((txn->flags & TX_CON_WANT_MSK) == TX_CON_WANT_SCL ||
(txn->flags & TX_CON_WANT_MSK) == TX_CON_WANT_KAL)) {
/* keep-alive possible */
~~~~
(This also explains why protocol-relative URL's (i.e.
`//some-domain.com/...`) work.)
Thus if I were to patch my HAProxy build to eliminate the just the
`*location == '/'` expression, I would obtain keep-alive regardless of
where I redirect the browser.
Could someone more experienced in the HAProxy source code advise if
this is the only place I should give a look?
Thanks,
Ciprian.