[boulder.pm] http/1.1 question

Walter Pienciak walter at frii.com
Tue Feb 1 09:42:43 CST 2000


On Mon, 31 Jan 2000, Ray Carlino wrote:

> Here is the script. It works great with netscape but not with IE5. This runs on
> our web server so that users can view the site in text only without us having
> to make dup pages. The error I get is that hostname not sent by client which is
> the server address. If I change the settings in ie5 not to use http/1.1 then it
> works also.
> 
> Thanks
> Ray

Hi, 

Okay.  There's a web doc on this program at

    http://www.ssc.com/websmith/issues/i2/ws22.html

for anyone who wants a summary of this program.

The general issue is that this program is assuming HTTP 1.0 behavior
(RFC 1945) on the part of clients, but now some some clients are using
HTTP 1.1 (RFC 2616), which does try to deal with virtual hosts.  Apparently,
some environment variables have changed.  Two possible solutions:

1)  You can pore over the RFCs and try to figure out what in blazes has
    changed.

2)  You can just look at what the problematic browser is actually sending,
    by using both it  and a "good" browser to access a CGI program like

    #!/usr/bin/perl -T

    print "Content-type: text/html\n\n";
    while (($key, $val) = each %ENV) {
        print "$key = $val<BR>\n";
    }

    and then comparing the outputs.

I strongly recommend 2), though using the RFCs is invaluable sometimes.

So, let's say just for giggles that you do that and find that while in
HTTP 1.0 clients the information you want is contained in $ENV{SERVER_NAME},
in HTTP 1.1 clients it's in $ENV{HOST}.

In this case you'd look at the line

    $host = $ENV{SERVER_NAME};

and modify it:

    $host = defined( $ENV{SERVER_NAME} ) ? $ENV{SERVER_NAME} : $ENV{HOST};

or, in more readable syntax,

    if ( defined($ENV{SERVER_NAME}) ) {  # HTTP 1.0 behavior
        $host = $ENV{SERVER_NAME};
    } else {                             # HTTP 1.1
        $host = $ENV{HOST};
    }


Walter





More information about the Boulder-pm mailing list