Thanks Charlie for your well-researched reply. (BTW I’m replying to you ONLY via ACFUG as that is where I know you from. How are you doing? Well I’m sure.  I’m in LA now, and CF-wise it’s lonely out here. There is NO LACFUG (that I have found at least, PLEASE correct me if I am wrong.)

 

Yes, both variables do report the same thing—with one “small” exception, when running my script on my local machine I get:

cgi.http_host is: 127.0.0.1:8500

and

cgi.server_name is: 127.0.0.1

 

Originally I wrote a little script to strip out the port from the http_host variable before uploading files to fusionlink.  Realized this was not an issue however since I am only interested DNS alias/domain name (in my application).

 

But still, I was curious: if they are reporting the same value it doesn’t matter which I use, but then I was “certain” that there was undoubtedly something I did not know about their inner workings and thus which would be the “best practice” variable to use.

 

So, I guess then, to rephrase my question to ACFUG’s members: is there a “best practice” issue here on which variable to use?

 

 

Thanks again,

 

Dan Kaufman

 

 

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Charlie Arehart
Sent: Sunday, September 17, 2006 4:23 PM
To: discussion@sdcfug.org; discussion@acfug.org
Subject: [ACFUG Discuss] RE: [sdcfug-d] difference between CGI._http_host and CGI.server_name

 

Dan, you've sent the note to both the ACFUG and SDCFUG, and while I don't generally like to cross-post, it seems to make sense for me to send this one answer to both lists. Someone may offer a more authoritative answer (or correct me if I'm wrong), but here are my thoughts. The simple answer is that they do appear to be the same, but it's worth understanding them in more detail.

 

CGI variables encompass at least two classes of variables: some created by CF, and some passed to it from the web server. Of those passed from the web server, some are defined by the HTTP spec (such as described in detail at http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html) while others are created by the web server vendor. And some of the ones passed from the web server are really generated from the client (and passed through the web server).

 

As such, it's worth keeping in mind that it's always possible that some CGI variables showing on one test environment may not show up in testing done on a different web server or from a different browser.

 

To your question, http_host is one of several variables defined by the HTTP spec (specifically in that URL above at http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.23), where it's discussed as the "Host" header. As a side note, the formal header names in the spec are changed by CF to adds the http_ prefix, and if they have "-" in their name, CF changes that to "_", so accept-encoding and user-agent become http_accept_encoding and http_user_agent.

 

The CF docs do list some of the CGI variables:

 

- http://livedocs.macromedia.com/coldfusion/6.1/htmldocs/expres34.htm for 6.1

- http://livedocs.macromedia.com/coldfusion/7/htmldocs/wwhelp/wwhimpl/common/html/wwhelp.htm?context=ColdFusion_Documentation&file=00000194.htm and http://livedocs.macromedia.com/coldfusion/7/htmldocs/wwhelp/wwhimpl/common/html/wwhelp.htm?context=ColdFusion_Documentation&file=00000193.htm for CF7

 

But they don't list all of them. I'm not clear on which they choose to list and why. Again, some listed there are from the client (like remote_addr and remote_host), while others are clearly specific to the server (path_translated).

 

The CF7 docs describe server_name as "Server's hostname, DNS alias, or IP address as it appears in self-referencing URLs." The spec above says that the "host" header "specifies the Internet host and port number of the resource being requested" from the URL. My testing of a URL at localhost:80, however, does not show the http_host reflecting the port, though. Perhaps CF strips it out, or the web server.

Unless someone says otherwise from experience in some other particular environment, it seems they both report the same thing.

 

/charlie

http://www.carehart.org/blog/

 

 


From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Dan
Sent: Sunday, September 17, 2006 1:26 PM
To: discussion@sdcfug.org
Subject: [sdcfug-d] difference between CGI._http_host and CGI.server_name

 

Could anyone explain the difference between CGI.http_host and CGI.server_name?

 

They appear to return the same value.  I’d like to better understand how each one works, the pros and cons of using http_host or server_name.

 

I am currently using cgi.http_host to pull the domain name from a URL to “serve up” a different CSS style sheet based on the domain name in the URL. It has been suggested that I could do exactly the same process using cgi.server_name—and it appears that I would agree with that.  However I’ve been know to “self doubt” myself, so before I change my script I’d like to understand if there’s a benefit, or “better reason” for using one variable or the other.

 

Thanks to all,

 

 

Dan Kaufman

 

7850 W. Sunset Blvd.

Apt. 209

Los Angeles, CA 90046

 

818.793.9402

[EMAIL PROTECTED]

www.StudioKaufman.com

 

 

"What  is the distance between the eyes and the soul?"

Fortune Cookie

 

 

 

 


-------------------------------------------------------------
To unsubscribe from this list, manage your profile @
http://www.acfug.org?fa=login.edituserform

For more info, see http://www.acfug.org/mailinglists
Archive @ http://www.mail-archive.com/discussion%40acfug.org/
List hosted by FusionLink
-------------------------------------------------------------
-------------------------------------------------------------
To unsubscribe from this list, manage your profile @
http://www.acfug.org?fa=login.edituserform

For more info, see http://www.acfug.org/mailinglists
Archive @ http://www.mail-archive.com/discussion%40acfug.org/
List hosted by FusionLink
-------------------------------------------------------------

Reply via email to