Result:
found more than 867 distributions - search limited to the first 2001 files matching your query ( run in 1.660 )


HTML-TagReader

 view release on metacpan or  search on metacpan

bin/tr_httpcheck.PL  view on Meta::CPAN

Connection: close
Content-Type: text/html
  
HTTP/1.1 200 OK
Server: Apache/1.3.0 (Unix) Debian/GNU PHP/3.0
Keep-alive: timeout=20, max=100
Content-type: text/html
Date: Wed, 05 May 1999 07:10:30 GMT

HTTP/1.1 301 Moved Permanently
Date: Thu, 13 May 1999 16:27:55 GMT

 view all matches for this distribution


HTML-Template-Pro

 view release on metacpan or  search on metacpan

procore.c  view on Meta::CPAN

   * we use it to calculate filepath for filename.
   * Then filename becames upper level template for its <include>.
   */
  const char* filepath=(param->FindFileFuncPtr)(param->ext_findfile_state,filename, param->masterpath);
  if (NULL==filepath) return ERR_PRO_FILE_NOT_FOUND;
  /* filepath should be alive for every nested template */
  filepath = strdup(filepath);
  if (NULL==filepath) return ERR_PRO_NOT_ENOUGH_MEMORY;
  saved_masterpath=param->masterpath; /* saving current file name */
  param->masterpath=filepath;
  if (param->filters) memarea=(param->LoadFileFuncPtr)(param->ext_filter_state,filepath);

 view all matches for this distribution


HTTP-AnyUA

 view release on metacpan or  search on metacpan

t/23-content-coderef.t  view on Meta::CPAN


    my $ua      = shift;
    my $any_ua  = HTTP::AnyUA->new(ua => $ua, response_is_future => 1);

    if ($ua->isa('Mojo::UserAgent')) {
        # disable keep-alive to avoid Mojo::Reactor::EV warnings
        $ua->max_connections(0);
    }

    my $chunk   = 0;
    my @chunk   = ('some ', 'document');

 view all matches for this distribution


HTTP-Balancer

 view release on metacpan or  search on metacpan

lib/HTTP/Balancer/Actor/Nginx.pm  view on Meta::CPAN

    access_log off;
    error_log  off;

    sendfile        on;

    keepalive_timeout  65;
    tcp_nodelay        on;

    gzip  on;
    gzip_disable "MSIE [1-6]\.(?!.*SV1)";

 view all matches for this distribution


HTTP-ClickHouse-Base

 view release on metacpan or  search on metacpan

