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;

  # OO interface
  my $header = Blosxom::Header->new('Content-Type' => 'text/html');
  $header->set(
    'Status'        => '304',
    'Cache-Control' => 'must-revalidate',
  );
  $header->remove('Cache-Control', 'Status');

  # As a reference to hash
  $header->{'Content-Type'} = 'text/plain';
  my $value = $header->{'Content-Type'};        # text/plain
  my $bool  = exists $header->{'Content-Type'}; # 1
  delete $header->{'Content-Type'};

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

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->{'Status'} = '304'; # will be autocompleted as '304 Not Modified'

METHODS

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

Creates a new Blosxom::Header object. If %headers were defined, existing headers would be overridden with them.

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

Deletes the specified elements from HTTP headers.

$header->set(%headers)

Set values of the specified HTTP headers.

DIAGNOSTICS

$blosxom::header hasn'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.

DEPENDENCIES

HTTP::Status, Blosxom 2.1.2

AUTHOR

Ryo Anazawa (anazawa@cpan.org)

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.