Blosxom::Header::ja - 一意に HTTP ヘッダを指定する
use Blosxom::Header; my $header = Blosxom::Header->instance; $header->set( Status => '304 Not Modified', Last_Modified => 'Wed, 23 Sep 2009 13:36:33 GMT', ); my $status = $header->get( 'Status' ); my $bool = $header->exists( 'ETag' ); my @deleted = $header->delete( qw/Content-Disposition Content-Length/ ); $header->push_cookie( @cookies ); $header->push_p3p( @p3p ); $header->clear;
ブロッサムは単一の CGI スクリプトとして動作する、 ウェブログ・アプリケーションの一つである。 このアプリケーションは、$header というハッシュのリファレンスをグローバル化する。 $header は CGI モジュールの header() 関数に渡され、HTTP ヘッダを生成する。
$header
header()
package blosxom; use CGI; our $header = { -type => 'text/html' }; # プラグインを読み込む print CGI::header( $header );
header() は $header のキーについて、大文字と小文字を区別しない。 また、キーの先頭にハイフンを付加するかどうかも任意だ。 他方、ハッシュのキーは大文字と小文字を区別する。 したがって、複数のプラグインが共存するような状況では、一意に $header を操作することができない。
Blosxom::Header インスタンスを返す。インスタンスが存在しなければ、 新たに作成する。
$blosxom::header が初期化されているとき、真を返す。 初期化されていないとき、偽を返す。 Blosxom は blosxom::generate() を呼ぶ直前に、この変数を初期化する。 $bool が偽のとき、下記のメソッドは例外を投げる。
$blosxom::header
blosxom::generate()
$bool
$field で指定したフィールドに、$value を代入する。 フィールド名は大文字と小文字を区別しない。 またハイフンの代わりに、アンダーバーを使うこともできる。
$value は基本的に文字列をとる。 特に、フィールド名として Set-Cookie あるいは P3P を指定したとき、リストのリファレンスをとる。
Set-Cookie
P3P
$header->set( Set_Cookie => [ $cookie1, $cookie2 ] ); $header->set( P3P => [ qw/CAO DSP LAW CURa/ ] );
引数としてフィールド名をとり、文字列を返す。 フィールドが存在しなければ undef を返す。 また、リスト・コンテキストで、リストを返す。
undef
my @cookie = $header->get( 'Set-Cookie' ); my @p3p = $header->get( 'P3P' );
引数としてフィールド名をとり、フィールドが存在するとき真を返す。 存在しないとき偽を返す。
指定したフィールドをすべて削除する。 削除したフィールドの値を返す。
Set-Cookie ヘッダを追加する。
P3P タグを追加する。
すべてのフィールドを削除する。
以下のメソッドは、引数をつけたとき set()、つけないとき get() として働く。
set()
get()
$header->attachment( 'foo.png' );
文字セットを指定する。$header->type に charset が含まれている場合、 この属性は無視される。
$header->type
charset
$header->charset( 'utf-8' );
$header->cookie( [ 'foo', 'bar' ] ); $header->cookie( 'baz' );
$header->expires( '+30s' ); # 30 秒後 $header->expires( '+10m' ); # 10 分後 $header->expires( '+1h' ); # 1 時間後 $header->expires( '-1d' ); # 昨日 $header->expires( 'now' ); # 現在 $header->expires( '+3M' ); # 3ヶ月後 $header->expires( '+10y' ); # 10 年後 # at the indicated time & date $header->expires( 'Thu, 25 Apr 1999 00:40:33 GMT' );
$header->nph( 1 );
$header->p3p( [ qw/CAO DSP LAW CURa/ ] ); $header->p3p( 'CAO DSP LAW CURa' );
$header->status( '304' );
$header->target( 'ResultsWindow' );
メディア・タイプを指定する。
$header->type( 'text/plain' );
この属性が undef の場合、CGI::header() がデフォルトの Content-Type ヘッダを 出力する。Content-Type ヘッダを出力したくない場合、空の文字列を代入 しなければならない。
CGI::header()
$header->type( q{} );
Blosxom 2.0.0 or higher.
Blosxom::Header::Proxy, CGI, Class::Singleton
穴澤亮 (anazawa@cpan.org)
Perl Artistic ライセンスに準ずる。
To install Blosxom::Header, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Blosxom::Header
CPAN shell
perl -MCPAN -e shell install Blosxom::Header
For more information on module installation, please visit the detailed CPAN module installation guide.