MEDIUM: httpclient: allow address and port change for resolving

To allow the http-request set-dst to work for the httpclient DNS
resolving, some changes need to be done:

- The destination address need to be set in the frontend (s->csf->dst)
  instead of the backend (s->csb->dst) to be able to use
  tcp_action_req_set_dst()

- SRV_F_MAPPORTS need to be set on the proxy in order to allow the port
  change in alloc_dst_address()
This commit is contained in:
William Lallemand 2022-05-03 14:09:06 +02:00
parent 5392ff6e3c
commit 1218d19921

View File

@ -596,8 +596,8 @@ struct appctx *httpclient_start(struct httpclient *hc)
s->req.wto = hc->timeout_server;
s->res.rto = hc->timeout_server;
s->csb->dst = addr;
s->csb->flags |= CS_FL_NOLINGER;
s->csf->dst = addr;
s->csf->flags |= CS_FL_NOLINGER;
s->flags |= SF_ASSIGNED;
s->res.flags |= CF_READ_DONTWAIT;
@ -1114,6 +1114,7 @@ static int httpclient_precheck()
httpclient_srv_raw->iweight = 0;
httpclient_srv_raw->uweight = 0;
httpclient_srv_raw->xprt = xprt_get(XPRT_RAW);
httpclient_srv_raw->flags |= SRV_F_MAPPORTS; /* needed to apply the port change with resolving */
httpclient_srv_raw->id = strdup("<HTTPCLIENT>");
if (!httpclient_srv_raw->id)
goto err;
@ -1130,6 +1131,7 @@ static int httpclient_precheck()
httpclient_srv_ssl->uweight = 0;
httpclient_srv_ssl->xprt = xprt_get(XPRT_SSL);
httpclient_srv_ssl->use_ssl = 1;
httpclient_srv_ssl->flags |= SRV_F_MAPPORTS; /* needed to apply the port change with resolving */
httpclient_srv_ssl->id = strdup("<HTTPSCLIENT>");
if (!httpclient_srv_ssl->id)
goto err;