How can I access a case sensitive host name?

This is a discussion on How can I access a case sensitive host name? within the PHP Language forums, part of the PHP Programming Forums category; Is there a way to echo back a case sensitive $HTTP_HOST in PHP? For example if I type HostName.domain....


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 10-08-2004
Jeff
 
Posts: n/a
Default How can I access a case sensitive host name?

Is there a way to echo back a case sensitive $HTTP_HOST in PHP? For
example if I type HostName.domain.com in my browser I want to return it
exactly as it appears in the location part of the browser
"HostName.domain.com" but it keeps returning a case insensitive result
"hostname.domain.com".


Reply With Quote
  #2 (permalink)  
Old 10-08-2004
Chris Hope
 
Posts: n/a
Default Re: How can I access a case sensitive host name?

Jeff wrote:

> Is there a way to echo back a case sensitive $HTTP_HOST in PHP? For
> example if I type HostName.domain.com in my browser I want to return it
> exactly as it appears in the location part of the browser
> "HostName.domain.com" but it keeps returning a case insensitive result
> "hostname.domain.com".


I would imagine the hostname that's being passwed to $HTTP_HOST (and
incidentally you should really be using $_SERVER['HTTP_HOST']) is what's
defined in the web server's configuration, which is likely to be in lower
case.

It's possible that even if it were allowed to be in mixed case in the web
server's config that it might still be passed to PHP as lowercase, or that
the browser itself is lowercasing the domain when it makes the request to
the server.

Regardless of all this, there's no way you can assume that an end-user will
actually type the domain into their browser using mixed case so you cannot
rely on this in your script.

At least now your other question about adding spaces before upper cased
letters now has some context :)

--
Chris Hope - The Electric Toolbox - http://www.electrictoolbox.com/
Reply With Quote
  #3 (permalink)  
Old 10-08-2004
Tim Van Wassenhove
 
Posts: n/a
Default Re: How can I access a case sensitive host name?

In article <dXC9d.205753$MQ5.116054@attbi_s52>, Jeff wrote:
> Is there a way to echo back a case sensitive $HTTP_HOST in PHP? For
> example if I type HostName.domain.com in my browser I want to return it
> exactly as it appears in the location part of the browser
> "HostName.domain.com" but it keeps returning a case insensitive result
> "hostname.domain.com".


Since when are hostnames case sensitive then?
Are you even sure your browser requests Foo instead of foo?

--
Met vriendelijke groeten,
Tim Van Wassenhove <http://www.timvw.info>
Reply With Quote
  #4 (permalink)  
Old 10-08-2004
Andy Hassall
 
Posts: n/a
Default Re: How can I access a case sensitive host name?

On Fri, 08 Oct 2004 20:40:41 GMT, "Jeff" <jmox@mail.com> wrote:

>Is there a way to echo back a case sensitive $HTTP_HOST in PHP? For
>example if I type HostName.domain.com in my browser I want to return it
>exactly as it appears in the location part of the browser
>"HostName.domain.com" but it keeps returning a case insensitive result
>"hostname.domain.com".


This behaviour makes sense - what's your need for case-sensitivity in the
case-insensitive domain name system?

RFC1035 sec 2.3.1 <http://www.ietf.org/rfc/rfc1035.txt>

"Note that while upper and lower case letters are allowed in domain
names, no significance is attached to the case. That is, two names with
the same spelling but different case are to be treated as if identical."

Monitoring HTTP requests with Ethereal made through Firefox and Internet
Explorer 6 shows that it converts the host to lowercase before it makes the
request - no mixed case Host: header gets through to the server.

--
Andy Hassall / <andy@andyh.co.uk> / <http://www.andyh.co.uk>
<http://www.andyhsoftware.co.uk/space> Space: disk usage analysis tool
Reply With Quote
  #5 (permalink)  
Old 10-08-2004
Jeff
 
Posts: n/a
Default Re: How can I access a case sensitive host name?

Thanks guys, I now understand the potential problems with this approach.
I have decided using underscores to separate multiple words in the host
name will prevent these problems while still enabling me to detect and
decipher multi worded host names.


Reply With Quote
  #6 (permalink)  
Old 10-08-2004
Chris Hope
 
Posts: n/a
Default Re: How can I access a case sensitive host name?

Jeff wrote:

> Thanks guys, I now understand the potential problems with this approach.
> I have decided using underscores to separate multiple words in the host
> name will prevent these problems while still enabling me to detect and
> decipher multi worded host names.


You'll be better to use dashes - and not underscores _ in your hostnames. I
have seen underscores used in hostnames before, but you're only allowed
a-z, 0-9 and - in domain names so it's best to stick to this for hostnames
as well.

--
Chris Hope - The Electric Toolbox - http://www.electrictoolbox.com/
Reply With Quote
  #7 (permalink)  
Old 10-09-2004
Coder Droid
 
Posts: n/a
Default Re: How can I access a case sensitive host name?

> For example if I type HostName.domain.com in my browser I want
> to return it exactly as it appears in the location part of the
> browser [snip]


I would venture to guess this isn't possible. What the user types in
their address/location is a client request. His or her client takes this
request and (via DNS) translates that to an address. If an appropriate
program is listening at that address, it will process the request and
send a response.

I don't see anything on this path where the actual string typed by the
user is ever going to be transmitted all the way to the web server and
made available to server side programs.

Since this string is client side, it might be possible to get to it
through other client-side means (javascript, for example).

--cd


Reply With Quote
  #8 (permalink)  
Old 10-09-2004
Coder Droid
 
Posts: n/a
Default Re: How can I access a case sensitive host name?

> Thanks guys, I now understand the potential problems with this
approach.
> I have decided using underscores to separate multiple words in the

host
> name will prevent these problems while still enabling me to detect and
> decipher multi worded host names.


You've got me curious: what are you doing? I don't mean that negatively:
I'm really curious what you're up to here, if you don't mind sharing.

--cd


Reply With Quote
  #9 (permalink)  
Old 10-09-2004
Jeff
 
Posts: n/a
Default Re: How can I access a case sensitive host name?

Sounds good, thanks.


Reply With Quote
  #10 (permalink)  
Old 10-09-2004
Gordon Burditt
 
Posts: n/a
Default Re: How can I access a case sensitive host name?

>I would venture to guess this isn't possible. What the user types in
>their address/location is a client request. His or her client takes this
>request and (via DNS) translates that to an address. If an appropriate
>program is listening at that address, it will process the request and
>send a response.


Modern web servers that serve multiple web sites depend on the HTTP
Host: header to determine what virtual host the request is for.
The days of needing a separate IP address for each virtual host
were long over 5 years ago.

A typical setup will have DNS entries for www.mysite.com and
www.yoursite.com and maybe a few hundred other names CNAMEd (or,
it could use A records) to www.ispwebserver.com. Apache (or other
server software) looks at the Host: header to figure out which site
("virtualhost") the request is for, and serves up the appropriate
pages. You CANNOT tell this by the IP address (the same for all 3
names above).

>I don't see anything on this path where the actual string typed by the
>user is ever going to be transmitted all the way to the web server and
>made available to server side programs.


The host name as the user types it should appear in the Host:
header. However, no guarantees that the case won't be changed
before it gets to the server, and definitely no guarantees that
the server won't just give the virtual host name as it appears
in the config file.

Gordon L. Burditt
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 07:56 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0