1
0
mirror of git://git.gnupg.org/gnupg.git synced 2025-01-25 15:27:03 +01:00

Part of issue 1447: Pass proper Host header when SRV is used.

* common/http.c (send_request, connect_server): Set proper Host header
  (no :port, host is that of the SRV) when SRV is used in the
  curl-shim.
This commit is contained in:
David Shaw 2012-12-15 10:35:19 -05:00
parent ba9e974f1f
commit cbe98b2cb1

View File

@ -1009,7 +1009,7 @@ send_request (http_t hd, const char *auth,
{ {
char portstr[35]; char portstr[35];
if (port == 80) if (port == 80 || (srv && srv->used_server))
*portstr = 0; *portstr = 0;
else else
sprintf (portstr, ":%u", port); sprintf (portstr, ":%u", port);
@ -1544,7 +1544,7 @@ connect_server (const char *server, unsigned short port,
unsigned int flags, struct http_srv *srv) unsigned int flags, struct http_srv *srv)
{ {
int sock = -1; int sock = -1;
int srvcount = 0; int srvcount = 0, fakesrv = 0;
int hostfound = 0; int hostfound = 0;
int srvindex, connected, chosen=-1; int srvindex, connected, chosen=-1;
int last_errno = 0; int last_errno = 0;
@ -1613,6 +1613,7 @@ connect_server (const char *server, unsigned short port,
strncpy (serverlist->target, server, MAXDNAME); strncpy (serverlist->target, server, MAXDNAME);
serverlist->target[MAXDNAME-1] = '\0'; serverlist->target[MAXDNAME-1] = '\0';
srvcount = 1; srvcount = 1;
fakesrv = 1;
} }
#ifdef HAVE_GETADDRINFO #ifdef HAVE_GETADDRINFO
@ -1713,7 +1714,7 @@ connect_server (const char *server, unsigned short port,
} }
#endif /* !HAVE_GETADDRINFO */ #endif /* !HAVE_GETADDRINFO */
if(chosen>-1 && srv) if(!fakesrv && chosen>-1 && srv)
{ {
srv->used_server = xstrdup (serverlist[chosen].target); srv->used_server = xstrdup (serverlist[chosen].target);
srv->used_port = serverlist[chosen].port; srv->used_port = serverlist[chosen].port;