Skip to content

Commit

Permalink
Wrote "description"
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryo Anazawa committed Dec 27, 2011
1 parent 4b633a9 commit a8449ac
Show file tree
Hide file tree
Showing 2 changed files with 96 additions and 1 deletion.
71 changes: 71 additions & 0 deletions README
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
NAME

Blosxom::Header - Missing interface to modify HTTP headers

SYNOPSIS

use Blosxom::Header;

my $header = Blosxom::Header->new();

$header->set(
type => 'text/html;',
status => '304',
cache_control => 'must-revalidate',
);
my $value = $header->get('status'); # 304 Not Modified
my $bool = $header->exists('cache_control'); # 1
my @keys = $header->keys(); # ('type', 'status', 'cache_control')

$header->remove('cache_control');
@keys = $header->keys(); # ('type', 'status')

$header->remove_all();
@keys = $header->keys(); # ()

DESCRIPTION

Blosxom, a weblog application, exports a global variable $header
which is a hash reference. This application passes $header CGI::header()
to generate HTTP headers.

When plugin writers modify HTTP headers, they must write as follows:

package foo;
$blosxom::header->{'-status'} = '304 Not Modified';

It's obviously bad practice. Blosxom misses the interface to modify
HTTP headers.

This module allows you to modify them in an object-oriented way.
If loaded, you might write as follows:

my $header = Blosxom::Header->new();
$header->set('status' => '304');

INSTALLATION

% perl Makefile.PL
% make
% make test

DEPENDENCIES

* Blosxom 2.1.2
* HTTP::Status

AUTHOR

Ryo Anazawa (r-anazawa@shochutairen.com)

LICENSE AND COPYRIGHT

Copyright (c) 2011 Ryo Anazawa. All rights reserved.

This module is free software; you can redistribute it and/or
modify it under the same terms as Perl itself. See L<perlartistic>.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

26 changes: 25 additions & 1 deletion lib/Blosxom/Header.pm
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ __END__
=head1 NAME
Blosxom::Header - Set HTTP headers in an object-oriented way
Blosxom::Header - Missing interface to modify HTTP headers
=head1 SYNOPSIS
Expand All @@ -100,6 +100,24 @@ Blosxom::Header - Set HTTP headers in an object-oriented way
=head1 DESCRIPTION
Blosxom, a weblog application, exports a global variable $header
which is a hash reference. This application passes $header CGI::header()
to generate HTTP headers.
When plugin writers modify HTTP headers, they must write as follows:
package foo;
$blosxom::header->{'-status'} = '304 Not Modified';
It's obviously bad practice. Blosxom misses the interface to modify
HTTP headers.
This module allows you to modify them in an object-oriented way.
If loaded, you might write as follows:
my $header = Blosxom::Header->new();
$header->set('status' => '304');
=head1 METHODS
=over 4
Expand All @@ -119,14 +137,20 @@ has a value.
=item $header->remove('foo', 'bar')
Deletes the specified elements from HTTP headers.
=item $header->set(%headers)
Set values of the specified HTTP headers.
=item $header->keys()
Returns a list of all the keys of HTTP headers.
=item $header->remove_all()
Deletes all the elements of HTTP headers.
=back
=head1 DIAGOSTICS
Expand Down

0 comments on commit a8449ac

Please sign in to comment.