On 07.09.2010 16:17, Hrvoje Niksic wrote: > Tom Mizutani<[email protected]> writes: > >> If you really believe that "www.example.com" is a virtual server, I >> suggest to specify the host with "--header" command line option, as >> follows: >> >> wget http://1.1.1.1/ --header 'Host: www.example.com' >> wget http://2.2.2.2/ --header 'Host: www.example.com' > > That is exactly the way to do it, and has worked perfectly for me in the > past (in fact, supporting this was an important use case when the > --header feature was last revamped).
Replying after 6 months or so :) - but in the end, I don't think it works as it should, when the site is redirected. I will paste 2 examples below with some explanations. We will use "www.wpkg.org" as an example - it normally redirects to "wpkg.org". 1) example one, we don't use the "--header" - www.wpkg.org redirects to wpkg.org $ wget -O /dev/null http://www.wpkg.org --2011-03-23 14:06:44-- http://www.wpkg.org/ Resolving www.wpkg.org... 178.63.195.126, 2a01:4f8:120:14c4::1111 Connecting to www.wpkg.org|178.63.195.126|:80... connected. HTTP request sent, awaiting response... 301 Moved Permanently Location: http://wpkg.org/ [following] --2011-03-23 14:06:44-- http://wpkg.org/ Resolving wpkg.org... 178.63.195.126, 2a01:4f8:120:14c4::1111 Reusing existing connection to www.wpkg.org:80. HTTP request sent, awaiting response... 200 OK Length: unspecified [text/html] Saving to: `/dev/null' [ <=> ] 13,424 --.-K/s in 0.07s 2011-03-23 14:06:44 (191 KB/s) - `/dev/null' saved [13424] 2) example two - we use the "--header" - we hit redirect number: $ wget -O /dev/null http://178.63.195.126 --header 'Host: www.wpkg.org' --2011-03-23 14:10:09-- http://178.63.195.126/ Connecting to 178.63.195.126:80... connected. HTTP request sent, awaiting response... 301 Moved Permanently Location: http://wpkg.org/ [following] --2011-03-23 14:10:09-- http://wpkg.org/ Resolving wpkg.org... 178.63.195.126, 2a01:4f8:120:14c4::1111 Reusing existing connection to 178.63.195.126:80. HTTP request sent, awaiting response... 301 Moved Permanently Location: http://wpkg.org/ [following] --2011-03-23 14:10:09-- http://wpkg.org/ Reusing existing connection to 178.63.195.126:80. HTTP request sent, awaiting response... 301 Moved Permanently Location: http://wpkg.org/ [following] --2011-03-23 14:10:09-- http://wpkg.org/ Reusing existing connection to 178.63.195.126:80. HTTP request sent, awaiting response... 301 Moved Permanently (...) 20 redirections exceeded. $ echo $? 8 (8 - Server issued an error response.) This happens because the 'Host: www.wpkg.org' header is attached to each subsequent request. Because of this, it's sometimes impossible to test if a vhost running on a given IP is OK or not! Any ideas how to best solve it? -- Tomasz Chmielewski http://wpkg.org
