Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

Re^3: HTTP::Server::Simple forking/SSL/IPv6

by Corion (Pope)
on Oct 24, 2011 at 14:03 UTC ( #933410=note: print w/replies, xml ) Need Help??

in reply to Re^2: HTTP::Server::Simple forking/SSL/IPv6
in thread HTTP::Server::Simple forking/SSL/IPv6

Moving from HTTP::Server::Simple to a PSGI setup using Plack shouldn't be hard. In HTTP::Server::Simple(::CGI), you have the subroutine handle_request, which prints its output. In PSGI, you have an anonymous subroutine that returns the HTML to be sent.

This is the part you need to change, instead of printing your HTML, you return a triplet of [ $status, $headers, $body ].

Replies are listed 'Best First'.
Re^4: HTTP::Server::Simple forking/SSL/IPv6
by cavac (Deacon) on Oct 24, 2011 at 14:26 UTC

    Well, in my case there's probably a bit more work involved. I also do things like on-the-fly HTTP compression, keeping database connections open, etc...

    If i understand correctly, the various files are loaded on request and not on startup? Or am i misreading the documentation?

    If everything is in an anonymous subroutine, how does debugging work? With Maplat (my framework), i just start the script with the appropriate breakpoints set and then surf to the page i want to debug.

    Edit: On a personal note, Corion, i really love the Power-to-Ethernet cable on your homenode. Where can i get one?

    Don't use '#ff0000':
    use Acme::AutoColor; my $redcolor = RED();
    All colors subject to change without notice.

      Depending on the backend (HTTP::Server::Simple, Starman, Corona, ...) you get persistence of connections and other values, or not (for example with Plack::Handler::CGI). The files are loaded on program startup, which is server startup for the permanent servers and page request for CGI.

      Having in-process debugging is something I have no experience with. Only the outermost part of your web application is an anonymous subroutine, everything else can be named subroutines, so finding your way around should work the same still. I guess a quick test whether your debugging setup works would be to just use one of the Plack example applications, set your breakpoints and see whether the program is debuggable under whatever server you plan to use.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://933410]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (7)
As of 2017-12-12 17:14 GMT
Find Nodes?
    Voting Booth?
    What programming language do you hate the most?

    Results (335 votes). Check out past polls.