HTTP::Server::Simple::CGI(3) User Contributed Perl Documentation HTTP::Server::Simple::CGI(3)

# [NAME](#NAME)

HTTP::Server::Simple::CGI - CGI.pm-style version of HTTP::Server::Simple

# [DESCRIPTION](#DESCRIPTION)

HTTP::Server::Simple was already simple, but some smart-ass pointed out that there is no CGI in HTTP, and so this module was born to isolate the CGI.pm-related parts of this handler.

## [accept\_hook](#accept_hook)

The accept\_hook in this sub-class clears the environment to the start-up state.

## [post\_setup\_hook](#post_setup_hook)

Initializes the global CGI object, as well as other environment settings.

## [cgi\_class \[Classname\]](#cgi_class__Classname_)

Gets or sets the class to use for creating the $cgi object passed to "handle\_request".

Called with a single argument, it sets the coderef. Called with no arguments, it returns this field's current value.

To provide an initialization subroutine to be run in the post\_setup\_hook, see "cgi\_init".

e.g.

```
    $server->cgi_class('CGI');
    $server->cgi_init(sub {
        require CGI;
        CGI::initialize_globals();
    });
```

or, if you want to use CGI::Simple,

```
    $server->cgi_class('CGI::Simple');
    $server->cgi_init(sub {
        require CGI::Simple;
    });
```

## [cgi\_init \[CODEREF\]](#cgi_init__CODEREF_)

A coderef to run in the post\_setup\_hook.

Called with a single argument, it sets the coderef. Called with no arguments, it returns this field's current value.

## [setup](#setup)

This method sets up CGI environment variables based on various meta-headers, like the protocol, remote host name, request path, etc.

See the docs in HTTP::Server::Simple for more detail.

## [handle\_request CGI](#handle_request_CGI)

This routine is called whenever your server gets a request it can handle.

It's called with a CGI object that's been pre-initialized. You want to override this method in your subclass

## [handler](#handler)

Handler implemented as part of HTTP::Server::Simple API

2026-09-06 perl v5.44.0

---

Document: HTTP::Server::Simple::CGI(3pm) from perl-http-server-simple 0.52-r3 (Chainguard OS)
Source: https://github.com/bestpractical/http-server-simple.git
