I'm attempting to use HTTP::Server::Simple together with SSL. The link here shows how to use SSL in the accept_hook subclass

http://search.cpan.org/~jesse/HTTP-Server-Simple-0.44/lib/HTTP/Server/Simple.pm#accept_hook

However, when I attempt to use this, the accept_hook function never gives control back to the handle_request function where my CGI processing lies. I call it from a web brower using https://server:8080/hello?name=bob My question is, where does code execution go after the accept_hook handles the SSL setup? Here is an outline:
#!/usr/bin/perl { package MyWebServer; use HTTP::Server::Simple::CGI; use IO::Socket::SSL; use base qw(HTTP::Server::Simple::CGI); my %dispatch = ( '/hello' => \&resp_hello, # ... ); sub handle_request { my $self = shift; my $cgi = shift; my $path = $cgi->path_info(); my $handler = $dispatch{$path}; if (ref($handler) eq "CODE") { print "HTTP/1.0 200 OK\r\n"; $handler->($cgi); } else { print "HTTP/1.0 404 Not found\r\n"; print $cgi->header, $cgi->start_html('Not found'), $cgi->h1('Not found'), $cgi->end_html; } } sub resp_hello { my $cgi = shift; # CGI.pm object return if !ref $cgi; my $who = $cgi->param('name'); print $cgi->header, $cgi->start_html("Hello"), $cgi->h1("Hello $who!"), $cgi->end_html; } sub accept_hook { my $self = shift; my $fh = $self->stdio_handle; $self->SUPER::accept_hook(@_); my $newfh = IO::Socket::SSL->start_SSL( $fh, SSL_server => 1, SSL_use_cert => 1, SSL_cert_file => 'myserver.crt', SSL_key_file => 'myserver.key', SSL_verify_mode => 0x00, ) or warn "problem setting up SSL socket: " . IO::Socket::SSL::e +rrstr(); $self->stdio_handle($newfh) if $newfh; } } # start the server on port 8080 my $pid = MyWebServer->new(8080)->background(); print "Use 'kill $pid' to stop server.\n";

In reply to CGI with SSL support by hotrod7262

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.