The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

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
  $header->remove('cache_control');

DESCRIPTION

Blosxom, a weblog application, exports a global variable $header which is a reference to hash. 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');

METHODS

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

Creates a new Blosxom::Header object.

$header->get('foo')

Returns a value of the specified HTTP header.

$header->exists('foo')

Returns a Boolean value telling whether the specified HTTP header has a value.

$header->remove('foo', 'bar')

Deletes the specified elements from HTTP headers.

$header->set(%headers)

Set values of the specified HTTP headers.

DIAGNOSTICS

$blosxom::header haven't been initialized yet.

You can't modify HTTP headers until Blosxom initializes $blosxom::header.

Unknown status code

The specified status code doesn't match any status codes defined by RFC2616.

  $header->set('status' => '123') # Unknown status code: 123

DEPENDENCIES

HTTP::Status, Blosxom 2.1.2

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 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.