RE: [ACFUG Discuss] RE: [sdcfug-d] difference between CGI._http_host and CGI.server_name
Thanks Charlie for your well-researched reply. (BTW Im replying to you ONLY via ACFUG as that is where I know you from. How are you doing? Well Im sure. Im in LA now, and CF-wise its 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 thingwith 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 doesnt 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 ACFUGs 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, andsome passed to it fromthe web server. Of those passed from the web server, some are defined by the HTTP spec (such as described in detailat 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 environmentmay 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 _, soaccept-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_Documentationfile=0194.htmandhttp://livedocs.macromedia.com/coldfusion/7/htmldocs/wwhelp/wwhimpl/common/html/wwhelp.htm?context=ColdFusion_Documentationfile=0193.htmfor 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 theyboth 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. Id 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_nameand it appears that I would agree with that. However Ive been know to self doubt myself, so before I change my script Id like to understand
RE: [ACFUG Discuss] RE: [sdcfug-d] difference between CGI._http_host and CGI.server_name
Well your finding would be more consistent with what the http specs (which as I noted said it should include the port). And you're using the built-in web server in CFMX (port 8500), so again this shows how things can differ among web servers. That said, I happened to notice in my testing again using localhost:80 that for some reason it was being removed in the URL (and therefore not in the http_host). When I changed IIS to use port 81, I see then that when I requested the URL with :81, it did indeed show it in the http_host. So if you want to be able to test for the server name without worrying about the port (if provided), use server_name (and server_port gives that port). As for your answering here on the ACFUG only, I'm sure the SD folks will appreciate hearing what you found (and perhaps what I've added above). I'll leave the to you as to whether you want to forward this or not to them. As for an LA CFUG, the conglomeration of a few of them that used to exist did die out, but I see one calledhttp://www.laadug.org/that does show a CF topic in September. /charlie http://www.carehart.org/blog/ From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED]Sent: Sunday, September 17, 2006 8:06 PMTo: discussion@acfug.orgSubject: RE: [ACFUG Discuss] RE: [sdcfug-d] difference between CGI._http_host and CGI.server_name Thanks Charlie for your well-researched reply. (BTW Im replying to you ONLY via ACFUG as that is where I know you from. How are you doing? Well Im sure. Im in LA now, and CF-wise its 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 thingwith 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 doesnt 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 ACFUGs 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 ArehartSent: Sunday, September 17, 2006 4:23 PMTo: discussion@sdcfug.org; discussion@acfug.orgSubject: [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, andsome passed to it fromthe web server. Of those passed from the web server, some are defined by the HTTP spec (such as described in detailat 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 environmentmay 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 "_", soaccept-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_Documentationfile=0194.htmandhttp://livedocs.macromedia.com/coldfusion/7/htmldocs/wwhelp/wwhimpl/common/html/wwhelp.htm?context=ColdFusion_Documentationfile=0193.htmfor 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 t
RE: [ACFUG Discuss] RE: [sdcfug-d] difference between CGI._http_host and CGI.server_name
Thanks again Charlie. I took your thoughtful advice and forwarded on my (last) reply to you to the SDCFUG groupas I will this one. Keep up the good work. Dan -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Charlie Arehart Sent: Sunday, September 17, 2006 6:40 PM To: discussion@acfug.org Subject: RE: [ACFUG Discuss] RE: [sdcfug-d] difference between CGI._http_host and CGI.server_name Well your finding would be more consistent with what the http specs (which as I noted said it should include the port). And you're using the built-in web server in CFMX (port 8500), so again this shows how things can differ among web servers. That said, I happened to notice in my testing again using localhost:80 that for some reason it was being removed in the URL (and therefore not in the http_host). When I changed IIS to use port 81, I see then that when I requested the URL with :81, it did indeed show it in the http_host. So if you want to be able to test for the server name without worrying about the port (if provided), use server_name (and server_port gives that port). As for your answering here on the ACFUG only, I'm sure the SD folks will appreciate hearing what you found (and perhaps what I've added above). I'll leave the to you as to whether you want to forward this or not to them. As for an LA CFUG, the conglomeration of a few of them that used to exist did die out, but I see one calledhttp://www.laadug.org/that does show a CF topic in September. /charlie http://www.carehart.org/blog/ From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED] Sent: Sunday, September 17, 2006 8:06 PM To: discussion@acfug.org Subject: RE: [ACFUG Discuss] RE: [sdcfug-d] difference between CGI._http_host and CGI.server_name Thanks Charlie for your well-researched reply. (BTW Im replying to you ONLY via ACFUG as that is where I know you from. How are you doing? Well Im sure. Im in LA now, and CF-wise its 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 thingwith 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 doesnt 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 ACFUGs 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, andsome passed to it fromthe web server. Of those passed from the web server, some are defined by the HTTP spec (such as described in detailat 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 environmentmay 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 _, soaccept-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
Re: [ACFUG Discuss] RE: [sdcfug-d] difference between CGI._http_host and CGI.server_name
Charlie, That may be your browser removing the default port. Try telnet to localhost port 80. Then try: GET /index.cfm HTTP/1.1 Host: 127.0.0.1:80 Alternatively, use Paros (www.parosproxy.org) and check the host value being sent by the browser. FWIW, the host header is not required and is most useful for multihomed servers. -dhs Dean H. Saxe, CISSP, CEH [EMAIL PROTECTED] Free speech exercised both individually and through a free press, is a necessity in any country where people are themselves free. -- Theodore Roosevelt, 1918 On Sep 17, 2006, at 9:39 PM, Charlie Arehart wrote: Well your finding would be more consistent with what the http specs (which as I noted said it should include the port). And you're using the built-in web server in CFMX (port 8500), so again this shows how things can differ among web servers. That said, I happened to notice in my testing again using localhost:80 that for some reason it was being removed in the URL (and therefore not in the http_host). When I changed IIS to use port 81, I see then that when I requested the URL with :81, it did indeed show it in the http_host. So if you want to be able to test for the server name without worrying about the port (if provided), use server_name (and server_port gives that port). As for your answering here on the ACFUG only, I'm sure the SD folks will appreciate hearing what you found (and perhaps what I've added above). I'll leave the to you as to whether you want to forward this or not to them. As for an LA CFUG, the conglomeration of a few of them that used to exist did die out, but I see one called http://www.laadug.org/ that does show a CF topic in September. /charlie http://www.carehart.org/blog/ From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED] Sent: Sunday, September 17, 2006 8:06 PM To: discussion@acfug.org Subject: RE: [ACFUG Discuss] RE: [sdcfug-d] difference between CGI._http_host and CGI.server_name 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
RE: [ACFUG Discuss] RE: [sdcfug-d] difference between CGI._http_host and CGI.server_name
Yep, that was it (the browser was stripping it). Thanks for the tip(s). /charlie http://www.carehart.org/blog/ -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Dean H. Saxe Sent: Sunday, September 17, 2006 10:27 PM To: discussion@acfug.org Subject: Re: [ACFUG Discuss] RE: [sdcfug-d] difference between CGI._http_host and CGI.server_name Charlie, That may be your browser removing the default port. Try telnet to localhost port 80. Then try: GET /index.cfm HTTP/1.1 Host: 127.0.0.1:80 Alternatively, use Paros (www.parosproxy.org) and check the host value being sent by the browser. FWIW, the host header is not required and is most useful for multihomed servers. -dhs Dean H. Saxe, CISSP, CEH [EMAIL PROTECTED] Free speech exercised both individually and through a free press, is a necessity in any country where people are themselves free. -- Theodore Roosevelt, 1918 On Sep 17, 2006, at 9:39 PM, Charlie Arehart wrote: Well your finding would be more consistent with what the http specs (which as I noted said it should include the port). And you're using the built-in web server in CFMX (port 8500), so again this shows how things can differ among web servers. That said, I happened to notice in my testing again using localhost:80 that for some reason it was being removed in the URL (and therefore not in the http_host). When I changed IIS to use port 81, I see then that when I requested the URL with :81, it did indeed show it in the http_host. So if you want to be able to test for the server name without worrying about the port (if provided), use server_name (and server_port gives that port). As for your answering here on the ACFUG only, I'm sure the SD folks will appreciate hearing what you found (and perhaps what I've added above). I'll leave the to you as to whether you want to forward this or not to them. As for an LA CFUG, the conglomeration of a few of them that used to exist did die out, but I see one called http://www.laadug.org/ that does show a CF topic in September. /charlie http://www.carehart.org/blog/ From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED] Sent: Sunday, September 17, 2006 8:06 PM To: discussion@acfug.org Subject: RE: [ACFUG Discuss] RE: [sdcfug-d] difference between CGI._http_host and CGI.server_name 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