lib/HTTP/ClickHouse/Base.pm  view on Meta::CPAN

        host        => '127.0.0.1',
        port        => 8123,
        database    => 'default',
        user        => undef,
        password    => undef,
        keep_alive  => 1,
        nb_timeout  => 25,
        debug       => 0
    );
    foreach my $_key ( keys %_attrs ) {
        unless ($self->{$_key}){

 view all matches for this distribution


HTTP-ClickHouse

 view release on metacpan or  search on metacpan

lib/HTTP/ClickHouse.pm  view on Meta::CPAN

    port       => 8123,                        # optional, default value 8123
    user       => 'Harry',                     # optional, default value 'default'
    password   => 'Alohomora',                 # optional
    database   => 'database_name',             # optional, default name "default"         
    nb_timeout => 10                           # optional, default value 25 second
    keep_alive => 1                            # optional, default 1 (1 or 0)
    debug      => 1                            # optional, default 0

=cut

sub new {

lib/HTTP/ClickHouse.pm  view on Meta::CPAN


    $self->{socket} = Net::HTTP::NB->new(
        Host        => $self->{host},
        PeerPort    => $self->{port},
        HTTPVersion => '1.1',
        KeepAlive   => $self->{keep_alive}
    ) or carp "Error. Can't connect to ClickHouse host: $!";
}

sub uri {
    my $self = shift;

lib/HTTP/ClickHouse.pm  view on Meta::CPAN


=cut

sub disconnect {
    my $self = shift;
    $self->{socket}->keep_alive(0) if ($self->{socket});
    $self->_ping();
}


=head1 SEE ALSO

 view all matches for this distribution


HTTP-ClientDetect

 view release on metacpan or  search on metacpan

lib/Interchange6/Plugin/Interchange5/Request.pm  view on Meta::CPAN


=item  forwarded_host

=item  host

=item  keep_alive

=item  path_info

=item  referer

lib/Interchange6/Plugin/Interchange5/Request.pm  view on Meta::CPAN


sub forwarded_host { return shift->environment("forwarded_host") }

sub host { return shift->environment("host") }

sub keep_alive { return shift->environment("keep_alive") }

sub path_info { return shift->environment("path_info") }

sub referer { return shift->environment("referer") }

 view all matches for this distribution


HTTP-DAV

 view release on metacpan or  search on metacpan

lib/HTTP/DAV/Resource.pm  view on Meta::CPAN

    $headers->header('If', $if1) if $if1;

    # See from RFC 12.12.
    # Valid values for '$text':
    #
    #    <D:keepalive>*</D:keepalive>
    # or
    #    <D:keepalive>
    #       <D:href>...url1...</D:href>
    #       <D:href>...url2...</D:href>
    #    </D:keepalive>
    # or
    #    <D:omit/>
    #
    my $xml_request;
    if ($text) {

 view all matches for this distribution


HTTP-Daemon-App

 view release on metacpan or  search on metacpan

README  view on Meta::CPAN

    if ($proto >= $HTTP_1_1) {
        ${*$self}{'httpd_nomore'}++ if $conn && lc($conn) =~ /\bclose\b/;
    }
    else {
        ${*$self}{'httpd_nomore'}++ unless $conn &&
          lc($conn) =~ /\bkeep-alive\b/;
    }

    if ($only_headers) {
        ${*$self}{'httpd_rbuf'} = $buf;
        return $r;

 view all matches for this distribution


HTTP-Daemon-Threaded

 view release on metacpan or  search on metacpan

lib/HTTP/Daemon/Threaded/WebClient.pm  view on Meta::CPAN

=begin classdoc

Handles a socket event. Accumulates a client request, parses it,
and then dispatches to the associated URL handler. Only a single
client request is handled, but the connection may be retained
indefinitely (for HTTP 1.1 Connection: keepalive clients).

@param $fd	the HTTP::Daemon::Threaded::Socket object on which the event occured

@return		the object

 view all matches for this distribution


HTTP-Daemon

 view release on metacpan or  search on metacpan

lib/HTTP/Daemon.pm  view on Meta::CPAN

    if ($proto >= $HTTP_1_1) {
        ${*$self}{'httpd_nomore'}++ if $conn && lc($conn) =~ /\bclose\b/;
    }
    else {
        ${*$self}{'httpd_nomore'}++
            unless $conn && lc($conn) =~ /\bkeep-alive\b/;
    }

    if ($only_headers) {
        ${*$self}{'httpd_rbuf'} = $buf;
        return $r;

 view all matches for this distribution


HTTP-Engine-Middleware

 view release on metacpan or  search on metacpan

lib/HTTP/Engine/Middleware.pm  view on Meta::CPAN

        unless ($res) {
            $self->diecatch(0);
            local $@;
            eval {
                $res = $handle->($req);
                $self->diecatch(0); # yes! i'm still alive!
            };
            $msg = $@ if !$self->diecatch && $@;
        }
        die $msg if $msg;
        for my $instance (reverse @run_middlewares) {

 view all matches for this distribution


HTTP-Engine

 view release on metacpan or  search on metacpan

examples/dumper.pl  view on Meta::CPAN

    interface => {
        module  => 'Standalone',
        args => {
            port    => 9999,
            fork    => 1,
            keepalive => 1,
        },
        request_handler => sub {
            my $req = shift;
            local $Data::Dumper::Sortkeys = 1;
            die "OK!" if ($req->body_params->{'foo'} || '') eq 'ok';

 view all matches for this distribution


HTTP-Handy

 view release on metacpan or  search on metacpan

t/0004-server.t  view on Meta::CPAN

($st) = http_req(path => '/die');
like($st, qr{^HTTP/1\.0 500}, 'app die -> 500');

# ok 13: server continues to accept requests after an app die
($st) = http_req(path => '/hello');
like($st, qr{^HTTP/1\.0 200}, 'alive after die');

# ok 14: unsupported method returns 405
($st) = http_req(method => 'DELETE', path => '/hello');
like($st, qr{^HTTP/1\.0 405}, 'DELETE -> 405');

 view all matches for this distribution


HTTP-HeaderParser-XS

 view release on metacpan or  search on metacpan

lib/HTTP/HeaderParser/XS.pm  view on Meta::CPAN


=head1 SYNOPSIS

  use HTTP::HeaderParser::XS;

  my $hdr = HTTP::HeaderParser::XS->new( \"GET / HTTP/1.0\r\nConnection: keep-alive\r\nHost: www.bar.com\r\n\r\n" );

  if ( $hdr->isResponse ) {
    # this is not a response in this simple demo, but it could be
    print "Response code: " . $hdr->getStatusCode . "\n";
    print "Connection header: " . $hdr->getHeader( 'Connection' ) . "\n";

 view all matches for this distribution


HTTP-Lint

 view release on metacpan or  search on metacpan

t/lint.t  view on Meta::CPAN

RES
	bless (['HTTP/1.1 non-close response without given size',
		[19, 6, 2]], 'HTTP::Lint::Error'),
	bless (['Missing Date header',
		[14, 18]], 'HTTP::Lint::Warning')
], 'Bad keepalive');

cmp_deeply ([http_lint (transaction (<<REQ, <<RES))], [
POST /trololo\r
Host: Wololo\r
Accept: text/plain\r

 view all matches for this distribution


HTTP-LoadGen

 view release on metacpan or  search on metacpan

lib/HTTP/LoadGen.pm  view on Meta::CPAN

	  push @h, $hdr->[$i], $hdr->[$i+1] if exists $keep{lc $hdr->[$i]};
	}
      }

      return ['GET', $scheme, $host, $port, $uri,
	      {keepalive=>KEEPALIVE, followed=>1, headers=>\@h}];
    }
  }
}

BEGIN {

 view all matches for this distribution


HTTP-MultiGet

 view release on metacpan or  search on metacpan

lib/HTTP/MultiGet.pm  view on Meta::CPAN

  } else {
    $req=$obj;
    my $code=$self->que_function($req,$id);
    $opt->{cb}=$code;
  }
  foreach my $key (qw(keepalive persistent)) {
    $opt->{params}->{$key}=0 unless exists $opt->{params}->{$key};
  }
  my $request=$self->SENDER_CLASS->new(
    $req,
    $opt,

 view all matches for this distribution


HTTP-Parser-XS

 view release on metacpan or  search on metacpan

picohttpparser/bench.c  view on Meta::CPAN


#include <assert.h>
#include <stdio.h>
#include "picohttpparser.h"

#define REQ "GET /wp-content/uploads/2010/03/hello-kitty-darth-vader-pink.jpg HTTP/1.1\r\nHost: www.kittyhell.com\r\nUser-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; ja-JP-mac; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3 Pathtraq/0.9\r\nAccep...

int main(void)
{
  const char* method;
  size_t method_len;

 view all matches for this distribution


HTTP-Parser2-XS

 view release on metacpan or  search on metacpan

eg/example1.pl  view on Meta::CPAN

use HTTP::Parser2::XS;

{
    my $buf = "GET /a%20s?foo=bar HTTP/1.0\x0d\x0a".
              "Host: localhost\x0d\x0a".
              "Connection: keep-alive\x0d\x0a".
              "\x0d\x0a";

    my $r = {};
    my $rv = parse_http_request($buf, $r);

eg/example1.pl  view on Meta::CPAN

        request_uri  = "$r->{'_request_uri'}"
        uri          = "$r->{'_uri'}"
        query_string = "$r->{'_query_string'}"
        protocol     = "$r->{'_protocol'}"

        keepalive    = $r->{'_keepalive'}
        
        END
    }

};

eg/example1.pl  view on Meta::CPAN


        protocol     = "$r->{'_protocol'}"
        status       = "$r->{'_status'}"
        message      = "$r->{'_message'}"

        keepalive    = $r->{'_keepalive'}
        
        END
    }


 view all matches for this distribution


HTTP-Promise

 view release on metacpan or  search on metacpan

lib/HTTP/Promise.pm  view on Meta::CPAN

    my $headers = $self->default_headers;
    if( $headers )
    {
        unless( $self->connection_header )
        {
            my $connection_header = 'keep-alive';
            if( $headers->exists( 'connection' ) )
            {
                $connection_header = $headers->get( 'connection' );
            }
            $self->{connection_header} = $connection_header;

lib/HTTP/Promise.pm  view on Meta::CPAN

            close( $sock );
            undef( $sock );
        }
        else
        {
            $p->{in_keepalive} = 1;
        }
    }
    if( !$p->{in_keepalive} )
    {
        if( $proxy )
        {
            # my( undef, $proxy_user, $proxy_pass, $proxy_host, $proxy_port, undef) = $self->_parse_url($proxy);
            return( $self->error( "Proxy set '$proxy' (", overload::StrVal( $proxy ), ") is not URI object." ) ) if( !$self->_is_a( $proxy => 'URI' ) );

lib/HTTP/Promise.pm  view on Meta::CPAN

        {
            $connection_header = 'close';
        }
        elsif( $req->version && $req->version > 1.0 )
        {
            $connection_header = 'keep-alive';
        }
        else
        {
            $connection_header = 'close';
        }

lib/HTTP/Promise.pm  view on Meta::CPAN

    {
        $n = $io->read( $buff, 2048, length( $buff ) );
        if( !defined( $n ) || $n == 0 )
        {
            my $code = defined( $n ) ? '' : $io->error->code;
            if( $p->{in_keepalive} && 
                ( length( $buff ) // 0 ) == 0 &&
                !$opts->{total_attempts} &&
                ( defined( $n ) || $code == ECONNRESET || ( $IS_WIN32 && $code == ECONNABORTED ) ) )
            {
                # the server closed the connection (maybe because of keep-alive timeout)
                $opts->{total_attempts}++;
                return( $self->send( $req, %$opts ) );
            }
            elsif( !length( $buff ) )
            {

lib/HTTP/Promise.pm  view on Meta::CPAN

        return( $self->pass_error ) if( !defined( $body ) );
        $total_bytes_read += $body->length;
        $ent->body( $body );
    }

    # manage connection cache (i.e. keep-alive)
    if( defined( $connection_header ) && 
        lc( $connection_header ) eq 'keep-alive' )
    {
        my $connection = $headers->connection->lc // '';
        if( ( $def->{version} > 1.0
             ? $connection ne 'close'      # HTTP/1.1 can keep alive by default
             : $connection eq 'keep-alive' # HTTP/1.0 needs explicit keep-alive
            ) && ( defined( $content_length ) or $chunked ) )
        {
            my $sock = $io->filehandle;
            $self->_pool->push( $uri->host, $uri->port, $sock ) ||
                return( $self->pass_error );

lib/HTTP/Promise.pm  view on Meta::CPAN


The size of the buffer to use when reading data from the filehandle or socket.

=head2 connection_header

Sets or gets the value for the header C<Connection>. It can be C<close> or C<keep-alive>

If it is let C<undef>, this module will try to guess the proper value based on the L<HTTP::Promise::Request/protocol> and L<HTTP::Promise::Request/version> used.

For protocol C<HTTP/1.0>, C<Connection> value would be C<close>, but above C<HTTP/1.1> the connection can be set to C<keep-alive> and thus be re-used.

=head2 cookie_jar

Sets or gets the Cookie jar class object to use. This is typically L<Cookie::Jar> or maybe L<HTTP::Cookies>

 view all matches for this distribution


HTTP-Proxy-Selective

 view release on metacpan or  search on metacpan

script/selective_proxy  view on Meta::CPAN

    port                    => 3128,
    max_clients             => 10,
    max_requests_per_child  => 100,
    min_spare_servers       => 1,
    max_spare_servers       => 5,
    keep_alive              => 0,
    max_keep_alive_requests => 1,
    keep_alive_timeout      => 60,
    engine                  => 'NoFork',
);

sub _generate_proxy_config {
    my %in_params = @_;

 view all matches for this distribution


HTTP-Proxy

 view release on metacpan or  search on metacpan

lib/HTTP/Proxy.pm  view on Meta::CPAN

        daemon   => undef,
        host     => 'localhost',
        logfh    => *STDERR,
        logmask  => NONE,
        max_connections => 0,
        max_keep_alive_requests => 10,
        port     => 8080,
        stash    => {},
        timeout  => 60,
        via      => undef,
        x_forwarded_for => 1,

lib/HTTP/Proxy.pm  view on Meta::CPAN

    # support for deprecated stuff
    {
        my %convert = (
            maxchild => 'max_clients',
            maxconn  => 'max_connections',
            maxserve => 'max_keep_alive_requests',
        );
        while( my ($old, $new) = each %convert ) {
            if( exists $params{$old} ) {
               $params{$new} = delete $params{$old};
               carp "$old is deprecated, please use $new";

lib/HTTP/Proxy.pm  view on Meta::CPAN


# normal accessors
for my $attr ( qw(
    agent chunk daemon host logfh port request response hop_headers
    logmask via x_forwarded_for client_headers engine
    max_connections max_keep_alive_requests
    )
  )
{
    no strict 'refs';
    *{"HTTP::Proxy::$attr"} = sub {

lib/HTTP/Proxy.pm  view on Meta::CPAN

# deprecated methods are still supported
{
    my %convert = (
        maxchild => 'max_clients',
        maxconn  => 'max_connections',
        maxserve => 'max_keep_alive_requests',
    );
    while ( my ( $old, $new ) = each %convert ) {
        no strict 'refs';
        *$old = sub {
            carp "$old is deprecated, please use $new";

lib/HTTP/Proxy.pm  view on Meta::CPAN


sub _init_agent {
    my $self  = shift;
    my $agent = LWP::UserAgent->new(
        env_proxy  => 1,
        keep_alive => 2,
        parse_head => 0,
        timeout    => $self->timeout,
      )
      or die "Cannot initialize proxy agent: $!";
    $self->agent($agent);

lib/HTTP/Proxy.pm  view on Meta::CPAN

          if defined $req->uri->scheme
             and $req->uri->scheme =~ /^(?:ftp|gopher)$/
             and $response->is_success;

        $self->log( SOCKET, "SOCKET", "Connection closed by the proxy" ), last
          if $last || $served >= $self->max_keep_alive_requests;
    }
    $self->log( SOCKET, "SOCKET", "Connection closed by the client" )
      if !$last
      and $served < $self->max_keep_alive_requests;
    $self->log( PROCESS, "PROCESS", "Served $served requests" );
    $conn->close;
}

# INTERNAL METHOD

lib/HTTP/Proxy.pm  view on Meta::CPAN

        else {
            if ( $conn->proto_ge("HTTP/1.1") ) {
                $chunked++;
                $response->push_header( "Transfer-Encoding" => "chunked" );
                $response->push_header( "Connection"        => "close" )
                  if $served >= $self->max_keep_alive_requests;
            }
            else {
                $last++;
                $conn->force_last_request;
            }

lib/HTTP/Proxy.pm  view on Meta::CPAN


Note: C<max_connections> will be deprecated soon, for two reasons: 1)
it is more of an L<HTTP::Proxy::Engine> attribute, 2) not all engines will
support it.

=item max_keep_alive_requests

=item maxserve

The maximum number of requests the proxy will serve in a single connection.
(same as C<MaxRequestsPerChild> in Apache)

lib/HTTP/Proxy.pm  view on Meta::CPAN


Those attributes control the HTTP connection:

=over 4

=item keep_alive

Support for keep alive HTTP connections.

=item max_keep_alive_requests

Maximum number of HTTP connections within a single TCP connection.

=item keep_alive_timeout

Timeout for keep-alive connection.

=back

=head1 EXPORTED SYMBOLS

 view all matches for this distribution


HTTP-Request-FromCurl

 view release on metacpan or  search on metacpan

lib/HTTP/Request/FromCurl.pm  view on Meta::CPAN

    'json=s@',
    'location|L',        # ignored, we always follow redirects
    'max-filesize=s',
    'max-time|m=s',
    'ntlm',
    'keepalive!',
    'range=s',
    'request|X=s',
    'oauth2-bearer=s',
    'output|o=s',
    'progress-bar|#',    # ignored

lib/HTTP/Request/FromCurl.pm  view on Meta::CPAN

                $options->{'cookie-jar-options'}->{ 'read' } = 1;
            };
        };

        # Curl 7.61.0 ignores these:
        #if( $options->{ keepalive }) {
        #    $headers{ 'Keep-Alive' } = 1;
        #} elsif( exists $options->{ keepalive }) {
        #    $headers{ 'Keep-Alive' } = 0;
        #};

        if( $options->{ compressed }) {
            my $compressions = HTTP::Message::decodable();

 view all matches for this distribution


HTTP-Request-FromTemplate

 view release on metacpan or  search on metacpan

lib/HTTP/Request/FromTemplate.pm  view on Meta::CPAN


  # A request, snarfed from your network monitor logs:
  my $template = <<TEMPLATE
  POST http://[% host %][% path %][% query %] HTTP/1.1
  Host: [% host %]
  Connection: keep-alive
  Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
  Accept-Encoding: gzip,deflate
  Accept-Language: en-us,en;q=0.5
  User-Agent: QuickTime (qtver=5.0.2;os=Windows NT 5.1)
  Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5

 view all matches for this distribution


HTTP-Request-Webpush

 view release on metacpan or  search on metacpan

examples/push.cgi  view on Meta::CPAN

  // Retrieve the textual payload from event.data (a PushMessageData object).
  // Other formats are supported (ArrayBuffer, Blob, JSON), check out the documentation
  // on https://developer.mozilla.org/en-US/docs/Web/API/PushMessageData.
  const payload = event.data ? event.data.text() : 'no payload';

  // Keep the service worker alive until the notification is created.
  event.waitUntil(
    self.registration.showNotification('HTTP::Request::Webpush example', {
      body: payload,
    })
  );

 view all matches for this distribution


HTTP-Server-Multiplex

 view release on metacpan or  search on metacpan

lib/HTTP/Server/Connection.pm  view on Meta::CPAN

            unless $proto;

        $headers  = $req->headers;
        $self->{HSC_no_more}++
            if $req->protocol lt HTTP_1_1
            || lc($headers->header('Connection') || '') ne 'keep-alive';

        if($proto lt HTTP_1_0)
        {   $self->{take_all}++;
            return;
        }

lib/HTTP/Server/Connection.pm  view on Meta::CPAN

    defined $content or $content = '';

    if($protocol ge HTTP_1_0)
    {   push @$header
          , Date       => time2str(time)
          , Connection => ($self->{HSC_no_more} ? 'close' : 'keep-alive')
          , @default_headers;

        push @$header
          , ref $content eq 'CODE'
            ? ('Transfer-Encoding' => 'chunked')

lib/HTTP/Server/Connection.pm  view on Meta::CPAN

          };

        my ($ct, $ce) = guess_media_type $file;
        push @headers
          , Date       => time2str(time)
          , Connection => ($self->{HSC_no_more} ? 'close' : 'keep-alive')
          , @default_headers
          , 'Content-Type' => $ct;
        push @headers, 'Content-Encoding' => $ce if $ce;
    }

 view all matches for this distribution


HTTP-Server-Singlethreaded

 view release on metacpan or  search on metacpan

Singlethreaded.pm  view on Meta::CPAN

      }else{
         warn "Error writing to socket $OutFileHandle ($fn): $!";
         $outbuf[$fn] = '';
      }

      # rewrite this when adding keepalive support
      length($outbuf[$fn]) or close $OutFileHandle;
   }

   # read incoming data to inbufs and list inbufs with complete requests
   # close bad connections

Singlethreaded.pm  view on Meta::CPAN

     path => \%ChangeConfigurationWhileServingBySettingThis;
  #
  # "top level select loop" is invoked explicitly
  for(;;){
    #
    # manage keepalives on database handles
    if ((time - $lasttime) > 40){
       ...
       $lasttime = time;
    };
    # Auto restart on editing this file

Singlethreaded.pm  view on Meta::CPAN

be passed on the C<use> line.

=head2 $MaxClients

if we have more active clients than this we won't accept more. Since
we're not respecting keepalive at this time, this number indicates
how long of a backlog singlethreaded will maintain at any moment,and
should be orders of magnitude lower than the number of simultaneous
web page viewers possible. Depending on how long your functions take.

=head2 $WebEmail

Singlethreaded.pm  view on Meta::CPAN


=item 0.12  July, 2009

silenced a warning about C<$_{Data}> being uninitialized

instead of actually implementing keep-alive, added a "Connection: close" header
line at the beginning of each response

=back

=head1 EXPORTS

 view all matches for this distribution


HTTP-StreamParser

 view release on metacpan or  search on metacpan

examples/request.pl  view on Meta::CPAN

  http_header => sub { print "Header: $_[1]: $_[2]\n" },
);
$req_parser->parse(join $CRLF, split /\n/, <<'EOF');
GET http://search.cpan.org/ HTTP/1.1
Host: search.cpan.org
Proxy-Connection: keep-alive
Cache-Control: max-age=0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.43 Safari/537.31
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-GB,en-US;q=0.8,en;q=0.6

 view all matches for this distribution


HTTP-Tiny

 view release on metacpan or  search on metacpan

lib/HTTP/Tiny.pm  view on Meta::CPAN

#pod   redirecting C<https> to C<http>. Default is C<false>.
#pod * C<cookie_jar> — An instance of L<HTTP::CookieJar> — or equivalent class
#pod   that supports the C<add> and C<cookie_header> methods
#pod * C<default_headers> — A hashref of default headers to apply to requests
#pod * C<local_address> — The local IP address to bind to
#pod * C<keep_alive> — Whether to reuse the last connection (if for the same
#pod   scheme, host and port) (defaults to 1)
#pod * C<keep_alive_timeout> — How many seconds to keep a connection available
#pod   for after a request (defaults to 0, unlimited)
#pod * C<max_redirect> — Maximum number of redirects allowed (defaults to 5)
#pod * C<max_size> — Maximum response size in bytes (only when not using a data
#pod   callback).  If defined, requests with responses larger than this will return
#pod   a 599 status code.

lib/HTTP/Tiny.pm  view on Meta::CPAN

#pod
#pod Errors during request execution will result in a pseudo-HTTP status code of 599
#pod and a reason of "Internal Exception". The content field in the response will
#pod contain the text of the error.
#pod
#pod The C<keep_alive> parameter enables a persistent connection, but only to a
#pod single destination scheme, host and port.  If any connection-relevant
#pod attributes are modified via accessor, or if the process ID or thread ID change,
#pod the persistent connection will be dropped.  If you want persistent connections
#pod across multiple destinations, use multiple HTTP::Tiny objects.
#pod
#pod The C<keep_alive_timeout> parameter allows you to control how long a
#pod keep alive connection will be considered for reuse. By setting this lower
#pod than the server keep alive time, this allows you to avoid race conditions where
#pod the server closes the connection while preparing to write the request on
#pod a reused persistent connection.
#pod
#pod See L</TLS/SSL SUPPORT> for more on the C<verify_SSL> and C<SSL_options>
#pod attributes.

lib/HTTP/Tiny.pm  view on Meta::CPAN


my @attributes;
BEGIN {
    @attributes = qw(
        allow_credentialed_redirects allow_downgrade cookie_jar default_headers
        http_proxy https_proxy keep_alive local_address max_redirect max_size
        proxy no_proxy SSL_options verify_SSL
    );
    my %persist_ok = map {; $_ => 1 } qw(
        cookie_jar default_headers max_redirect max_size
    );

lib/HTTP/Tiny.pm  view on Meta::CPAN

    }

    my $self = {
        max_redirect => 5,
        timeout      => defined $args{timeout} ? $args{timeout} : 60,
        keep_alive   => 1,
        keep_alive_timeout => 0,
        verify_SSL   => defined $args{verify_SSL} ? $args{verify_SSL} : _verify_SSL_default(),
        no_proxy     => $ENV{no_proxy},
    };

    bless $self, $class;

lib/HTTP/Tiny.pm  view on Meta::CPAN

#pod =method connected
#pod
#pod     $host = $http->connected;
#pod     ($host, $port) = $http->connected;
#pod
#pod Indicates if a connection to a peer is being kept alive, per the C<keep_alive>
#pod option.
#pod
#pod In scalar context, returns the peer host and port, joined with a colon, or
#pod C<undef> (if no peer is connected).
#pod In list context, returns the peer host and port or an empty list (if no peer

lib/HTTP/Tiny.pm  view on Meta::CPAN

        my $cb_args = @redir_args ? +{} : $args;
        my $data_cb = $self->_prepare_data_cb($response, $cb_args);
        $known_message_length = $handle->read_body($data_cb, $response);
    }

    if ( $self->{keep_alive}
        && $handle->connected
        && $known_message_length
        && $response->{protocol} eq 'HTTP/1.1'
        && ($response->{headers}{connection} || '') ne 'close'
    ) {

lib/HTTP/Tiny.pm  view on Meta::CPAN

    my $handle  = HTTP::Tiny::Handle->new(
        timeout         => $self->{timeout},
        SSL_options     => $self->{SSL_options},
        verify_SSL      => $self->{verify_SSL},
        local_address   => $self->{local_address},
        keep_alive      => $self->{keep_alive},
        keep_alive_timeout => $self->{keep_alive_timeout}
    );

    require Time::HiRes if $self->{keep_alive_timeout} > 0;

    if ($self->{_has_proxy}{$scheme} && ! grep { $host =~ /\Q$_\E$/ } @{$self->{no_proxy}}) {
        return $self->_proxy_connect( $request, $handle );
    }
    else {

lib/HTTP/Tiny.pm  view on Meta::CPAN

    }

    $request->{headers}{'host'}         = $request->{host_port};
    $request->{headers}{'user-agent'} ||= $self->{agent};
    $request->{headers}{'connection'}   = "close"
        unless $self->{keep_alive};

    # Some servers error on an empty-body PUT/POST without a content-length
    if ( $request->{method} eq 'PUT' || $request->{method} eq 'POST' ) {
        if (!defined($args->{content}) || !length($args->{content}) ) {
            $request->{headers}{'content-length'} = 0;

lib/HTTP/Tiny.pm  view on Meta::CPAN

    $self->{fh}->setsockopt(IPPROTO_TCP, TCP_NODELAY, 1);

    binmode($self->{fh})
      or die(qq/Could not binmode() socket: '$!'\n/);

    if ( $self->{keep_alive} ) {
        unless ( defined( $self->{fh}->setsockopt( SOL_SOCKET, SO_KEEPALIVE, 1 ) ) ) {
            CORE::close($self->{fh});
            die(qq/Could not set SO_KEEPALIVE on socket: '$!'\n/);
        }
    }

lib/HTTP/Tiny.pm  view on Meta::CPAN

    @_ == 1 || @_ == 2 || die(q/Usage: $handle->can_write([timeout])/ . "\n");
    my $self = shift;
    return $self->_do_timeout('write', @_)
}

sub _has_keep_alive_expired {
    my $self = shift;
    return unless $self->{keep_alive_timeout} > 0;
    my $now = Time::HiRes::time();
    return $now - ($self->{last_used} || $now) > $self->{keep_alive_timeout};
}

sub _update_last_used {
    my $self = shift;
    return unless $self->{keep_alive_timeout} > 0;
    $self->{last_used} = Time::HiRes::time();
}

sub _assert_ssl {
    my($ok, $reason) = HTTP::Tiny->can_ssl();

lib/HTTP/Tiny.pm  view on Meta::CPAN

        || length($self->{rbuf})
        || $scheme ne $self->{scheme}
        || $host ne $self->{host}
        || $port ne $self->{port}
        || $peer ne $self->{peer}
        || $self->_has_keep_alive_expired()
        || eval { $self->can_read(0) }
        || $@ ;
        return 1;
}

lib/HTTP/Tiny.pm  view on Meta::CPAN


C<local_address> — The local IP address to bind to

=item *

C<keep_alive> — Whether to reuse the last connection (if for the same scheme, host and port) (defaults to 1)

=item *

C<keep_alive_timeout> — How many seconds to keep a connection available for after a request (defaults to 0, unlimited)

=item *

C<max_redirect> — Maximum number of redirects allowed (defaults to 5)

lib/HTTP/Tiny.pm  view on Meta::CPAN


Errors during request execution will result in a pseudo-HTTP status code of 599
and a reason of "Internal Exception". The content field in the response will
contain the text of the error.

The C<keep_alive> parameter enables a persistent connection, but only to a
single destination scheme, host and port.  If any connection-relevant
attributes are modified via accessor, or if the process ID or thread ID change,
the persistent connection will be dropped.  If you want persistent connections
across multiple destinations, use multiple HTTP::Tiny objects.

The C<keep_alive_timeout> parameter allows you to control how long a
keep alive connection will be considered for reuse. By setting this lower
than the server keep alive time, this allows you to avoid race conditions where
the server closes the connection while preparing to write the request on
a reused persistent connection.

See L</TLS/SSL SUPPORT> for more on the C<verify_SSL> and C<SSL_options>
attributes.

lib/HTTP/Tiny.pm  view on Meta::CPAN

=head2 connected

    $host = $http->connected;
    ($host, $port) = $http->connected;

Indicates if a connection to a peer is being kept alive, per the C<keep_alive>
option.

In scalar context, returns the peer host and port, joined with a colon, or
C<undef> (if no peer is connected).
In list context, returns the peer host and port or an empty list (if no peer

lib/HTTP/Tiny.pm  view on Meta::CPAN

allow_downgrade
cookie_jar
default_headers
http_proxy
https_proxy
keep_alive
local_address
max_redirect
max_size
no_proxy
proxy

 view all matches for this distribution


( run in 1.660 second using v1.01-cache-2.11-cpan-71847e10f99 )