Browse files

use bracket notation for HTTP/1.1 Host: header, as alain pointed out

in ipngwg (IETF adelaide).
  • Loading branch information...
1 parent 8a161ae commit 7f3f8f7a89b80a5f9c037acb105522cb1f1faaca sumikawa committed May 7, 2000
Showing with 7 additions and 2 deletions.
  1. +7 −2 freebsd3/usr.bin/fetch/http.c
View
9 freebsd3/usr.bin/fetch/http.c
@@ -220,8 +220,13 @@ http_parse(struct fetch_state *fs, const char *u)
*/
https->http_hostname = safe_strdup(hostname);
https->http_port = port;
- hosthdr = alloca(sizeof("Host: :\r\n") + 5 + strlen(hostname));
- sprintf(hosthdr, "Host: %s:%d\r\n", hostname, port);
+ if (strchr(hostname, ':')) {
+ hosthdr = alloca(sizeof("Host: :\r\n") + 7 + strlen(hostname));
+ sprintf(hosthdr, "Host: [%s]:%d\r\n", hostname, port);
+ } else {
+ hosthdr = alloca(sizeof("Host: :\r\n") + 5 + strlen(hostname));
+ sprintf(hosthdr, "Host: %s:%d\r\n", hostname, port);
+ }
https->http_host_header = safe_strdup(hosthdr);
/*

0 comments on commit 7f3f8f7

Please sign in to comment.