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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |