CGI::Test::Page3pm
Abstract represention of an http reply content
Usage
# Deferred class, only heirs can be created# $page holds a CGI::Test::Page objectuse CGI::Test;ok 1, $page->is_ok;ok 2, $page->user ne ''; # authenticated accessmy $ctype = $page->content_type;ok 3, $ctype eq "text/plain";$page->delete;
Overview
The "CGI::Test::Page" class is deferred. It is an abstract representation of an HTTP reply content, which would be displayed on a browser, as a page. It does not necessarily hold HTML content.
Here is an outline of the class hierarchy tree, with the leading "CGI::Test::" string stripped for readability, and a trailing "*" indicating deferred clases:
Page*Page::ErrorPage::Real*Page::HTMLPage::OtherPage::Text
Those classes are constructed as needed by "CGI::Test". You must always call delete on them to break the circular references if you care about reclaiming unused memory.
Interface
This is the interface defined at the "CGI::Test::Page" level. Each subclass may add further specific features, but the following is available to the whole hierarchy:
- "content_type"
-
The MIME content type, along with parameters, as it appeared in the headers. For instance, it can be:
text/html; charset=ISO-8859-1Don't assume it to be just
"text/html"though. Use something like:ok 1, $page->content_type =~ m|^text/html\b|;in your regression tests, which will match whether there are parameters following the content type or not.
- "delete"
-
Breaks circular references to allow proper reclaiming of unused memory. Must be the last thing to call on the object before forgetting about it.
- "error_code"
-
The error code. Will be 0 to mean OK, but otherwise HTTP error codes are used, as described by HTTP::Status.
- "forms"
-
Returns a list reference containing all the CGI forms on the page, as
"CGI::Test::Form"objects. Will be an empty list for anything but"CGI::Test::Page::HTML", naturally.
- "form_count"
-
The amount of forms held in the
"forms"list.
- "is_error"
-
Returns true when the page indicates an HTTP error.
- "is_ok"
-
Returns true when the page is not the result of an HTTP error.
- "server"
-
Returns the server object that returned the page. Currently, this is the
"CGI::Test"object, but it might change one day. In any case, this is the place where GET/POST requests may be addresed.
- "user"
-
The authenticated user that requested this page, or
"undef"if no authentication was made.
Releases
5 releases since Debian 9 (Stretch); the text changed 2 times.