Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Processing POST request in simple Windows server.

by gothic_mallard (Pilgrim)
on Oct 22, 2004 at 07:47 UTC ( [id://401413]=note: print w/replies, xml ) Need Help??


in reply to Processing POST request in simple Windows server.

I'd recommend you take a look at CGI.pm that handles all this kind of thing for you in a nice little module.

--- Jay

All code is untested unless otherwise stated.

Replies are listed 'Best First'.
Re^2: Processing POST request in simple Windows server.
by John Whitney (Novice) on Oct 23, 2004 at 06:49 UTC
    Appreciate the response.

    I looked at CGI.pm and the documentation regarding it. But all the examples I could find using CGI.pm were the case where there was just the need to process one POST/GET request..

    In my case I've created a server that needs to process many POST/GET requests. What I am missing is the following loop....

    use cgi while (a request to localhost:6789 server) { process the request with CGI.pm modules }
    here's the code that makes an attempt at this loop....

    use IO::Socket; use Net::hostent; use CGI; # Constants $cnst_port = 6789; # Port we want to listen to $cnst_server = 'http://localhost:' . $cnst_port . '/'; # Server addre +ss $server = IO::Socket::INET->new( Proto => 'tcp', LocalPort => $cnst_po +rt, Listen => SOMAXCONN, Reuse => 1 ); die "Can\'t set up server" unless $server; print STDERR "Server Version 0.637\n" . "Server accepting clients via $cnst_server\n"; while ($client = $server->accept()) { $client->autoflush(1); $cgi = new CGI; $request_path_translated = $cgi->path_translated(); $request_query_string = $cgi->query_string(); $request_request_method = $cgi->request_method(); print STDERR "request_path_translated = $request_path_translated\n"; print STDERR "request_query_string = $request_query_string\n"; print STDERR "request_request_method = $request_request_method\n"; RETURN_DUMMY_PAGE (); close($client); } sub RETURN_DUMMY_PAGE { print $client 'HTTP/1.0 200 OK' . "\n" . 'Content-type: text/html' . "\n\n" . '<HTML>' . "\n" . ' <HEAD><TITLE>Asayo - LED Sign Software XL</TITLE></HEAD>' . "\n" + . ' <BODY><H1>Dummy Page</H1></BODY>' . "\n" . '</HTML>' . "\n"; }
    The dummy page gets returned each time, but the CGI calls return nothing..

    Any ideas?

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (2)
As of 2024-04-26 03:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found