develooper Front page | perl.libwww | Postings from November 2001

keep alive update

Thread Next
From:
Bill Moseley
Date:
November 8, 2001 11:24
Subject:
keep alive update
Message ID:
3.0.3.32.20011108112341.006e7198@pop3.hank.org
Looking at some older code I see I was jumping through hoops for keep alives.

What I want is a way to nicely handle the situation where keep alive
support isn't available for the current LWP installation.

    if ( $server->keep_alive ) {

        eval 'require LWP::Protocol::http11;';
        if ( $@ ) {
            warn "Cannot use keep alives -- $@\n";
        } else {
            LWP::Protocol::implementor('http', 'LWP::Protocol::http11');
        }
    } else {
        require LWP::Protocol::http;
        LWP::Protocol::implementor('http', 'LWP::Protocol::http');
    }

Also, how can I report the number of connections?  I'd like to see how many
connections compared to number of requests.  Also, how do I determine how
large to set the connection cache?  

For example, say I'm spidering my own site, so I want keep_alive set.  I'm
also validating links to our image server, so I want keep alive's there.
I'm also validating links to remote sites, where I don't really need keep
alives.

Thanks,



Bill Moseley
mailto:moseley@hank.org

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About