Net::HTTPS::NB(3pm) User Contributed Perl Documentation Net::HTTPS::NB(3pm)NAME
Net::HTTPS::NB - Non-blocking HTTPS client
SYNOPSIS
Example from Net::HTTP::NB
use Net::HTTPS::NB;
use IO::Select;
use strict;
my $s = Net::HTTPS::NB->new(Host => "pause.perl.org") || die $@;
$s->write_request(GET => "/");
my $sel = IO::Select->new($s);
READ_HEADER: {
die "Header timeout" unless $sel->can_read(10);
my($code, $mess, %h) = $s->read_response_headers;
redo READ_HEADER unless $code;
}
while(1) {
die "Body timeout" unless $sel->can_read(10);
my $buf;
my $n = $s->read_entity_body($buf, 1024);
last unless $n;
print $buf;
}
Example of non-blocking connect
use strict;
use Net::HTTPS::NB;
use IO::Select;
my $sock = Net::HTTPS::NB->new(Host => 'encrypted.google.com', Blocking => 0);
my $sele = IO::Select->new($sock);
until ($sock->connected) {
if ($HTTPS_ERROR == HTTPS_WANT_READ) {
$sele->can_read();
}
elsif($HTTPS_ERROR == HTTPS_WANT_WRITE) {
$sele->can_write();
}
else {
die 'Unknown error: ', $HTTPS_ERROR;
}
}
See `examples' subdirectory for more examples.
DESCRIPTION
Same interface as Net::HTTPS but it will never try multiple reads when the read_response_headers() or read_entity_body() methods are
invoked. In addition allows non-blocking connect.
If read_response_headers() did not see enough data to complete the headers an empty list is returned.
If read_entity_body() did not see new entity data in its read the value -1 is returned.
PACKAGE CONSTANTS
Imported by default
HTTPS_WANT_READ
HTTPS_WANT_WRITE
PACKAGE VARIABLES
Imported by default
$HTTPS_ERROR
METHODS
new(%cfg)
Same as Net::HTTPS::new, but in addition allows `Blocking' parameter. By setting this parameter to 0 you can perform non-blocking connect.
See connected() to determine when connection completed.
connected()
Returns true value when connection completed (https handshake done). Otherwise returns false. In this case you can check $HTTPS_ERROR to
determine what handshake need for, read or write. $HTTPS_ERROR could be HTTPS_NEED_READ or HTTPS_NEED_WRITE respectively. See "SYNOPSIS".
blocking($flag)
As opposed to Net::HTTPS where blocking method consciously broken you can set socket blocking. For example you can return socket to
blocking state after non-blocking connect.
SEE ALSO
Net::HTTP, Net::HTTP::NB
COPYRIGHT
Copyright 2011 Oleg G <oleg@cpan.org>.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
perl v5.14.2 2011-06-07 Net::HTTPS::NB(3pm)
Check Out this Related Man Page
OnlinePayment::HTTPS(3pm) User Contributed Perl Documentation OnlinePayment::HTTPS(3pm)NAME
Business::OnlinePayment::HTTPS - Base class for HTTPS payment APIs
SYNOPSIS
package Business::OnlinePayment::MyProcessor;
use base qw(Business::OnlinePayment::HTTPS);
sub submit {
my $self = shift;
#...
# pass a list (order is preserved, if your gateway needs that)
( $page, $response, %reply_headers )
= $self->https_get( field => 'value', ... );
# or a hashref
my %hash = ( field => 'value', ... );
( $page, $response_code, %reply_headers )
= $self->https_get( \%hash );
#...
}
DESCRIPTION
This is a base class for HTTPS based gateways, providing useful code for implementors of HTTPS payment APIs.
It depends on Net::HTTPS::Any, which in turn depends on Net::SSLeay _or_ ( Crypt::SSLeay and LWP::UserAgent ).
METHODS
https_get [ \%options ] HASHREF | FIELD => VALUE, ...
Accepts parameters as either a hashref or a list of fields and values. In the latter case, ordering is preserved (see Tie::IxHash to
do so when passing a hashref).
Returns a list consisting of the page content as a string, the HTTP response code and message (i.e. "200 OK" or "404 Not Found"), and a
list of key/value pairs representing the HTTP response headers.
The options hashref supports setting headers:
{
headers => { 'X-Header1' => 'value', ... },
}
https_post [ \%options ] SCALAR | HASHREF | FIELD => VALUE, ...
Accepts form fields and values as either a hashref or a list. In the latter case, ordering is preserved (see Tie::IxHash to do so when
passing a hashref).
Also accepts instead a simple scalar containing the raw content.
Returns a list consisting of the page content as a string, the HTTP response code and message (i.e. "200 OK" or "404 Not Found"), and a
list of key/value pairs representing the HTTP response headers.
The options hashref supports setting headers and Content-Type:
{
headers => { 'X-Header1' => 'value', ... },
Content-Type => 'text/namevalue',
}
SEE ALSO
Business::OnlinePayment, Net::HTTPS::Any
perl v5.12.4 2010-05-25 OnlinePayment::HTTPS(3pm)