[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] MacHTTP CGI question revisited



Here's a script that displays ENV variables imported by CGI.pm. The
result page is below. For more info, view the CGI.pm section titled
"FETCHING ENVIRONMENT VARIABLES" with Shuck, the POD viewer. Also check
your WebStar / MacHTTP tech ref manual, section "MacHTTP AppleScript &
AppleEvent Variables". 

#!perl -w

use CGI;

$q = new CGI;

$| = 1;
print <<END;
Content-type: text/html

<HTML>
<HEAD>
   <TITLE>Mac Environment Test</TITLE>
</HEAD>
<BODY>

<H1><CENTER>Mac Environment Test</CENTER></H1>
<P>CGI.pm defines the following methods for query objects. Notice that
some 
of them are null. This means, I think, that the browser didn't supply
the 
appropriate value.<BR><BR>

END
print "accept          => ", $q->accept(), "<BR>\n";
print "user_agent      => ",  $q->user_agent(), "<BR>\n";
print "path_info       => ",  $q->path_info(), "<BR>\n";
print "path_translated => ",  $q->path_translated(), "<BR>\n";
print "remote_host     => ",  $q->remote_host(), "<BR>\n";
print "script_name     => ",  $q->script_name(), "<BR>\n";
print "referer         => ",  $q->referer(), "<BR>\n";
print "auth_type       => ",  $q->auth_type(), "<BR>\n";
print "server_name     => ",  $q->server_name(), "<BR>\n";
print "server_software => ",  $q->server_software(), "<BR>\n";
print "server_protocol => ",  $q->server_protocol(), "<BR>\n";
print "remote_addr     => ",  $q->remote_addr(), "<BR>\n";
print "remote_user     => ",  $q->remote_user(), "<BR>\n";
print "user_name       => ",  $q->user_name(), "<BR>\n";
print "request_method  => ",  $q->request_method(), "<BR>\n";
print "raw_cookie      => ",  $q->raw_cookie(), "<BR>\n";

print <<END;
<P>The following is the result of Chris Nandor's \@ENV method. Same
reason 
for null values. <BR><BR>

END

@ENV = qw(
        HTTP_USER_AGENT
        REMOTE_ADDR
        SERVER_SOFTWARE
        SERVER_PROTOCOL
        GATEWAY_INTERFACE
        REQUEST_METHOD
        SCRIPT_NAME
        SERVER_NAME
        SERVER_PORT
);
foreach $key (sort @ENV) {
        print $key, " = ", $ENV{$key}, "<BR>\n";
}

print "</BODY></HTML>\n";

exit (0);
__END__

===================================
Here's the result. . . 
===================================





           Mac Environment Test

CGI.pm defines the following methods for query objects. Notice that some 
of them are null. This means, I think, that the browser didn't supply
the 
appropriate value.

accept => 
user_agent => Mozilla/3.01 (Macintosh; I; 68K)
path_info => 
path_translated => 
remote_host => col-as1s49.erols.com.
script_name => /cgi-bin/envTest.cgi
referer => http://207.172.68.49/
auth_type => 
server_name => col-as1s49.erols.com.
server_software => MacHTTP/2.0
server_protocol => HTTP/1.0
remote_addr => col-as1s49.erols.com.
remote_user => 
user_name => 
request_method => GET
raw_cookie => 

The following is the result of Chris Nandor's @ENV method. Same reason 
for null values. 

GATEWAY_INTERFACE = CGI/1.1
HTTP_USER_AGENT = Mozilla/3.01 (Macintosh; I; 68K)
REMOTE_ADDR = col-as1s49.erols.com.
REQUEST_METHOD = GET
SCRIPT_NAME = /cgi-bin/envTest.cgi
SERVER_NAME = col-as1s49.erols.com.
SERVER_PORT = 80
SERVER_PROTOCOL = HTTP/1.0
SERVER_SOFTWARE = MacHTTP/2.0

-- 
----------------------------------------
--- Tom Kennedy -- tomKenn@erols.com ---


***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch