The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

SWISH::Prog::Headers - create document headers for Swish-e -S prog

SYNOPSIS

  use SWISH::Prog::Headers;
  use File::Slurp;
  my $f = 'some/file.html';
  my $buf = read_file( $f ):
  
  print SWISH::Prog::Headers->head( $buf, { url=>$f } ), $buf;

DESCRIPTION

SWISH::Prog::Headers generates the correct headers for feeding documents to the Swish-e indexer.

VARIABLES

$AutoURL

The $AutoURL package variable is used when no URL is supplied in the head() method. It is incremented each time it is used in head(). You can set it to whatever numerical value you choose. It defaults to $^T.

$Debug

Set to TRUE to carp verbage about content length, etc.

METHODS

There is one class method available.

head( buf [, \%opts ] )

Returns scalar string of proper headers for a document.

The only required parameter is buf, which should be the content of the document as a scalar string.

The following keys are supported in %opts. If not supplied, they will be guessed at based on the contents of buf.

url

The URL or file path of the document. If not supplied, a guaranteed unique numeric value will be used, based on the start time of the calling script.

modtime

The last modified time of the document in epoch seconds (time() format). If not supplied, the current time() value is used.

parser

The parser type to be used for the document. If not supplied, it will not be included in the header and Swish-e will determine the parser type. See the Swish-e configuration documentation on determining parser type. See also the SWISH::Prog parser() method.

type

The MIME type of the document. If not supplied, it will be guessed at based on the file extension of the URL (if supplied) or $DefMime. NOTE: MIME type is only used in SWISH::Parser headers.

update

If Swish-e is in incremental mode (which must be indicated by setting the increm parameter in new()), this value can be used to set the update mode for the document.

swishp

Set to TRUE to use SWISH::Parser header labels (including Content-Type).

NOTE: The special environment variable SWISHP is checked in order to determine the correct header labels. If you are using SWISH::Parser, you must set that environment variable, or pass the swishp option.

Headers API

See the Swish-e documentation at http://swish-e.org/.

For SWISH::Parser Headers API (which is slightly different) see http://swishparser.peknet.com/.

SEE ALSO

SWISH::Prog, SWISH::Parser

AUTHOR

Peter Karman, <perl@peknet.com>

COPYRIGHT AND LICENSE

Copyright 2006 by Peter Karman

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.