HTTP-Promise
view release on metacpan or search on metacpan
3. "SSL_ca_path"
This is the path to a directory of files containing
Certificate Authority certificates.
If environment variable "PERL_LWP_SSL_CA_PATH" or
"HTTPS_CA_DIR" is set, then the ssl option property
"SSL_ca_path" takes its value.
Other options can be set and are processed directly by the SSL
Socket implementation in use. See IO::Socket::SSL or Net::SSL for
details.
* "threshold"
Integer. Sets the content length threshold beyond which, the
response content will be stored to a locale file. It can then be
fetch with "file". Default to global variable
$CONTENT_SIZE_THRESHOLD, which is "undef" by default.
See also the "max_size" option.
3. "SSL_ca_path"
This is the path to a directory of files containing Certificate
Authority certificates.
If environment variable "PERL_LWP_SSL_CA_PATH" or "HTTPS_CA_DIR"
is set, then the ssl option property "SSL_ca_path" takes its
value.
Other options can be set and are processed directly by the SSL Socket
implementation in use. See IO::Socket::SSL or Net::SSL for details.
stop_if
Sets or gets a callback code reference (reference to a perl subroutine
or an anonymous subroutine) that will be used to determine if we should
keep trying upon reading data from the filehandle and an "EINTR" error
occurs.
If the callback returns true, further attempts will stop and return an
error. The default is to continue trying.
This is the path to a file containing the Certificate Authority certificates.
If environment variable `PERL_LWP_SSL_CA_FILE` or `HTTPS_CA_FILE` is set, then the ssl option property `SSL_ca_file` takes its value.
- 3. `SSL_ca_path`
This is the path to a directory of files containing Certificate Authority certificates.
If environment variable `PERL_LWP_SSL_CA_PATH` or `HTTPS_CA_DIR` is set, then the ssl option property `SSL_ca_path` takes its value.
Other options can be set and are processed directly by the SSL Socket implementation in use. See [IO::Socket::SSL](https://metacpan.org/pod/IO%3A%3ASocket%3A%3ASSL) or [Net::SSL](https://metacpan.org/pod/Net%3A%3ASSL) for details.
- `threshold`
Integer. Sets the content length threshold beyond which, the response content will be stored to a locale file. It can then be fetch with ["file"](#file). Default to global variable `$CONTENT_SIZE_THRESHOLD`, which is `undef` by default.
See also the `max_size` option.
- `timeout`
Integer. Sets the timeout value. Defaults to 180 seconds, i.e. 3 minutes.
This is the path to a file containing the Certificate Authority certificates.
If environment variable `PERL_LWP_SSL_CA_FILE` or `HTTPS_CA_FILE` is set, then the ssl option property `SSL_ca_file` takes its value.
- 3. `SSL_ca_path`
This is the path to a directory of files containing Certificate Authority certificates.
If environment variable `PERL_LWP_SSL_CA_PATH` or `HTTPS_CA_DIR` is set, then the ssl option property `SSL_ca_path` takes its value.
Other options can be set and are processed directly by the SSL Socket implementation in use. See [IO::Socket::SSL](https://metacpan.org/pod/IO%3A%3ASocket%3A%3ASSL) or [Net::SSL](https://metacpan.org/pod/Net%3A%3ASSL) for details.
## stop\_if
Sets or gets a callback code reference (reference to a perl subroutine or an anonymous subroutine) that will be used to determine if we should keep trying upon reading data from the filehandle and an `EINTR` error occurs.
If the callback returns true, further attempts will stop and return an error. The default is to continue trying.
## threshold
Integer. Sets the content length threshold beyond which, the response content will be stored to a locale file. It can then be fetch with ["file"](#file). Default to global variable `$CONTENT_SIZE_THRESHOLD`, which is `undef` by default.
lib/HTTP/Promise.pm view on Meta::CPAN
If environment variable C<PERL_LWP_SSL_CA_FILE> or C<HTTPS_CA_FILE> is set, then the ssl option property C<SSL_ca_file> takes its value.
=item 3. C<SSL_ca_path>
This is the path to a directory of files containing Certificate Authority certificates.
If environment variable C<PERL_LWP_SSL_CA_PATH> or C<HTTPS_CA_DIR> is set, then the ssl option property C<SSL_ca_path> takes its value.
=back
Other options can be set and are processed directly by the SSL Socket implementation in use. See L<IO::Socket::SSL> or L<Net::SSL> for details.
=item * C<threshold>
Integer. Sets the content length threshold beyond which, the response content will be stored to a locale file. It can then be fetch with L</file>. Default to global variable C<$CONTENT_SIZE_THRESHOLD>, which is C<undef> by default.
See also the C<max_size> option.
=item * C<timeout>
Integer. Sets the timeout value. Defaults to 180 seconds, i.e. 3 minutes.
lib/HTTP/Promise.pm view on Meta::CPAN
If environment variable C<PERL_LWP_SSL_CA_FILE> or C<HTTPS_CA_FILE> is set, then the ssl option property C<SSL_ca_file> takes its value.
=item 3. C<SSL_ca_path>
This is the path to a directory of files containing Certificate Authority certificates.
If environment variable C<PERL_LWP_SSL_CA_PATH> or C<HTTPS_CA_DIR> is set, then the ssl option property C<SSL_ca_path> takes its value.
=back
Other options can be set and are processed directly by the SSL Socket implementation in use. See L<IO::Socket::SSL> or L<Net::SSL> for details.
=head2 stop_if
Sets or gets a callback code reference (reference to a perl subroutine or an anonymous subroutine) that will be used to determine if we should keep trying upon reading data from the filehandle and an C<EINTR> error occurs.
If the callback returns true, further attempts will stop and return an error. The default is to continue trying.
=head2 threshold
Integer. Sets the content length threshold beyond which, the response content will be stored to a locale file. It can then be fetch with L</file>. Default to global variable C<$CONTENT_SIZE_THRESHOLD>, which is C<undef> by default.
lib/HTTP/Promise/IO.pm view on Meta::CPAN
}
sub buffer { return( shift->_set_get_scalar_as_object( 'buffer', @_ ) ); }
sub can_read
{
my $self = shift( @_ );
my $fh = $self->filehandle;
my $opts = $self->_get_args_as_hash( @_ );
return(1) unless( defined( fileno( $fh ) ) );
return(1) if( $fh->isa( 'IO::Socket::SSL' ) && $fh->pending );
return(1) if( $fh->isa( 'Net::SSL' ) && $fh->can('pending') && $fh->pending );
# If this is an in-memory scalar filehandle
# check that it is opened so we can read from it
if( fileno( $fh ) == -1 )
{
if( $self->_can( $fh => 'can_read' ) )
{
return( $fh->can_read );
}
lib/HTTP/Promise/IO.pm view on Meta::CPAN
# Returns file handle like object
sub connect_ssl
{
my $self = shift( @_ );
my $opts = $self->_get_args_as_hash( @_ );
my $host = $opts->{host} || return( $self->error( "No host to connect to was provided." ) );
my $port = $opts->{port} || return( $self->error( "No port to connect to was provided." ) );
return( $self->error( "Port provided ($port) is not a number" ) ) if( $port !~ /^\d+$/ );
return( $self->error( "No timeout was provided to connect." ) ) if( !exists( $opts->{timeout} ) || !length( $opts->{timeout} ) );
$self->_load_class( 'IO::Socket::SSL' ) || return( $self->pass_error );
my $params = {};
if( $self->_is_array( $INIT_PARAMS ) )
{
for( @$INIT_PARAMS )
{
$params->{ $_ } = $opts->{ $_ } if( exists( $opts->{ $_ } ) );
}
}
$params->{host} = $host;
$params->{port} = $port;
my $new = $self->connect( %$params ) ||
return( $self->pass_error );
my $sock = $new->filehandle;
my $timeout = $opts->{timeout} // $self->timeout // 5;
# my $timeout = ( $opts->{timeout} - time() );
# return( $self->error( "Cannot create SSL connection: timeout" ) ) if( $timeout <= 0 );
my $ssl_opts = $new->_ssl_opts;
IO::Socket::SSL->start_SSL(
$sock,
PeerHost => $host,
PeerPort => $port,
Timeout => $timeout,
( defined( $opts->{local_host} ) ? ( LocalHost => $opts->{local_host} ) : () ),
( defined( $opts->{local_port} ) ? ( LocalPort => $opts->{local_port} ) : () ),
%$ssl_opts,
) or return( $self->error( "Cannot create SSL connection: " . IO::Socket::SSL::errstr() ) );
$new->_set_sockopts( $sock );
return( $new );
}
sub connect_ssl_over_proxy
{
my $self = shift( @_ );
my $opts = $self->_get_args_as_hash( @_ );
my $proxy_host = $opts->{proxy_host} || return( $self->error( "No proxy host to connect to was provided." ) );
my $proxy_port = $opts->{proxy_port} || return( $self->error( "No proxy port to connect to was provided." ) );
my $host = $opts->{host} || return( $self->error( "No host to connect to was provided." ) );
my $port = $opts->{port} || return( $self->error( "No port to connect to was provided." ) );
return( $self->error( "Proxy port provided ($proxy_port) is not a number" ) ) if( $proxy_port !~ /^\d+$/ );
return( $self->error( "Host port provided ($port) is not a number" ) ) if( $port !~ /^\d+$/ );
return( $self->error( "Port provided ($port) is not a number" ) ) if( $port !~ /^\d+$/ );
return( $self->error( "No timeout was provided to connect." ) ) if( !exists( $opts->{timeout} ) || !length( $opts->{timeout} ) );
my $proxy_authorization = $opts->{proxy_authorization};
$self->_load_class( 'IO::Socket::SSL' ) || return( $self->pass_error );
my $params = {};
if( $self->_is_array( $INIT_PARAMS ) )
{
for( @$INIT_PARAMS )
{
$params->{ $_ } = $opts->{ $_ } if( exists( $opts->{ $_ } ) );
}
}
$params->{host} = $proxy_host;
lib/HTTP/Promise/IO.pm view on Meta::CPAN
}
my $timeout = ( $opts->{timeout} - time() );
return( $self->error( "Cannot start SSL connection: timeout" ) ) if( $opts->{timeout} <= 0 );
my $ssl_opts = $new->_ssl_opts;
unless( exists( $ssl_opts->{SSL_verifycn_name} ) )
{
$ssl_opts->{SSL_verifycn_name} = $host;
}
IO::Socket::SSL->start_SSL(
$sock,
PeerHost => "$host",
PeerPort => "$port",
Timeout => "$timeout",
( defined( $opts->{local_host} ) ? ( LocalHost => $opts->{local_host} ) : () ),
( defined( $opts->{local_port} ) ? ( LocalPort => $opts->{local_port} ) : () ),
%$ssl_opts
) or return( $self->error( "Cannot start SSL connection: " . IO::Socket::SSL::errstr() ) );
$new->_set_sockopts( $sock );
return( $new );
}
sub filehandle { return( shift->_set_get_glob( '_fh', @_ ) ); }
# Credits: Olaf Alders in Net::HTTP
sub getline
{
my $self = shift( @_ );
lib/HTTP/Promise/IO.pm view on Meta::CPAN
sub _set_sockopts
{
my $self = shift( @_ );
my $sock = shift( @_ ) ||
return( $self->error( "No socket was provided." ) );
setsockopt( $sock, IPPROTO_TCP, TCP_NODELAY, 1 ) or
return( $self->error( "Failed to setsockopt(TCP_NODELAY): $!" ) );
if( $IS_WIN32 )
{
if( ref( $sock ) ne 'IO::Socket::SSL' )
{
my $tmp = 1;
ioctl( $sock, 0x8004667E, \$tmp ) or
return( $self->error( "Cannot set flags for the socket: $!" ) );
}
}
else
{
my $flags = fcntl( $sock, F_GETFL, 0 ) or
return( $self->error( "Cannot get flags for the socket: $!" ) );
lib/HTTP/Promise/IO.pm view on Meta::CPAN
sub _ssl_opts
{
my $self = shift( @_ );
my $ssl_opts = $self->ssl_opts;
unless( exists( $ssl_opts->{SSL_verify_mode} ) )
{
if( exists( $ssl_opts->{verify_hostname} ) &&
!$ssl_opts->{verify_hostname} )
{
$ssl_opts->{SSL_verify_mode} = IO::Socket::SSL::SSL_VERIFY_NONE();
}
else
{
# set SSL_VERIFY_PEER as default.
$ssl_opts->{SSL_verify_mode} = IO::Socket::SSL::SSL_VERIFY_PEER();
}
unless( exists( $ssl_opts->{SSL_verifycn_scheme} ) )
{
$ssl_opts->{SSL_verifycn_scheme} = 'www'
}
}
if( $ssl_opts->{SSL_verify_mode} )
{
unless( exists( $ssl_opts->{SSL_ca_file} ) || exists( $ssl_opts->{SSL_ca_path} ) )
{
lib/HTTP/Promise/IO.pm view on Meta::CPAN
Boolean. If this is true, this will exclude the C<string> sought from the buffer allocation.
=item C<include>
Boolean. If this is true, this will set the buffer including the C<string> sought after.
=back
=head2 ssl_opts
Sets or gets an hash reference of ssl options to be used with L<IO::Socket::SSL/start_SSL>
=head2 stop_if
Sets or gets a code reference acting as a callback when an error C<EINTR> if encountered. If the callback returns true, the method using it, will stop and return an error, otherwise, it will keep trying.
=head2 timeout
Sets or gets the timeout threshold. This returns a L<number object|Module::Generic::Number>
=head2 unread
( run in 0.382 second using v1.01-cache-2.11-cpan-05444aca049 )