Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Browsers send info?

by Gorby (Monk)
on May 05, 2003 at 04:22 UTC ( [id://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.

Gorby

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 # printenv.pl 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/vnd.ms-powerpoint, application/vnd.ms-excel, 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="127.0.0.1" REMOTE_PORT="3264" REQUEST_METHOD="GET" REQUEST_URI="/cgi-bin/printenv.pl" SCRIPT_FILENAME="C:/Program Files/Apache Group/Apache2/cgi-bin/printen +v.pl" SCRIPT_NAME="/cgi-bin/printenv.pl" SERVER_ADDR="127.0.0.1" SERVER_ADMIN="admin@hbt.tassie.net.au" 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"

    cheers

    tachyon

    s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print

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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://255557]
Approved by submersible_toaster
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (3)
As of 2024-03-19 04:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found