Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number

Browsers send info?

by Gorby (Monk)
on May 05, 2003 at 04:22 UTC ( #255557=perlquestion: print w/replies, xml ) Need Help??
Gorby has asked for the wisdom of the Perl Monks concerning the following question:

Hello Wise Monks. Are the following statements regarding cgi programming in perl true?

1. When a browser visits a site generated by a perl cgi script, that browser can send headers containing information enclosed in tags that it chooses to make available. (i.e. <INFO> my number is 1234 </INFO>)

2. The target perl cgi script can capture the information between the tags and use it.

If these statements are true, what functions in perl should I use to capture the information? Hope you can shed some light on this.

Thanks in advance.


Replies are listed 'Best First'.
•Re: Browsers send info?
by merlyn (Sage) on May 05, 2003 at 06:19 UTC
    Neither of these are true. HTTP client-to-server information comes in a few limited forms:
    • The requested URL
    • The query string (the part after the question mark)
    • The HTTP headers (many of which have pre-defined meanings)
    • On a POST request, the content of the form (key/value pairs, usually)
    • On a POST request, the content of any uploaded files
    So, if you want information to go from a browser to a server, you'll have to figure out how to get it into one of these.

    -- Randal L. Schwartz, Perl hacker
    Be sure to read my standard disclaimer if this is a reply.

Re: Browsers send info?
by tachyon (Chancellor) on May 05, 2003 at 07:08 UTC

    To complete merlyns response the WebServer makes available cretain information sent by the browser in the %ENV hash which is probably what you are getting at (I think) This is not sent in the form of TAG /TAG as noted. You can see what is available by installing this script on your web server then pointing your browser at it. The imformation sent depends to an extent on which version of the browser is in use and user settings.

    #!/usr/bin/perl # print "Content-type: text/html\n\n"; print "$_\t$ENV{$_}\n" for keys %ENV; __DATA__ You will see something like this: COMSPEC="C:\WINNT\system32\cmd.exe" DOCUMENT_ROOT="C:/Program Files/Apache Group/Apache2/htdocs" GATEWAY_INTERFACE="CGI/1.1" HTTP_ACCEPT="image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, appl +ication/, application/, application/mswo +rd, application/x-shockwave-flash, */*" HTTP_ACCEPT_ENCODING="gzip, deflate" HTTP_ACCEPT_LANGUAGE="en-au" HTTP_CONNECTION="Keep-Alive" HTTP_HOST="localhost" HTTP_USER_AGENT="Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; .N +ET CLR 1.0.3705)" PATH="D:\Perl\bin\;C:\WINNT\system32;C:\WINNT;C:\WINNT\System32\Wbem" PATHEXT=".COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH" QUERY_STRING="" REMOTE_ADDR="" REMOTE_PORT="3264" REQUEST_METHOD="GET" REQUEST_URI="/cgi-bin/" SCRIPT_FILENAME="C:/Program Files/Apache Group/Apache2/cgi-bin/printen" SCRIPT_NAME="/cgi-bin/" SERVER_ADDR="" SERVER_ADMIN="" SERVER_NAME="localhost" SERVER_PORT="80" SERVER_PROTOCOL="HTTP/1.1" SERVER_SIGNATURE="<address>Apache/2.0.40 Server at localhost Port 80</ +address>\n" SERVER_SOFTWARE="Apache/2.0.40 (Win32)" SYSTEMROOT="C:\WINNT" WINDIR="C:\WINNT"




      Ah! That's exactly what I needed. Thanks!

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://255557]
Approved by submersible_toaster
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (4)
As of 2017-07-27 16:09 GMT
Find Nodes?
    Voting Booth?
    I came, I saw, I ...

    Results (418 votes). Check out past polls.