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

IDS::DataSource::HTTP

Introduction

This class is a subclass of IDS::DataSource, and meets its interface specification.

All real uses will be through subclasses.

We expect descendents to:

  • Whenever a string is loaded, parse then (no lazy evaluation). This is because *we* have the function to return the tokens.

  • Parameters relating to parsing are in the "params" entry, which is a hash reference. It is initialized here.

  • An optional initializer follows the parameters to new.

  • Elements of self:

    data

    the data that caused the parse that we have

    tokens

    The results of the parse

    params

    parameters that may affect parsing

  • The subclass must implement the following functions: parse, empty

load(source)

load exactly one request from a file, IO::Handle, or supplied string. If a string is used, it is up to the caller to ensure that more than one request is not in the string.

cleanup

Clean data to prepare for tokenizing.

read_session(filehandle)

Read an HTTP session (up to EOF or a blank line) from the filehandle passed as an argument.

read_next(filehandle)

Read the next request. We are expecting a list of files on the filehandle passed in. We will either read the next request from the from the currently-open file, or open the next file in the list, as needed.

data()

Return the data used for the tokens we have. If called in array mode, we return the individual lines, otherwise the join of those line.

postdata()

Return the data part of a POST request. Only has meaning in a POST request.

source() =item source(value)

Set and/or get the data source.

tokens()

Return the tokens that result from parsing the structure. The tokens can be returned as an array or a reference to the internal array holding them (for efficiency). Modify this referenced array at your own risk.

Note that this function can remove values. Note that this function can convert everything to lower case. Both of these options are controlled by parameters, and neither affects the internal version of the tokens.

expand_pct(data)

Expand the %-substitutions. This function currently does not handle unicode and &-expansions. Should it?

Functions required by IDS::DataSource

default_parameters()

Sets all of the default values for the parameters. Normally called by new() or one of its descendents.

param_options()

Command-line option specifiers for our parameters for GetOpt::Long.

alternate()

Try deleting lines and re-parsing. We have to keep track of state. Note that the various reading functions will reset the state.

This function returns either a new IDS::DataSource::HTTP object or undef. If called after it returns undef, it will start the process over.

AUTHOR INFORMATION

Copyright 2005-2007, Kenneth Ingham. All rights reserved.

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

Address bug reports and comments to: ids_test at i-pi.com. When sending bug reports, please provide the versions of IDS::Test.pm, IDS::Algorithm.pm, IDS::DataSource.pm, the version of Perl, and the name and version of the operating system you are using. Since Kenneth is a PhD student, the speed of the reponse depends on how the research is proceeding.

BUGS

Please report them.

SEE ALSO

IDS::Test, IDS::DataSource, IDS::Algorithm