view release on metacpan or search on metacpan
lib/AI/CleverbotIO.pm view on Meta::CPAN
my $encoded = $response->{content};
if (!$encoded) {
my $url = $response->{url} // '*unknown url, check HTTP::Tiny*';
ouch 500, "response status $response->{status}, nothing from $url)";
}
my $decoded = eval { decode_json($encoded) }
or ouch 500, "response status $response->{status}, exception: $@";
return $decoded;
} ## end sub __decode_content
1;
view all matches for this distribution
view release on metacpan or search on metacpan
lib/AI/MXNet/NDArray.pm view on Meta::CPAN
Parameters
----------
$str_img : str
binary image data
:$clip_rect : iterable of 4 int
clip decoded image to rectangle (x0, y0, x1, y1)
:$out= : Maybe[NDArray]
output buffer. can be 3 dimensional (c, h, w) or 4 dimensional (n, c, h, w)
:$index : int
output decoded image to i-th slice of 4 dimensional buffer
:$channels=3 : int
number of channels to output. Decode to grey scale when channels = 1.
$mean= : Maybe[NDArray]
subtract mean from decode image before outputting.
=cut
view all matches for this distribution
view release on metacpan or search on metacpan
bin/remote.pl view on Meta::CPAN
}
# extract, cleanup and return the data
# if decoding the content fails, we just deal with the raw content
push @items =>
$class->extract( $res->decoded_content() || $res->content() );
}
# return unique items
my %seen;
view all matches for this distribution
view release on metacpan or search on metacpan
lib/AI/PredictionClient/Classes/SimpleTensor.pm view on Meta::CPAN
});
sub value {
my ($self, $value_aref) = @_;
my $decoded_aref;
my $value_type = $self->dtype_values->{ $self->dtype };
my $tensor_value_ref = \$self->tensor_ds->{$value_type};
if ($value_aref) {
lib/AI/PredictionClient/Classes/SimpleTensor.pm view on Meta::CPAN
return [];
} else {
if ($self->dtype eq 'DT_STRING' && !$self->use_base64_strings) {
@$decoded_aref = map { decode_base64($_) } @$$tensor_value_ref;
return $decoded_aref;
} else {
return $$tensor_value_ref;
}
}
view all matches for this distribution
view release on metacpan or search on metacpan
lib/AMF/Connection.pm view on Meta::CPAN
);
croak "HTTP POST error: ".$http_response->status_line."\n"
unless($http_response->is_success);
my $response_stream = new AMF::Connection::InputStream( $http_response->decoded_content, $class->{'input_amf_options'});
my $response = new AMF::Connection::Message;
$response->deserialize( $response_stream );
#print STDERR Dumper( $response )."\n";
view all matches for this distribution
view release on metacpan or search on metacpan
lib/API/Assembla.pm view on Meta::CPAN
my ($self, $id) = @_;
my $req = $self->make_req('/spaces/'.$id);
my $resp = $self->_client->request($req);
# print STDERR $resp->decoded_content;
my $xp = XML::XPath->new(xml => $resp->decoded_content);
my $space = $xp->find('/space')->pop;
my $name = $space->findvalue('name')."";
return API::Assembla::Space->new(
lib/API/Assembla.pm view on Meta::CPAN
my ($self) = @_;
my $req = $self->make_req('/spaces/my_spaces');
my $resp = $self->_client->request($req);
# print STDERR $resp->decoded_content;
my $xp = XML::XPath->new(xml => $resp->decoded_content);
my $spaces = $xp->find('/spaces/space');
my %objects = ();
foreach my $space ($spaces->get_nodelist) {
lib/API/Assembla.pm view on Meta::CPAN
my ($self, $id, $number) = @_;
my $req = $self->make_req('/spaces/'.$id.'/tickets/'.$number);
my $resp = $self->_client->request($req);
# print STDERR $resp->decoded_content;
my $xp = XML::XPath->new(xml => $resp->decoded_content);
my $ticket = $xp->find('/ticket')->pop;
return API::Assembla::Ticket->new(
id => $ticket->findvalue('id').'',
lib/API/Assembla.pm view on Meta::CPAN
my ($self, $id) = @_;
my $req = $self->make_req('/spaces/'.$id.'/tickets');
my $resp = $self->_client->request($req);
# print STDERR $resp->decoded_content;
my $xp = XML::XPath->new(xml => $resp->decoded_content);
my $tickets = $xp->find('/tickets/ticket');
my %objects = ();
foreach my $ticket ($tickets->get_nodelist) {
view all matches for this distribution
view release on metacpan or search on metacpan
lib/API/BigBlueButton/Response.pm view on Meta::CPAN
sub new {
my ( $class, $res ) = @_;
my $success = $res->is_success;
my $xml = $success ? $res->decoded_content : '';
my $error = $success ? '' : $res->decoded_content;
my $status = $res->status_line;
my $parsed_response = $xml ? xml2hash( $xml, attr => '' ) : {};
return bless(
view all matches for this distribution
view release on metacpan or search on metacpan
lib/API/CLI/Request.pm view on Meta::CPAN
my $ua = LWP::UserAgent->new;
my $req = $self->req;
my $res = $ua->request($req);
my $code = $res->code;
my $content = $res->decoded_content;
my $status = $res->status_line;
my $ct = $res->content_type;
my $out = $self->verbose ? "Response: $status ($ct)\n" : undef;
my $data;
view all matches for this distribution
view release on metacpan or search on metacpan
lib/API/Drip/Request.pm view on Meta::CPAN
if ( $result->code == 204 ) {
$self->{debugger}->("Success, no content");
return undef;
}
my $decoded = eval {decode_json( $result->content )};
if ( $@ ) {
$self->{debugger}->('Failed to decode JSON:', $@, $result->content);
die $result;
}
return $decoded;
}
=head1 CONFIGURATION
view all matches for this distribution
view release on metacpan or search on metacpan
lib/API/Eulerian/EDW/Authority.pm view on Meta::CPAN
$class->_success( $kind, $json );
} else {
$status = $class->_error(
$code, $json ?
encode_json( $json ) :
$response->decoded_content
);
}
}
return $status;
view all matches for this distribution
view release on metacpan or search on metacpan
lib/API/Instagram.pm view on Meta::CPAN
# For debugging purposes
print "Requesting: $url$/" if $self->_debug;
# Treats response content
my $res = decode_json $self->_ua->$method( $url, [], $params )->decoded_content;
# Verifies meta node
my $meta = $res->{meta};
carp "$meta->{error_type}: $meta->{error_message}" if $meta->{code} ne '200';
view all matches for this distribution
view release on metacpan or search on metacpan
API/Intis/lib/API/Intis.pm view on Meta::CPAN
while((my $key, my $value) = each %config){
say "$key => $value\n";
next if $key eq 'host' || $key eq 'login' || $key eq 'APIkey';
$url .= "&$key=$value";
};
my $request = $ua->get("$url&return=$format")->decoded_content(charset => 'utf-8', raw => 1);
$request_json = $request if $format eq 'json';
$request_xml = $request if $format eq 'xml';
};
my $r = from_json($request_json);
my @error;
view all matches for this distribution
view release on metacpan or search on metacpan
lib/API/Mathpix.pm view on Meta::CPAN
else {
warn 'Rate limiting !';
}
if ($response->is_success) {
my $data = decode_json($response->decoded_content);
return API::Mathpix::Response->new($data);
}
else {
warn $response->status_line;
}
view all matches for this distribution
view release on metacpan or search on metacpan
t/sentence.t view on Meta::CPAN
# encode word
my $encoded = API::MikroTik::Sentence::_encode_word('bla' x 3);
$encoded .= API::MikroTik::Sentence::_encode_word('bla' x 50);
is length($encoded), 162, 'right length';
is $s->_fetch_word(\$encoded), 'bla' x 3, 'right decoded word';
is length($encoded), 152, 'right length';
is $s->_fetch_word(\$encoded), 'bla' x 50, 'right decoded word';
$packed = encode_sentence('/cmd/1', {a => 1, b => 2});
$packed
.= encode_sentence('/cmd/2', {c => 'foo', d => 'bar'}, {e => 'baz'}, 11);
my $words = $s->fetch(\$packed);
view all matches for this distribution
view release on metacpan or search on metacpan
lib/API/Octopart.pm view on Meta::CPAN
{
last;
}
}
$content = $response->decoded_content;
if (!$response->is_success) {
die "request: " . $req->as_string . "\n" .
"resp: " . $response->as_string;
}
view all matches for this distribution
view release on metacpan or search on metacpan
lib/API/Vultr.pm view on Meta::CPAN
backups => 'enabled',
hostname => 'hostname'
);
if ($create_response->is_success) {
print Dumper($create_response->decoded_content);
}
else {
die $create_response->status_line;
}
view all matches for this distribution
view release on metacpan or search on metacpan
lib/ARGV/JSON.pm view on Meta::CPAN
=head1 SYNOPSIS
use ARGV::JSON;
while (<>) {
# $_ is a decoded JSON here!
}
Or in one-liner:
perl -MARGV::JSON -anal -E 'say $_->{foo}->{bar}' a.json b.json
view all matches for this distribution
view release on metacpan or search on metacpan
lib/ARSObject.pm view on Meta::CPAN
#
# ars_GetEntry(ctrl,schema,entry_id,...) -> (internalId => value,...)
# no ars_GetEntryBLOB(ctrl,schema,entry_id,field_id,locType,locFile)
# no ars_EncodeDiary(diaryEntryHash1, ... diaryEntryHashN)
# encoded 'Status-History'
# decoded 'diary'
#
my ($s, %a) =@_;
my $f =$a{-schema} ||$a{-form} ||$a{-from};
print $s->cpcon("entry(-form=>'$f',-id=>'$a{-id}')\n")
if $s->{-echo} || $a{-echo};
view all matches for this distribution
view release on metacpan or search on metacpan
example/GetFilter.pl view on Meta::CPAN
}
elsif(defined($finfo->{'schemaList'})) {
if(defined($dq)) {
foreach my $s (@{$finfo->{'schemaList'}}) {
$qualtext = ars_Decode_QualHash($ctrl, $s, $dq);
print "Query decoded against form \"$s\" : ".$qualtext."\n";
}
} else {
print "Query : [none defined]\n";
}
}
view all matches for this distribution
view release on metacpan or search on metacpan
lib/ASP4/SimpleCGI.pm view on Meta::CPAN
Returns a URL-encoded version of C<$str>.
=head2 unescape( $str )
Returns a URL-decoded version of C<$str>.
=head2 upload( $field_name )
Returns all of the information we have about a file upload named C<$field_name>.
view all matches for this distribution
view release on metacpan or search on metacpan
lib/AWS/S3/Bucket.pm view on Meta::CPAN
lazy => 1,
clearer => '_clear_acl',
default => sub {
my $self = shift;
my $type = 'GetBucketAccessControl';
return $self->_get_property( $type )->response->decoded_content();
},
trigger => sub {
my ( $self, $new_val, $old_val ) = @_;
my %shorts = map { $_ => undef } qw(
lib/AWS/S3/Bucket.pm view on Meta::CPAN
} else {
die $msg;
} # end if()
} # end if()
return $response->response->decoded_content();
},
trigger => sub {
my ( $self, $policy ) = @_;
my $type = 'SetBucketPolicy';
view all matches for this distribution
view release on metacpan or search on metacpan
lib/AWS/SNS/Verify.pm view on Meta::CPAN
Returns a 1 on success, or die with an L<Ouch> on a failure.
=head2 message
Returns a hash reference of the decoded L<body> that was passed in to the constructor.
=head2 certificate_string
If you want to cache the certificate in a local cache, then get it using this method.
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Acme/Archive/Mbox.pm view on Meta::CPAN
my %attr;
my $name = $message->get('Subject');
for (qw/uid gid mode mtime/) {
$attr{$_} = $message->get("X-AAM-$_");
}
my $contents = ($message->parts())[1]->decoded();
$self->add_data($name, $contents, %attr);
}
$mgr->close($folder);
}
view all matches for this distribution
view release on metacpan or search on metacpan
Buckaroo.pm view on Meta::CPAN
###############################################################################
# this translation array is just for fun, but also for debugging so you can see
# how characters are encoded as they are encoded.
#
# If you try a new encoding method, use this one and you'll be able to see if
# characters are encoded and decoded correctly.
my @xlate_array1 = (qw(
000q 001q 002q 003q 004q 005q 006q 007q 008q 009q
010q 011q 012q 013q 014q 015q 016q 017q 018q 019q
020q 021q 022q 023q 024q 025q 026q 027q 028q 029q
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Acme/Buga.pm view on Meta::CPAN
Encode string into buga text
=head2 decode
my $decoded = $b->decode;
my $decoded = $b->decode('buGa BUGA Buga BUga buGa BUGA BUga BugA BugA BUGA Buga BUga buGa buga');
Decode string into buga text
=head1 AUTHOR
view all matches for this distribution
view release on metacpan or search on metacpan
devdata/https_mojolicious.io_blog_2017_12_16_day-16-the-secret-life-of-sessions view on Meta::CPAN
<p>During each request, the <a href="http://mojolicious.org/perldoc/Mojolicious/Controller#session">session</a> is just another hash reference attached to the controller, in some ways like the <a href="/blog/2017/12/02/day-2-the-stash">stash</a>, exc...
Mojolicious does this by encoding the structure, first as JSON then Base64.
It then signs the resulting string using HMAC-SHA1 and the application's <a href="http://mojolicious.org/perldoc/Mojolicious#secrets">secret</a> to prevent tampering and stores it as a cookie on the response to the client.</p>
<p>On subsequent requests, the client sends the cookie along with the request (as cookies do).
Mojolicious then checks if the document and signature validate against the secret, if so the cookie is decoded and made available again via the session method.</p>
<p>Two important things to note.
First, though the data is safe from tampering, it isn't encrypted; a savvy user can decode the cookie and see the stored data, so don't put anything in it that shouldn't be seen.
Second, this is only useful if the secret is strong and safe.
If not, the client could forge a cookie that appeared to come from your application, possibly with catastrophic results!
view all matches for this distribution
view release on metacpan or search on metacpan
devdata/https_mojolicious.io_blog_2018_12_20_testing-dancer_ view on Meta::CPAN
The first, <code>get_ok</code>, builds a transaction and requests the resource.
Since the url is relative, it is handled by the app (if we wanted we could request and web resource too using a fully qualified url).
The transaction is stored in the tester object (<code>$t</code>) and all following tests will check it until it is replaced by the next request.</p>
<p>The remaining tests are reasonably self-explanatory, we check that the response status was 200, that we got a content type header that we expected and that its content is as we expect.
The content has already been utf-8 decoded, and the script has implicitly <code>use utf8</code>, so if you expected unicode, you can compare them easily.
The tests return the tester object so chaining is possible, making for visually clean sets of tests.</p>
<p>The next test is similar but this one uses the standard <a href="https://mojolicious.org/perldoc/Mojo/UserAgent">Mojo::UserAgent</a> style request generation to build a query string naming Santa for our greeting.
The tests are all the same except of course that it checks that the content greets Santa.</p>
view all matches for this distribution
view release on metacpan or search on metacpan
devdata/http_advent.perldancer.org_2018_20 view on Meta::CPAN
<p>Each of the above method calls is a test.
The first, <code>get_ok</code>, builds a transaction and requests the resource.
Since the url is relative, it is handled by the app (if we wanted we could request and web resource too using a fully qualified url).
The transaction is stored in the tester object (<code>$t</code>) and all following tests will check it until it is replaced by the next request.</p>
<p>The remaining tests are reasonably self-explanatory, we check that the response status was 200, that we got a content type header that we expected and that its content is as we expect.
The content has already been utf-8 decoded, and the script has implicitly <code>use utf8</code>, so if you expected unicode, you can compare them easily.
The tests return the tester object so chaining is possible, making for visually clean sets of tests.</p>
<p>The next test is similar but this one uses the standard <a href="https://mojolicious.org/perldoc/Mojo/UserAgent">Mojo::UserAgent</a> style request generation to build a query string naming Santa for our greeting.
The tests are all the same except of course that it checks that the content greets Santa.</p>
<pre class="prettyprint">$t->get_ok('/text', form => { name => 'santa' })
->status_is(200)
view all matches for this distribution
view release on metacpan or search on metacpan
bin/coinbase.pl view on Meta::CPAN
# add ACCESS_SIGNATURE in a request_prepare handler so we can set it knowing the request content
# ... it doesn't matter for GETs though because the content should be blank (like we see in our code)
$ua->add_handler(
request_prepare => sub {
my($request, $ua, $h) = @_;
my $content = $request->decoded_content(); # empty string.
$content = "" unless defined($content);
my $to_hmac = $nonce . $url . $content;
my $sig = hmac_sha256_hex( $to_hmac, $api_secret );
print "$prog: in callback, str=$to_hmac, ACCESS_SIGNATURE => $sig\n";
bin/coinbase.pl view on Meta::CPAN
}
my $response = $ua->get( $url );
my $noun = $response->is_success() ? "Success" : "Error";
#print ("$prog: $noun " . $response->status_line . ", content: " . $response->decoded_content . "\n");
print ("$prog: $noun " . $response->status_line . ", content: " . $response->content . "\n");
}
}
# this is an example of a header used on the coinbase API, from their docs;
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Acme/Collector64.pm view on Meta::CPAN
This function takes B<binary string> to encode and return the encoded string.
=item $c64->decode($string)
This function takes B<text string> to decode and return the decoded data.
=back
=head1 AUTHOR
view all matches for this distribution