NAME

HTTP::ProxyCheck - a class to check the functionality of HTTP proxy servers.

[ back to top ]


SYNOPSIS

    use HTTP::ProxyCheck;
    
    my $proxy       = 'proxy:8080';
    my $url         = 'http://search.cpan.org/';
    my $proxy_check = new HTTP::ProxyCheck(
        proxy       => $proxy,
        url         => $url,
        answer_size => 'header',
        print_error => 0,
    ) 
    or die $HTTP::ProxyCheck::error;
    
    print "Trying to connect to '$proxy' and retrieve '$url'\n";
    
    if ( $proxy_check->check() ) {
        print "'$proxy' returns:\n\n", $proxy_check->get_answer(), "\n\n";
    }
    else {
        print "Error: ", $proxy_check->get_error(), "\n";
    }

[ back to top ]


DESCRIPTION

HTTP::ProxyCheck is a class to check HTTP proxy servers. It connects to given HTTP proxy servers and tries to retrieve a provided URL through them.

[ back to top ]


CONSTRUCTOR

new( [attribute => $value, ...] )

new() is the HTTP::ProxyCheck object constructor.

If an error happens while constructing the object, use $HTTP::ProxyCheck::error to get the error message.

All named attributes of new() are optional.

Attributes

Return values

[ back to top ]


METHODS

check( [attribute => $value, ...] )

check() does the actual proxy server checking. It connects to a specified proxy server and tries to get a defined URL through it.

All named attributes of check() are optional, but proxy and url must be either set as object or method attribute.

Attributes

Return values

get_answer( )

get_answer() gets the most recent proxy server answer.

The proxy server answer is in the form specified by the answer_size attribute of the HTTP::ProxyCheck object or the check() method.

For more information see CONSTRUCTOR.

Return values

get_error( )

get_error() gets the most recent error message.

For more information see ERROR HANDLING.

Return values

get_proxy( )

get_proxy() gets the current value of the object attribute proxy.

Return values

set_proxy( $proxy )

set_proxy() sets the value of the object attribute proxy.

Attributes

Return values

get_check_proxy( )

get_check_proxy() gets the current value of the object attribute check_proxy.

Return values

set_check_proxy( $check )

set_check_proxy sets the object attribute check_proxy.

Attributes

Return values

get_url( )

get_url() gets the current value of the object attribute url.

Return values

set_url( $url )

set_url sets the object attribute url.

Attributes

Return values

get_check_url( )

get_check_url() gets the current value of the object attribute check_url.

Return values

set_check_url( $check )

set_check_url sets the object attribute check_url.

Attributes

Return values

get_answer_size( )

get_answer_size() gets the current value of the object attribute answer_size.

Return values

set_answer_size( $answer_size )

set_answer_size sets the object attribute answer_size.

Attributes

Return values

[ back to top ]


ERROR HANDLING

HTTP::ProxyCheck has a highly configurable error handling system. It is configured with the attributes verbose_errors, print_error and raise_error at object creation:

    my $proxy_check = new HTTP::ProxyCheck(
        proxy          => 'proxy:8080',
        url            => 'http://search.cpan.org',
        verbose_errors => 1,
        print_error    => 0,
        raise_error    => 1,
    );

Every time you call a method of HTTP::ProxyCheck and an error happens, which means the method returns undef, the error message can be retrieved with get_error() or $HTTP::ProxyCheck::error:

    $proxy_check->set_answer_size( 'full' )
      or die $proxy_check->get_error();
    
    $proxy_check->check()
      or die $HTTP::ProxyCheck::error;

If there's an error during the object construction, you can't get the error message through get_error(). Use $HTTP::ProxyCheck::error instead:

    my $proxy_check = new HTTP::ProxyCheck( proxy => 'proxy' )
      or die $HTTP::ProxyCheck::error;

The object attribute verbose_errors configures the verbosity of the error message. Set verbose_errors => 1 to enable verbose error messages and verbose_errors => 0 to disable verbose error messages.

Verbose error messages look like this:

    $method failed: $error_message

And non-verbose error messages like this:

    $error_message

The default value of verbose_errors is 0.

With print_error and raise_error you can set the degree of automation of the error handling.

If print_error is set to 1, the error message is displayed with Carp::carp(). Set print_error to 0 to disable this feature.

If raise_error is set to 1, the error message is displayed with Carp::croak() and the program is brought to an end. If raise_error is set to 0, this feature is disabled.

The default value of print_error is 1 and of raise_error it is 0.

[ back to top ]


SUPPORT

Contact the AUTHOR.

[ back to top ]


BUGS

Unknown

[ back to top ]


VERSION

    HTTP::ProxyCheck version 1.2

[ back to top ]


CHANGES

    1.4 Thu May 25 10:47:42 CEST 2006
        - Added installation instructions to README
    
    1.3 Sun May  7 11:51:50 CEST 2006
        - Charles Longeau <chl attuxfamily dot org> made a small patch to 
          specify the user agent, instead of a fixed "HTTP::ProxyCheck/$VERSION"
          one.
    
    1.2 Sat May  8 09:38:02 CEST 2004
        - Fix to unset the error message of a previous IO::Socket::INET run
          Thanks to Ben Schnopp <ben at schnopp dot com>
    
    
    1.1 Tue Aug 12 19:45:00 CEST 2003
        - rewrote the module
        - added better error handling
        - updated POD
    
    1.0  Fri Feb 21 17:09:32 CET 2003
        - gone stable after detailed testing 
        - updated POD (synopsis)
    
    0.2  Fri Feb 21 11:57:43 CET 2003
        - added check(answer => $type)
        - renamed methods to gain more consistency
        - updated POD (synopsis, methods)
    
    0.1  Wed Feb  5 14:35:25 CET 2003
        - original version

[ back to top ]


AUTHOR

    Thomas Weibel
    cpan@beeblebrox.net
    http://beeblebrox.net/

[ back to top ]


COPYRIGHT

Copyright (c) 2004 - 2006 Thomas Weibel. All rights reserved.

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

[ back to top ]