wget: always print port# in 'Host' header (smaller code)
authorDenis Vlasenko <vda.linux@googlemail.com>
Wed, 3 Jan 2007 22:29:01 +0000 (22:29 -0000)
committerDenis Vlasenko <vda.linux@googlemail.com>
Wed, 3 Jan 2007 22:29:01 +0000 (22:29 -0000)
networking/wget.c

index bca66f822f804919bf67d9c31bc77b94d7dd0b1d..ee5aa63e9d6594e628ee4d5a6c2b2c66c6113761 100644 (file)
@@ -272,15 +272,8 @@ int wget_main(int argc, char **argv)
                                fprintf(sfp, "GET /%s HTTP/1.1\r\n", target.path);
                        }
 
-                       {
-                               const char *portstr = "";
-                               if (target.port != 80)
-                                       portstr = xasprintf(":%d", target.port);
-                               fprintf(sfp, "Host: %s%s\r\nUser-Agent: %s\r\n",
-                                       target.host, portstr, user_agent);
-                               if (ENABLE_FEATURE_CLEAN_UP && target.port != 80)
-                                       free((char*)portstr);
-                       }
+                       fprintf(sfp, "Host: %s:%u\r\nUser-Agent: %s\r\n",
+                               target.host, target.port, user_agent);
 
 #if ENABLE_FEATURE_WGET_AUTHENTICATION
                        if (target.user) {