=encoding utf-8 =head1 NAME =begin original HTTP::Config - Configuration for request and response objects =end original HTTP::Config - リクエストおよびレスポンスオブジェクトの構成 =head1 SYNOPSIS 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 => "http://www.example.com"); if (my @m = $c->matching($request)) { print "Yadayada\n" if $m[0]->{verbose}; } =head1 DESCRIPTION =begin original An C 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. =end original C オブジェクトは、リクエストまたはリクエスト/レスポンスの ペアに一致するエントリのリストです。 その目的は、リクエストまたはレスポンスオブジェクトを指定して検索できる 構成データを保持することです。 =begin original 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. =end original 各構成エントリはハッシュです。 一部のキーは、リクエスト/レスポンスオブジェクトの属性に対して起きる 一致を指定します。 その他のキーは、ユーザーデータの保持に使えます。 =begin original The following methods are provided: =end original 次のメソッドが用意されています: =over 4 =item $conf = HTTP::Config->new =begin original Constructs a new empty C object and returns it. =end original 新しい空の C オブジェクトを作成して返します。 =item $conf->entries =begin original Returns the list of entries in the configuration object. In scalar context returns the number of entries. =end original 構成オブジェクト内のエントリのリストを返します。 スカラコンテキストでは、エントリの数を戻します。 =item $conf->empty =begin original Return true if there are no entries in the configuration object. This is just a shorthand for C<< not $conf->entries >>. =end original 構成オブジェクトにエントリがない場合に真を返します。 これは C<< not $conf->entries >> の省略形です。 =item $conf->add( %matchspec, %other ) =item $conf->add( \%entry ) =begin original Adds a new entry to the configuration. You can either pass separate key/value pairs or a hash reference. =end original 新しいエントリを構成に追加します。 個別のキーと値のペアまたはハッシュリファレンスを渡すことができます。 =item $conf->remove( %spec ) =begin original Removes (and returns) the entries that have matches for all the key/value pairs in %spec. If %spec is empty this will match all entries; so it will empty the configuation object. =end original %spec 内のすべてのキー/値ペアに一致するエントリを削除して、それを返します。 %spec が空の場合、これはすべてのエントリに一致するため、 構成オブジェクトが空になります。 =item $conf->matching( $uri, $request, $response ) =item $conf->matching( $uri ) =item $conf->matching( $request ) =item $conf->matching( $response ) =begin original Returns the entries that match the given $uri, $request and $response triplet. =end original 指定された $uri, $request, $response の組み合わせに一致するエントリを 返します。 =begin original If called with a single $request object then the $uri is obtained by calling its 'uri_canonical' method. If called with a single $response object, then the request object is obtained by calling its 'request' method; and then the $uri is obtained as if a single $request was provided. =end original 単一の $request オブジェクトで呼び出された場合、 $uri は 'uri_canonical' メソッドを呼び出すことで 取得されます。 単一の $response オブジェクトで呼び出された場合、'request' メソッドを 呼び出すことでリクエストオブジェクトが取得され、単一の $request が 提供された場合と同様に $uri が取得されます。 =begin original The entries are returned with the most specific matches first. In scalar context returns the most specific match or C in none match. =end original エントリは、最も具体的に一致したものを最初に返します。 スカラコンテキストでは、最も具体的に一致したものを返します。 一致しない場合は C を返します。 =item $conf->add_item( $item, %matchspec ) =item $conf->remove_items( %spec ) =item $conf->matching_items( $uri, $request, $response ) =begin original Wrappers that hides the entries themselves. =end original エントリ自体を隠すラッパー。 =back =head2 Matching (一致) =begin original 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. =end original 構成エントリの次のキーは、一致を指定します。 これら全てに対して、単一の値ではなく値の配列を指定できます。 配列内の値の少なくとも一つが一致する場合、エントリは一致します。 =begin original Entries that require match against a response object attribute will never match unless a response object was provided. =end original レスポンスオブジェクト属性との一致を必要とする項目は、 レスポンスオブジェクトが提供されない限り一致しません。 =over =item m_scheme => $scheme =begin original Matches if the URI uses the specified scheme; e.g. "http". =end original URI が指定されたスキーム("http" など) を使う場合に一致します。 =item m_secure => $bool =begin original If $bool is TRUE; matches if the URI uses a secure scheme. If $bool is FALSE; matches if the URI does not use a secure scheme. An example of a secure scheme is "https". =end original $bool が真の場合、URI がセキュリティで保護されたスキームを使っている場合に 一致します。 $bool が偽の場合、URI がセキュリティで保護されたスキームを使っていない場合に 一致します。 セキュリティで保護されたスキームの例は "https" です。 =item m_host_port => "$hostname:$port" =begin original Matches if the URI's host_port method return the specified value. =end original URI の host_port メソッドが指定された値を返す場合に一致します。 =item m_host => $hostname =begin original Matches if the URI's host method returns the specified value. =end original URI の host メソッドが指定された値を返す場合に一致します。 =item m_port => $port =begin original Matches if the URI's port method returns the specified value. =end original URI の port メソッドが指定された値を返す場合に一致します。 =item m_domain => ".$domain" =begin original Matches if the URI's host method return a value that within the given domain. The hostname "www.example.com" will for instance match the domain ".com". =end original URI の host メソッドが、指定されたドメイン内の値を返す場合に一致します。 たとえば、ホスト名 "www.example.com" は、ドメイン ".com" と一致します。 =item m_path => $path =begin original Matches if the URI's path method returns the specified value. =end original URI の path メソッドが指定された値を返す場合に一致します。 =item m_path_prefix => $path =begin original Matches if the URI's path is the specified path or has the specified path as prefix. =end original URI のパスが指定されたパスである場合、または指定されたパスを 接頭辞として持つ場合に一致します。 =item m_path_match => $Regexp =begin original Matches if the regular expression matches the URI's path. Eg. qr/\.html$/. =end original 正規表現が URI のパスと一致する場合に一致します。 例: qr/\.html$/。 =item m_method => $method =begin original Matches if the request method matches the specified value. Eg. "GET" or "POST". =end original リクエストメソッドが指定された値と一致する場合に一致します。 例: "GET" や "POST"。 =item m_code => $digit =item m_code => $status_code =begin original Matches if the response status code matches. If a single digit is specified; matches for all response status codes beginning with that digit. =end original 応答ステータスコードが一致する場合に一致します。 1 桁が指定されている場合は、その桁で始まるすべての応答ステータスコードに 一致します。 =item m_proxy => $url =begin original Matches if the request is to be sent to the given Proxy server. =end original 要求が指定されたプロキシサーバに送信される場合に一致します。 =item m_media_type => "*/*" =item m_media_type => "text/*" =item m_media_type => "html" =item m_media_type => "xhtml" =item m_media_type => "text/html" =begin original Matches if the response media type matches. =end original レスポンスメディアタイプが一致する場合に一致します。 =begin original With a value of "html" matches if $response->content_is_html returns TRUE. With a value of "xhtml" matches if $response->content_is_xhtml returns TRUE. =end original "html" の値は、$response->content_is_html が真を返す場合に一致します。 "xhtml" の値は、$response->content_is_xhtml が真を返す場合に一致します。 =item m_uri__I<$method> => undef =begin original Matches if the URI object provides the method. =end original URI オブジェクトがこのメソッドを提供する場合に一致します。 =item m_uri__I<$method> => $string =begin original Matches if the URI's $method method returns the given value. =end original URI の $method メソッドが指定された値を返す場合に一致します。 =item m_header__I<$field> => $string =begin original Matches if either the request or the response have a header $field with the given value. =end original リクエストまたはレスポンスのいずれかに、指定された値を持つ ヘッダ $field がある場合に一致します。 =item m_response_attr__I<$key> => undef =item m_response_attr__I<$key> => $string =begin original Matches if the response object has that key, or the entry has the given value. =end original 応答オブジェクトにそのキーがある場合、またはエントリに 指定された値がある場合に一致します。 =back =head1 SEE ALSO L, L, L =head1 COPYRIGHT Copyright 2008, Gisle Aas This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =begin meta Translate: SHIRAKATA Kentaro Status: completed =end meta =cut