368 lines
8.0 KiB
HTML
368 lines
8.0 KiB
HTML
|
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<HTML><HEAD><TITLE>Man page of HTTP::Config</TITLE>
|
|
</HEAD><BODY>
|
|
<H1>HTTP::Config</H1>
|
|
Section: User Contributed Perl Documentation (3pm)<BR>Updated: 2020-02-29<BR><A HREF="#index">Index</A>
|
|
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<A NAME="lbAB"> </A>
|
|
<H2>NAME</H2>
|
|
|
|
HTTP::Config - Configuration for request and response objects
|
|
<A NAME="lbAC"> </A>
|
|
<H2>VERSION</H2>
|
|
|
|
|
|
|
|
version 6.22
|
|
<A NAME="lbAD"> </A>
|
|
<H2>SYNOPSIS</H2>
|
|
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
use HTTP::Config;
|
|
my $c = HTTP::Config->new;
|
|
$c->add(m_domain => ".example.com", m_scheme => "http", verbose => 1);
|
|
|
|
use HTTP::Request;
|
|
my $request = HTTP::Request->new(GET => "<A HREF="http://www.example.com">http://www.example.com</A>");
|
|
|
|
if (my @m = $c->matching($request)) {
|
|
print "Yadayada\n" if $m[0]->{verbose};
|
|
}
|
|
|
|
</PRE>
|
|
|
|
|
|
<A NAME="lbAE"> </A>
|
|
<H2>DESCRIPTION</H2>
|
|
|
|
|
|
|
|
An <TT>"HTTP::Config"</TT> object is a list of entries that
|
|
can be matched against request or request/response pairs. Its
|
|
purpose is to hold configuration data that can be looked up given a
|
|
request or response object.
|
|
<P>
|
|
|
|
Each configuration entry is a hash. Some keys specify matching to
|
|
occur against attributes of request/response objects. Other keys can
|
|
be used to hold user data.
|
|
<P>
|
|
|
|
The following methods are provided:
|
|
<DL COMPACT>
|
|
<DT id="1">$conf = HTTP::Config->new<DD>
|
|
|
|
|
|
|
|
|
|
Constructs a new empty <TT>"HTTP::Config"</TT> object and returns it.
|
|
<DT id="2">$conf->entries<DD>
|
|
|
|
|
|
|
|
|
|
Returns the list of entries in the configuration object.
|
|
In scalar context returns the number of entries.
|
|
<DT id="3">$conf->empty<DD>
|
|
|
|
|
|
|
|
|
|
Return true if there are no entries in the configuration object.
|
|
This is just a shorthand for <TT>"not $conf->entries"</TT>.
|
|
<DT id="4">$conf->add( %matchspec, %other )<DD>
|
|
|
|
|
|
|
|
|
|
|
|
<DT id="5">$conf->add( \%entry )<DD>
|
|
|
|
|
|
|
|
|
|
|
|
Adds a new entry to the configuration.
|
|
You can either pass separate key/value pairs or a hash reference.
|
|
<DT id="6">$conf->remove( %spec )<DD>
|
|
|
|
|
|
|
|
|
|
Removes (and returns) the entries that have matches for all the key/value pairs in <TT>%spec</TT>.
|
|
If <TT>%spec</TT> is empty this will match all entries; so it will empty the configuration object.
|
|
<DT id="7">$conf->matching( $uri, $request, $response )<DD>
|
|
|
|
|
|
|
|
|
|
|
|
<DT id="8">$conf->matching( $uri )<DD>
|
|
|
|
|
|
|
|
|
|
<DT id="9">$conf->matching( $request )<DD>
|
|
|
|
|
|
|
|
|
|
<DT id="10">$conf->matching( $response )<DD>
|
|
|
|
|
|
|
|
|
|
|
|
Returns the entries that match the given <TT>$uri</TT>, <TT>$request</TT> and <TT>$response</TT> triplet.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
If called with a single <TT>$request</TT> object then the <TT>$uri</TT> is obtained by calling its 'uri_canonical' method.
|
|
If called with a single <TT>$response</TT> object, then the request object is obtained by calling its 'request' method;
|
|
and then the <TT>$uri</TT> is obtained as if a single <TT>$request</TT> was provided.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
The entries are returned with the most specific matches first.
|
|
In scalar context returns the most specific match or <TT>"undef"</TT> in none match.
|
|
<DT id="11">$conf->add_item( $item, %matchspec )<DD>
|
|
|
|
|
|
|
|
|
|
|
|
<DT id="12">$conf->remove_items( %spec )<DD>
|
|
|
|
|
|
|
|
|
|
<DT id="13">$conf->matching_items( $uri, $request, $response )<DD>
|
|
|
|
|
|
|
|
|
|
|
|
Wrappers that hides the entries themselves.
|
|
</DL>
|
|
<A NAME="lbAF"> </A>
|
|
<H3>Matching</H3>
|
|
|
|
|
|
|
|
The following keys on a configuration entry specify matching. For all
|
|
of these you can provide an array of values instead of a single value.
|
|
The entry matches if at least one of the values in the array matches.
|
|
<P>
|
|
|
|
Entries that require match against a response object attribute will never match
|
|
unless a response object was provided.
|
|
<DL COMPACT>
|
|
<DT id="14">m_scheme => $scheme<DD>
|
|
|
|
|
|
|
|
|
|
Matches if the <FONT SIZE="-1">URI</FONT> uses the specified scheme; e.g. ``http''.
|
|
<DT id="15">m_secure => $bool<DD>
|
|
|
|
|
|
|
|
|
|
If <TT>$bool</TT> is <FONT SIZE="-1">TRUE</FONT>; matches if the <FONT SIZE="-1">URI</FONT> uses a secure scheme. If <TT>$bool</TT>
|
|
is <FONT SIZE="-1">FALSE</FONT>; matches if the <FONT SIZE="-1">URI</FONT> does not use a secure scheme. An example
|
|
of a secure scheme is ``https''.
|
|
<DT id="16">m_host_port => "$hostname:$port"<DD>
|
|
|
|
|
|
|
|
|
|
Matches if the <FONT SIZE="-1">URI</FONT>'s host_port method return the specified value.
|
|
<DT id="17">m_host => $hostname<DD>
|
|
|
|
|
|
|
|
|
|
Matches if the <FONT SIZE="-1">URI</FONT>'s host method returns the specified value.
|
|
<DT id="18">m_port => $port<DD>
|
|
|
|
|
|
|
|
|
|
Matches if the <FONT SIZE="-1">URI</FONT>'s port method returns the specified value.
|
|
<DT id="19">m_domain => ".$domain"<DD>
|
|
|
|
|
|
|
|
|
|
Matches if the <FONT SIZE="-1">URI</FONT>'s host method return a value that within the given
|
|
domain. The hostname ``<A HREF="http://www.example.com">www.example.com</A>'' will for instance match the
|
|
domain ``.com''.
|
|
<DT id="20">m_path => $path<DD>
|
|
|
|
|
|
|
|
|
|
Matches if the <FONT SIZE="-1">URI</FONT>'s path method returns the specified value.
|
|
<DT id="21">m_path_prefix => $path<DD>
|
|
|
|
|
|
|
|
|
|
Matches if the <FONT SIZE="-1">URI</FONT>'s path is the specified path or has the specified
|
|
path as prefix.
|
|
<DT id="22">m_path_match => $Regexp<DD>
|
|
|
|
|
|
|
|
|
|
Matches if the regular expression matches the <FONT SIZE="-1">URI</FONT>'s path. Eg. qr/\.html$/.
|
|
<DT id="23">m_method => $method<DD>
|
|
|
|
|
|
|
|
|
|
Matches if the request method matches the specified value. Eg. ``<FONT SIZE="-1">GET''</FONT> or ``<FONT SIZE="-1">POST''.</FONT>
|
|
<DT id="24">m_code => $digit<DD>
|
|
|
|
|
|
|
|
|
|
|
|
<DT id="25">m_code => $status_code<DD>
|
|
|
|
|
|
|
|
|
|
|
|
Matches if the response status code matches. If a single digit is
|
|
specified; matches for all response status codes beginning with that digit.
|
|
<DT id="26">m_proxy => $url<DD>
|
|
|
|
|
|
|
|
|
|
Matches if the request is to be sent to the given Proxy server.
|
|
<DT id="27">m_media_type => "*/*"<DD>
|
|
|
|
|
|
|
|
|
|
|
|
<DT id="28">m_media_type => "text/*"<DD>
|
|
|
|
|
|
|
|
|
|
<DT id="29">m_media_type => "html"<DD>
|
|
|
|
|
|
|
|
|
|
<DT id="30">m_media_type => "xhtml"<DD>
|
|
|
|
|
|
|
|
|
|
<DT id="31">m_media_type => "text/html"<DD>
|
|
|
|
|
|
|
|
|
|
|
|
Matches if the response media type matches.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
With a value of ``html'' matches if <TT>$response</TT>->content_is_html returns <FONT SIZE="-1">TRUE.</FONT>
|
|
With a value of ``xhtml'' matches if <TT>$response</TT>->content_is_xhtml returns <FONT SIZE="-1">TRUE.</FONT>
|
|
<DT id="32">m_uri__<I></I>$method<I></I> => undef<DD>
|
|
|
|
|
|
Matches if the <FONT SIZE="-1">URI</FONT> object provides the method.
|
|
<DT id="33">m_uri__<I></I>$method<I></I> => $string<DD>
|
|
|
|
|
|
|
|
|
|
Matches if the <FONT SIZE="-1">URI</FONT>'s <TT>$method</TT> method returns the given value.
|
|
<DT id="34">m_header__<I></I>$field<I></I> => $string<DD>
|
|
|
|
|
|
|
|
|
|
Matches if either the request or the response have a header <TT>$field</TT> with the given value.
|
|
<DT id="35">m_response_attr__<I></I>$key<I></I> => undef<DD>
|
|
|
|
|
|
|
|
<DT id="36">m_response_attr__<I></I>$key<I></I> => $string<DD>
|
|
|
|
|
|
|
|
|
|
|
|
Matches if the response object has that key, or the entry has the given value.
|
|
</DL>
|
|
<A NAME="lbAG"> </A>
|
|
<H2>SEE ALSO</H2>
|
|
|
|
|
|
|
|
<FONT SIZE="-1">URI</FONT>, HTTP::Request, HTTP::Response
|
|
<A NAME="lbAH"> </A>
|
|
<H2>AUTHOR</H2>
|
|
|
|
|
|
|
|
Gisle Aas <<A HREF="mailto:gisle@activestate.com">gisle@activestate.com</A>>
|
|
<A NAME="lbAI"> </A>
|
|
<H2>COPYRIGHT AND LICENSE</H2>
|
|
|
|
|
|
|
|
This software is copyright (c) 1994-2017 by Gisle Aas.
|
|
<P>
|
|
|
|
This is free software; you can redistribute it and/or modify it under
|
|
the same terms as the Perl 5 programming language system itself.
|
|
<P>
|
|
|
|
<HR>
|
|
<A NAME="index"> </A><H2>Index</H2>
|
|
<DL>
|
|
<DT id="37"><A HREF="#lbAB">NAME</A><DD>
|
|
<DT id="38"><A HREF="#lbAC">VERSION</A><DD>
|
|
<DT id="39"><A HREF="#lbAD">SYNOPSIS</A><DD>
|
|
<DT id="40"><A HREF="#lbAE">DESCRIPTION</A><DD>
|
|
<DL>
|
|
<DT id="41"><A HREF="#lbAF">Matching</A><DD>
|
|
</DL>
|
|
<DT id="42"><A HREF="#lbAG">SEE ALSO</A><DD>
|
|
<DT id="43"><A HREF="#lbAH">AUTHOR</A><DD>
|
|
<DT id="44"><A HREF="#lbAI">COPYRIGHT AND LICENSE</A><DD>
|
|
</DL>
|
|
<HR>
|
|
This document was created by
|
|
<A HREF="/cgi-bin/man/man2html">man2html</A>,
|
|
using the manual pages.<BR>
|
|
Time: 00:05:45 GMT, March 31, 2021
|
|
</BODY>
|
|
</HTML>
|