3

I wanted to see how my site would respond to a request if the hostname is in capital letters instead of the usual lower-case. I tried doing that on FireFox and Chrome, but they automatically convert the hostname to lower-case letters. Then I tried using wget on terminal, but it too convert the request to lower-case. Is there any way I can test this?

7

You could use --header option of wget.

wget --header 'Host: EXAMPLE.COM' http://example.com

with --debug you could see actual request

wget --debug --header 'Host: EXAMPLE.COM' http://example.com

...

---request begin---
GET / HTTP/1.1
User-Agent: Wget/1.13.4 (linux-gnu)
Accept: */*
Host: EXAMPLE.COM
Connection: Keep-Alive

---request end---
...

But actually it's useless unless you use some custom web server. All modern web servers take care of converting hostname to lowercase.

1
  • "All modern web servers take care of converting hostname to lowercase." - Web servers (Apache at least) don't actually "convert" the hostname to lowercase. The web server compares the Host header case-insensitively when mapping the request to the server/vHost, however, the Host header is passed through as-is to other server-side scripts (including Apache config) where it will be compared case-sensitively, unless you take steps not to. However, all modern "browsers" do convert the hostname to lowercase before making the request (but bots might not). – MrWhite Mar 7 at 21:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.