summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMukund Sivaraman <muks@banu.com>2011-02-07 18:00:39 +0530
committerMukund Sivaraman <muks@banu.com>2011-02-07 18:00:39 +0530
commit7378c975246e96270ce871bedbde51cae01199a5 (patch)
tree366cc19765a60208e35e3a09f48893faa1f4a86e /src
parent2d02e2211e1493b2652b44329bd0b29bac71c1b7 (diff)
downloadtinyproxy-7378c975246e96270ce871bedbde51cae01199a5.tar.gz
tinyproxy-7378c975246e96270ce871bedbde51cae01199a5.zip
Surround IPv6 literals with [] in Host: headers
Diffstat (limited to 'src')
-rw-r--r--src/reqs.c24
1 files changed, 18 insertions, 6 deletions
diff --git a/src/reqs.c b/src/reqs.c
index 569f916..2de43a8 100644
--- a/src/reqs.c
+++ b/src/reqs.c
@@ -268,6 +268,7 @@ static int
establish_http_connection (struct conn_s *connptr, struct request_s *request)
{
char portbuff[7];
+ char dst[sizeof(struct in6_addr)];
/* Build a port string if it's not a standard port */
if (request->port != HTTP_PORT && request->port != HTTP_PORT_SSL)
@@ -275,12 +276,23 @@ establish_http_connection (struct conn_s *connptr, struct request_s *request)
else
portbuff[0] = '\0';
- return write_message (connptr->server_fd,
- "%s %s HTTP/1.0\r\n"
- "Host: %s%s\r\n"
- "Connection: close\r\n",
- request->method, request->path,
- request->host, portbuff);
+ if (inet_pton(AF_INET6, request->host, dst) > 0) {
+ /* host is an IPv6 address literal, so surround it with
+ * [] */
+ return write_message (connptr->server_fd,
+ "%s %s HTTP/1.0\r\n"
+ "Host: [%s]%s\r\n"
+ "Connection: close\r\n",
+ request->method, request->path,
+ request->host, portbuff);
+ } else {
+ return write_message (connptr->server_fd,
+ "%s %s HTTP/1.0\r\n"
+ "Host: %s%s\r\n"
+ "Connection: close\r\n",
+ request->method, request->path,
+ request->host, portbuff);
+ }
}
/*