Net::Server::HTTP



Net::Server::HTTP

NAME
TEST ONE LINER
SYNOPSIS
DESCRIPTION
METHODS
COMMAND LINE ARGUMENTS
TODO
AUTHOR
THANKS
SEE ALSO
POD ERRORS

NAME

Net::Server::HTTP − very basic Net::Server based HTTP server class

TEST ONE LINER

    perl −e 'use Net::Server::HTTP; Net::Server::HTTP−>run(port=>8080)'

SYNOPSIS

    use base qw(Net::Server::HTTP);
    __PACKAGE__−>run;
    sub process_http_request {
        my $self = shift;
        print "Content−type: text/html\n\n";
        print "<form method=post action=/bam><input type=text name=foo><input type=submit></form>\n";
        if (require Data::Dumper) {
            local $Data::Dumper::Sortkeys = 1;
            my $form = {};
            if (require CGI) {  my $q = CGI−>new; $form−>{$_} = $q−>param($_) for $q−>param;  }
            print "<pre>".Data::Dumper−>Dump([\%ENV, $form], ['*ENV', 'form'])."</pre>";
        }
    }

DESCRIPTION

Even though Net::Server::HTTP doesn’t fall into the normal parallel of the other Net::Server flavors, handling HTTP requests is an often requested feature and is a standard and simple protocol.

Net::Server::HTTP begins with base type MultiType defaulting to Net::Server::Fork. It is easy to change it to any of the other Net::Server flavors by passing server_type => $other_flavor in the server configurtation. The port has also been defaulted to port 80 − but could easily be changed to another through the server configuration.

METHODS

"process_http_request"

During this method, the %ENV will have been set to a standard CGI style environment. You will need to be sure to print the Content-type header. This is one change from the other standard Net::Server base classes.

During this method you can read from ENV and STDIN just like a normal HTTP request in other web servers. You can print to STDOUT and Net::Server will handle the header negotiation for you.

Note: Net::Server::HTTP has no concept of document root or script aliases or default handling of static content. That is up to the consumer of Net::Server::HTTP to work out.

Net::Server::HTTP comes with a basic ENV display installed as the default process_request method.

"process_request"

This method has been overridden in Net::Server::HTTP − you should not use it while using Net::Server::HTTP. This method parses the environment and sets up request alarms and handles dying failures. It calls process_http_request once the request is ready.

"send_status"

Takes an HTTP status and a message. Sends out the correct headers.

"send_501"

Calls send_status with 501 and the argument passed to send_501.

COMMAND LINE ARGUMENTS

In addition to the command line arguments of the Net::Server base classes you can also set the following options.
max_header_size

Defaults to 100_000. Maximum number of bytes to read while parsing headers.

server_revision

Defaults to Net::Server::HTTP/$Net::Server::VERSION.

timeout_header

Defaults to 15 − number of seconds to wait for parsing headers.

timeout_idle

Defaults to 60 − number of seconds a request can be idle before the request is closed.

TODO

Add support for writing out HTTP/1 .1.

AUTHOR

Paul T. Seamons paul@seamons.com

THANKS

See Net::Server

SEE ALSO

Please see also Net::Server::Fork, Net::Server::INET, Net::Server::PreFork, Net::Server::PreForkSimple, Net::Server::MultiType, Net::Server::Single Net::Server::SIG Net::Server::Daemonize Net::Server::Proto

POD ERRORS

Hey! The above document had some coding errors, which are explained below:
Around line 292:

You forgot a ’=back’ before ’=head1’






Opportunity


Personal Opportunity - Free software gives you access to billions of dollars of software at no cost. Use this software for your business, personal use or to develop a profitable skill. Access to source code provides access to a level of capabilities/information that companies protect though copyrights. Open source is a core component of the Internet and it is available to you. Leverage the billions of dollars in resources and capabilities to build a career, establish a business or change the world. The potential is endless for those who understand the opportunity.

Business Opportunity - Goldman Sachs, IBM and countless large corporations are leveraging open source to reduce costs, develop products and increase their bottom lines. Learn what these companies know about open source and how open source can give you the advantage.





Free Software


Free Software provides computer programs and capabilities at no cost but more importantly, it provides the freedom to run, edit, contribute to, and share the software. The importance of free software is a matter of access, not price. Software at no cost is a benefit but ownership rights to the software and source code is far more significant.


Free Office Software - The Libre Office suite provides top desktop productivity tools for free. This includes, a word processor, spreadsheet, presentation engine, drawing and flowcharting, database and math applications. Libre Office is available for Linux or Windows.





Free Books


The Free Books Library is a collection of thousands of the most popular public domain books in an online readable format. The collection includes great classical literature and more recent works where the U.S. copyright has expired. These books are yours to read and use without restrictions.


Source Code - Want to change a program or know how it works? Open Source provides the source code for its programs so that anyone can use, modify or learn how to write those programs themselves. Visit the GNU source code repositories to download the source.





Education


Study at Harvard, Stanford or MIT - Open edX provides free online courses from Harvard, MIT, Columbia, UC Berkeley and other top Universities. Hundreds of courses for almost all major subjects and course levels. Open edx also offers some paid courses and selected certifications.


Linux Manual Pages - A man or manual page is a form of software documentation found on Linux/Unix operating systems. Topics covered include computer programs (including library and system calls), formal standards and conventions, and even abstract concepts.