view release on metacpan or search on metacpan
lib/Dancer/Plugin/EncodeID.pm view on Meta::CPAN
#print STDERR "Decoded: '$text'\n";
$cleartext .= $text;
};
if (defined $prefix) {
## Ensure the decoded ID contains the prefix
my $i = index $cleartext,$prefix;
if ($i != 0) {
die "Invalid Hash-ID value ($orig_encoded_id) - bad prefix" ;
}
#skip the prefix;
lib/Dancer/Plugin/EncodeID.pm view on Meta::CPAN
=head1 FUNCTIONS
C<encode_id(ID [,PREFIX])> - Encodes the given ID, returns the encoded hash value.
If "PREFIX" is given, it will be added to the ID before encoding.
It can be used when decoding to verify the decoded value is valid.
C<decode_id(ID [,PREFIX])> - Decodes the given ID, returns the original (cleartext) ID value.
If "PREFIX" is given, it will be used to verify the validity of the ID.
=head1 DESCRIPTION
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Dancer/Plugin/SimpleLexicon.pm view on Meta::CPAN
The value of the default language. If not specified, and the looking up
in the above values fails, no translation will be done.
=head2 encoding
The string returned by maketext will be decoded using
this encoding. By default is C<UTF-8>.
To disable the decoding, set it to C<raw>.
=head1 EXPORT
view all matches for this distribution
view release on metacpan or search on metacpan
lib/CORION/Apache/Tika/Connection/LWP.pm view on Meta::CPAN
my $p = deferred;
my ( $code, $response ) = $self->process_response(
$res->request, # request
$res->code, # code
$res->message, # msg
$res->decoded_content, # body
$res->headers # headers
);
$p->resolve( $code, $response );
$p->promise
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Dancer2/Plugin/Auth/OAuth/Provider/AzureAD.pm view on Meta::CPAN
Accept => "application/json"
);
if ( $resp->is_success ) {
my $user = $self->_stringify_json_booleans(
JSON::MaybeXS::decode_json( $resp->decoded_content )
);
$session_data->{azuread}{user_info} = $user;
} else {
# To-Do: logging error
}
lib/Dancer2/Plugin/Auth/OAuth/Provider/AzureAD.pm view on Meta::CPAN
After login, the following session key will have contents: C<{oauth}{azuread}>
The token will probably be in C<{id_token}>
When log in has occured, the provider attempts to decode the resulting token
for information about the user. All of the decoded information can be found in
the session key: C<{oauth}{azuread}{login_info}>
The login email address, for example, will probably be in a key called
C<{unique_name}>
view all matches for this distribution
view release on metacpan or search on metacpan
t/000-base.t view on Meta::CPAN
my $test = Plack::Test->create(TestApp->to_app);
my $is_client_ok = $test->request(GET '/client_status');
unless ($is_client_ok->decoded_content eq 'available') {
# couldn't call "elastic", assume no local ES cluster
plan 'skip_all', 'ElasticSearch client not instantiable: ' . $is_client_ok->decoded_content;
}
my $count_response = $test->request(GET '/count');
ok($count_response->is_success, '... and we can talk to the ES instance');
my $count = from_json($count_response->decoded_content);
ok(exists $count->{hits},
q{... and the response looks like an ES response});
my $ref1 = $test->request(GET '/client_refname')->decoded_content;
my $ref2 = $test->request(GET '/client_refname')->decoded_content;
is($ref1, $ref2,
qq{... and both calls to elastic() return the same object ($ref1)});
done_testing;
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Dancer2/Plugin/EncryptID.pm view on Meta::CPAN
=head2 dancer_encrypt
C<dancer_encrypt(ID [,PREFIX])> - Encrypt the given ID, returns the encoded hash value.
If "PREFIX" is given, it will be added to the ID before encoding.
It can be used when decoding to verify the decoded value is valid.
=cut
plugin_keywords 'dancer_encrypt';
view all matches for this distribution
view release on metacpan or search on metacpan
t/01-basic.t view on Meta::CPAN
for my $format (qw/atom rss/) {
for my $route ("/feed/$format", "/other/feed/$format") {
ok ($res = $psgi->request( GET $route ) );
is $res->code, 200, "$format - $route";
is ($res->header('Content-Type'), "application/$format+xml");
ok ( $feed = XML::Feed->parse( \$res->decoded_content ) );
is ( $feed->title, 'TestApp with ' . $format );
my @entries = $feed->entries;
is (scalar @entries, 10);
is ($entries[0]->title, 'entry 1');
}
view all matches for this distribution
view release on metacpan or search on metacpan
POST '/graphql',
Content_Type => 'application/json',
Content => '{"query":"{helloWorld}"}',
);
my $json = JSON::MaybeXS->new->allow_nonref;
is_deeply eval { $json->decode( $res->decoded_content ) },
{ 'data' => { 'helloWorld' => 'Hello, world!' } },
'Content as expected';
};
subtest 'GraphQL with route-handler' => sub {
POST '/graphql2',
Content_Type => 'application/json',
Content => '{"query":"{helloWorld}"}',
);
my $json = JSON::MaybeXS->new->allow_nonref;
is_deeply eval { $json->decode( $res->decoded_content ) },
{ 'data' => { 'helloWorld' => 'Hello, world!' } },
'Content as expected';
};
subtest 'GraphQL with die' => sub {
POST '/graphql-live-and-let-die',
Content_Type => 'application/json',
Content => '{"query":"{helloWorld}"}',
);
my $json = JSON::MaybeXS->new->allow_nonref;
is_deeply eval { $json->decode( $res->decoded_content ) },
{ errors => [ { message => "I died!\n" } ] },
'error as expected';
};
subtest 'GraphiQL' => sub {
my $res = $test->request(
GET '/graphql',
Accept => 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
);
like $res->decoded_content, qr/React.createElement\(GraphiQL/, 'Content as expected';
};
done_testing;
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Dancer2/Plugin/JWT.pm view on Meta::CPAN
elsif ($app->request->param('_jwt')) {
$encoded = $app->request->param('_jwt');
}
if ($encoded) {
my $decoded;
eval {
$decoded = decode_jwt( token => $encoded,
key => $secret,
verify_iat => $need_iat,
verify_nbf => $need_nbf,
verify_exp => defined $need_exp ? 1 : 0 ,
leeway => $need_leeway,
lib/Dancer2/Plugin/JWT.pm view on Meta::CPAN
accepted_enc => $enc );
};
if ($@) {
$app->execute_hook('plugin.jwt.jwt_exception' => ($a = $@)); # this is weird, but required!
};
$app->request->var('jwt', $decoded);
$app->request->var('jwt_status' => 'present');
}
else {
## no token
lib/Dancer2/Plugin/JWT.pm view on Meta::CPAN
$dsl->app->add_hook(
Dancer2::Core::Hook->new(
name => 'after',
code => sub {
my $response = shift;
my $decoded = $dsl->app->request->var('jwt');
if($set_authorization_header || $set_cookie_header || $set_location_header) {
# If all are disabled, then skip also encoding!
if (defined($decoded)) {
my $encoded = encode_jwt( payload => $decoded,
key => $secret,
alg => $alg,
enc => $enc,
auto_iat => $need_iat,
relative_exp => $need_exp,
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Dancer2/Plugin/LiteBlog/Scaffolder.pm view on Meta::CPAN
my ($base64_content, $output_path) = @_;
# Decode the base64 string
my $binary_data = decode_base64($base64_content);
# Write the decoded binary data to a file
write_file($output_path, {binmode => ':raw'}, $binary_data);
}
sub scaffold {
my ($basedir, $force) = @_;
view all matches for this distribution
view release on metacpan or search on metacpan
my $code = $uri->query_param( 'code' );
$request = POST '/access_token', Content => [ client_id => 'client1', client_secret => 'secret', grant_type => 'authorization_code', code => $code, redirect_uri => 'http://localhost/callback' ];
$response = $test->request($request);
is $response->code, 200, "Access token route working";
my $decoded = from_json( $response->content );
ok exists $decoded->{access_token}, "Access token provided";
ok exists $decoded->{refresh_token}, "Refresh token provided";
my $access_token = $decoded->{access_token};
my $refresh_token = $decoded->{refresh_token};
$request = HTTP::Request->new( GET => '/protected-identity' );
$request->header( Authorization => "Bearer $access_token");
$response = $test->request($request);
is $response->code, 200, "With bearer, protected route OK";
is $response->code, 400, "With bearer, protected route with another scope KO";
$request = POST '/access_token', Content => [ client_id => 'client1', client_secret => 'secret', grant_type => 'refresh_token', refresh_token => $refresh_token ];
$response = $test->request($request);
is $response->code, 200, "Refresh access token succesfully";
$decoded = from_json( $response->content );
ok exists $decoded->{access_token}, "Access token provided";
ok exists $decoded->{refresh_token}, "Refresh token provided";
my $new_access_token = $decoded->{access_token};
my $new_refresh_token = $decoded->{refresh_token};
isnt $new_access_token, $access_token, "Access token has changed";
isnt $new_refresh_token, $refresh_token, "Refresh token has changed";
#ok exists $decoded->{access_token}, "Access token provided";
$request = HTTP::Request->new( GET => '/protected-identity' );
$request->header( Authorization => "Bearer $new_access_token");
$response = $test->request($request);
is $response->code, 200, "With bearer, new access token, protected route OK";
my $code = $uri->query_param( 'code' );
$request = POST '/access_token', Content => [ client_id => 'client2', client_secret => 'secret2', grant_type => 'authorization_code', code => $code, redirect_uri => 'http://localhost/callback' ];
$response = $test->request($request);
is $response->code, 200, "Access token route working";
my $decoded = from_json( $response->content );
ok exists $decoded->{access_token}, "Access token provided";
ok exists $decoded->{refresh_token}, "Refresh token provided";
my $access_token = $decoded->{access_token};
my $refresh_token = $decoded->{refresh_token};
$request = HTTP::Request->new( GET => '/protected-identity' );
$request->header( Authorization => "Bearer $access_token");
$response = $test->request($request);
is $response->code, 200, "With bearer, protected route OK";
my $code = $uri->query_param( 'code' );
$request = POST '/access_token', Content => [ client_id => 'client2', client_secret => 'secret2', grant_type => 'authorization_code', code => $code, redirect_uri => 'http://localhost/callback' ];
$response = $test->request($request);
is $response->code, 200, "Access token route working";
my $decoded = from_json( $response->content );
ok exists $decoded->{access_token}, "Access token provided";
ok exists $decoded->{refresh_token}, "Refresh token provided";
my $access_token = $decoded->{access_token};
my $refresh_token = $decoded->{refresh_token};
$request = HTTP::Request->new( GET => '/protected-identity' );
$request->header( Authorization => "Bearer $access_token");
$response = $test->request($request);
is $response->code, 200, "With bearer, protected route OK";
my $code = $uri->query_param( 'code' );
$request = POST '/access_token', Content => [ client_id => 'client2', client_secret => 'secret2', grant_type => 'authorization_code', code => $code, redirect_uri => 'http://localhost/callback' ];
$response = $test->request($request);
is $response->code, 200, "Access token route working";
my $decoded = from_json( $response->content );
ok exists $decoded->{access_token}, "Access token provided";
ok exists $decoded->{refresh_token}, "Refresh token provided";
#try to use the same code a second time
$response = $test->request($request);
is $response->code, 400, "Access token route not working, authorization code already consumed";
my $decoded = from_json( $response->content );
ok !exists $decoded->{access_token}, "Access token not provided";
ok !exists $decoded->{refresh_token}, "Refresh token not provided";
#Wrong scope
my $uri = URI->new( '/authorize' );
$uri->query_param( client_id => 'client1' );
$uri->query_param( redirect_uri => 'http://localhost/callback' );
view all matches for this distribution
view release on metacpan or search on metacpan
my $test = Plack::Test->create( Local::App->to_app );
subtest 'Static URL' => sub {
is $test->request( GET '/static/url?query=parameter' ), object {
call decoded_content => 'OK';
}, 'Request OK';
is $span->{otel}, {
attributes => {
'client.address' => '127.0.0.1',
], 'Expected calls on span';
};
subtest 'Forward' => sub {
is $test->request( GET '/forward' ), object {
call decoded_content => 'OK';
}, 'Request OK';
is $span->{otel}, {
attributes => {
'client.address' => '127.0.0.1',
], 'Expected calls on span';
};
subtest 'Pass' => sub {
is $test->request( GET '/url/with/pass' ), object {
call decoded_content => 'OK';
}, 'Request OK';
is $span->{otel}, {
attributes => {
'client.address' => '127.0.0.1',
subtest 'Async' => sub {
require Test2::Require::Module;
Test2::Require::Module->import('IO::Async');
is $test->request( GET '/async', user_agent => 'Test' ), object {
call decoded_content => 'OK';
}, 'Request OK';
is $span->{otel}, {
attributes => {
'client.address' => '127.0.0.1',
], 'Expected calls on span';
};
subtest 'With placeholder' => sub {
is $test->request( GET '/url/with/value' ), object {
call decoded_content => 'OK';
}, 'Request OK';
is $span->{otel}, {
attributes => {
'client.address' => '127.0.0.1',
};
subtest 'Response code' => sub {
is $test->request( GET '/status/400' ), object {
call code => 400;
call decoded_content => 'OK';
}, 'Request OK';
is $span->{otel}, {
attributes => {
'client.address' => '127.0.0.1',
view all matches for this distribution
view release on metacpan or search on metacpan
subtest 'Route param' => sub {
my $res = $test->request(
POST '/route/foo?param=bar', Content => [ param => 'baz' ]
);
is( $res->decoded_content, 'foo', 'Route returns foo' );
};
subtest 'Query param' => sub {
my $res = $test->request(
POST '/query/foo?param=bar', Content => [ param => 'baz' ]
);
is( $res->decoded_content, 'bar', 'Query returns bar' );
};
subtest 'Body param' => sub {
my $res = $test->request(
POST '/body/foo?param=bar', Content => [ param => 'baz' ]
);
is( $res->decoded_content, 'baz', 'Body returns baz' );
};
subtest 'All params' => sub {
my $res = $test->request(
POST '/params/foo?param=bar', Content => [ param => 'baz' ]
);
is( $res->decoded_content, 'foo bar baz', 'All params returns foo bar baz' );
};
subtest 'Munged params route' => sub {
my $res = $test->request(
POST '/munged/foo?param=bar', Content => [ param => 'baz' ]
);
is( $res->decoded_content, 'foo', 'Munge honors route' );
};
subtest 'Munged params query' => sub {
my $res = $test->request(
POST '/munged?param=bar', Content => [ param => 'baz' ]
);
is( $res->decoded_content, 'bar', 'Munge honors query' );
};
subtest 'Munged params body' => sub {
my $res = $test->request(
POST '/munged', Content => [ param => 'baz' ]
);
is( $res->decoded_content, 'baz', 'Munge honors body' );
};
subtest 'Munged param route' => sub {
my $res = $test->request(
POST '/munged_singular/foo?param=bar', Content => [ param => 'baz' ]
);
is( $res->decoded_content, 'foo', 'Munge singular honors route' );
};
subtest 'Munged param query' => sub {
my $res = $test->request(
POST '/munged_singular?param=bar', Content => [ param => 'baz' ]
);
is( $res->decoded_content, 'bar', 'Munge singular honors query' );
};
subtest 'Munged param body' => sub {
my $res = $test->request(
POST '/munged_singular', Content => [ param => 'baz' ]
);
is( $res->decoded_content, 'baz', 'Munge singular honors body' );
};
done_testing;
view all matches for this distribution
view release on metacpan or search on metacpan
t/test-progress.t view on Meta::CPAN
ok( $response1->is_success, 'Response ok when setting and updating progress' );
my $response2 = $app->request( GET '/_progress_status/test' );
ok($response2->is_success, 'Get good response from progressstatus');
my $data = $json->decode($response2->decoded_content);
is($data->{total}, 100, 'Total is 100');
is($data->{count}, 2, 'Count matches total');
ok(!$data->{in_progress}, 'No longer in progress');
}
t/test-progress.t view on Meta::CPAN
{
my $response1 = $app->request( GET '/test_progress_status_with_args' );
ok( $response1->is_success, 'Success for less simple progress' );
my $response2 = $app->request( GET '/_progress_status/test2' );
my $data = $json->decode($response2->decoded_content);
is($data->{total}, 200, 'Total is 200');
is($data->{count}, 3, 'Count matches total');
is(scalar(@{$data->{messages}}), 2, 'Has two messages');
ok(!$data->{in_progress}, 'No longer in progress');
}
t/test-progress.t view on Meta::CPAN
ok($response1->is_success, 'Two progress meters with the same name and same pid pass');
like($response1->content, qr/^Progress status test3 already exists/,
'two unfinished progress meters with the same name dies');
my $response2 = $app->request( GET '/_progress_status/test3' );
my $data = $json->decode($response2->decoded_content);
is($data->{total}, 200, 'Total is overriden');
}
{
## Test progress status with automatic ID
my $response1 = $app->request(GET '/test_progress_with_progress_id?progress_id=1000');
ok($response1->is_success, '200 response for progress with progress id');
my $response2 = $app->request(GET '/_progress_status/1000');
ok($response2->is_success, 'Get good response from progressstatus');
my $data = $json->decode($response2->decoded_content);
is($data->{total}, 100, 'Get a sensible response');
}
done_testing(17); # number of tests + Test::Warnings
view all matches for this distribution
view release on metacpan or search on metacpan
t/100-xmlrpc.t view on Meta::CPAN
<params/>
</methodCall>
EOXML
);
my $response = $tester->request($request);
my $value = $p->parse($response->decoded_content)->value->value;
is_deeply(
$value,
'pong',
"ping"
) or diag(explain($value));
t/100-xmlrpc.t view on Meta::CPAN
EOXML
);
my $response = $tester->request($request);
is($response->status_line, '200 OK', "OK response");
my $methods = $p->parse($response->decoded_content)->value->value;
is_deeply(
$methods,
{
'/endpoint' => [qw/
methodList
view all matches for this distribution
view release on metacpan or search on metacpan
my $req = HTTP::Request->new( $method => "http://localhost$uri" );
my $res = $cb->($req);
subtest "$method $uri" => sub {
plan tests => $expected_response ? 2 : 1;
ok( $res->is_success, "request successful for $method $uri" );
like( $res->decoded_content, $expected_response, "expected response content for $method $uri" )
if $expected_response;
};
return;
};
test_psgi( $app, $client );
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Dancer2/Plugin/WebSocket.pm view on Meta::CPAN
=over
=item serializer
If serializer is set to a C<true> value, messages will be assumed to be JSON
objects and will be automatically encoded/decoded using a L<JSON::MaybeXS>
serializer. If the value of C<serializer> is a hash, it'll be passed as
arguments to the L<JSON::MaybeXS> constructor.
plugins:
WebSocket:
view all matches for this distribution
view release on metacpan or search on metacpan
t/deserialize.t view on Meta::CPAN
};
}
note "Decoding of mixed route and deserialized body params"; {
# Check integers from request body remain integers
# but route params get decoded.
test_psgi $app, sub {
my $cb = shift;
my @req_params = (
"/from/D\x{c3}\x{bc}sseldorf", # /from/d%C3%BCsseldorf
t/deserialize.t view on Meta::CPAN
# Watch out for hash order randomization..
is_deeply(
$r->content,
'["population",592393,"town","'."D\x{c3}\x{bc}sseldorf".'"]',
"Integer from JSON body remains integer and route params decoded",
);
};
}
# Check body is deserialized on PATCH and DELETE.
view all matches for this distribution
view release on metacpan or search on metacpan
[BUG FIXES]
* Fix generating new sessions for every request
(Peter Mottram, Rory Zweistra, GH #9).
* Use decoded_content instead of content in UTF-8 tests
(Peter Mottram, GH #8).
[TESTS]
* Stop Test::More complaining about wide chars in print (Peter Mottram).
view all matches for this distribution
view release on metacpan or search on metacpan
t/Dancer2-Session-DatabasePlugin.t view on Meta::CPAN
{
my $req=GET '/session/fetch',Cookie=>$cookie;
my $res = $test->request( $req );
cmp_ok($res->code,'==',200,'Should get a 200');
ok($cookie=$res->header($h),'Should have a cookie!');
cmp_ok($res->decoded_content,'eq','I am a little teapot.');
cmp_ok(keys(%{$SESSION->sth_cache}),'>',0,'Should have more than 0 statement handles');
}
{
my $req=GET '/session/fetch',Cookie=>$cookie;
my $res = $test->request( $req );
cmp_ok($res->code,'==',200,'Should get a 200');
ok($cookie=$res->header($h),'Should have a cookie!');
cmp_ok($res->decoded_content,'eq','I am a little teapot.');
cmp_ok(keys(%{$SESSION->sth_cache}),'>',0,'Should have more than 0 statement handles');
my @keys=keys %{$saved};
is_deeply($saved,$SESSION->sth_cache,'Should have the same sth cache in both places') or die "Cannot continue testing";
ok(join('',@{$saved}{@keys}) eq join('',@{$SESSION->sth_cache}{@keys}),'Statement handles should be cached') or die "cannot continue testing";
t/Dancer2-Session-DatabasePlugin.t view on Meta::CPAN
{
my $req=GET '/session/fetch',Cookie=>$cookie;
my $res = $test->request( $req );
cmp_ok($res->code,'==',200,'Should get a 200');
ok($cookie=$res->header($h),'Should have a cookie!');
cmp_ok($res->decoded_content,'eq','I am a little teapot.');
cmp_ok(keys(%{$SESSION->sth_cache}),'>',0,'Should have more than 0 statement handles');
}
{
my $req=GET 'disconnect2',Cookie=>$cookie;
my $res = $test->request( $req );
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Dancer2/Session/Memcached.pm view on Meta::CPAN
$self->_flush( $new_id, $self->_retrieve( $old_id ) );
$self->_destroy( $old_id );
}
# reject anything where the first two bytes are below \x20 once
# Base64 decoded, ensuring Storable doesnt attempt to thaw such cruft.
sub validate_id {
$_[1] =~ m/^[I-Za-z0-9_\-~][A-Za-z0-9_\-~]+$/;
}
1;
view all matches for this distribution
view release on metacpan or search on metacpan
my $res = $cb->($req);
$jar->extract_cookies($res);
subtest "$method $uri" => sub {
plan tests => $expected_response ? 2 : 1;
ok( $res->is_success, "request successful for $method $uri" );
like( $res->decoded_content, $expected_response, "expected response content for $method $uri" )
if $expected_response;
};
return;
};
test_psgi( $app, $client );
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Dancer2/Core/Request.pm view on Meta::CPAN
# Private 'read-only' attributes for request params. See the params()
# method for the public interface.
#
# _body_params, _query_params and _route_params have setter methods that
# decode byte string to characters before setting; If you know you have
# decoded (character) params, such as output from a deserializer, you can
# set these directly in the request object hash to avoid the decode op.
sub _params { $_[0]->{'_params'} ||= $_[0]->_build_params }
sub _has_params { defined $_[0]->{'_params'} }
lib/Dancer2/Core/Request.pm view on Meta::CPAN
# returns characters and skipping the decode op in the setter ensures
# that numerical data "stays" numerical; decoding an SV that is an IV
# converts that to a PVIV. Some serializers are picky (JSON)..
$self->{_body_params} = $data;
# Set body parameters (decoded HMV)
$self->{'body_parameters'} =
Hash::MultiValue->from_mixed( is_hashref($data) ? %$data : () );
return $data;
}
lib/Dancer2/Core/Request.pm view on Meta::CPAN
if ($type) {
my $attr = "${type}_parameters";
return $self->$attr;
}
# merge together the *decoded* parameters
$self->{'merged_parameters'} ||= do {
my $query = $self->query_parameters;
my $body = $self->body_parameters;
my $route = $self->route_parameters; # not in Plack::Request
Hash::MultiValue->new( map $_->flatten, $query, $body, $route );
lib/Dancer2/Core/Request.pm view on Meta::CPAN
$new_params->{$key} = $value;
$new_request->{_query_params}->{$key} = $value;
$new_request->{query_parameters}->add( $key => $value );
}
# Copy params (these are already decoded)
$new_request->{_params} = $new_params;
$new_request->{_body_params} = $self->{_body_params};
$new_request->{_route_params} = $self->{_route_params};
$new_request->{headers} = $self->headers;
# Copy remaining settings
$new_request->{is_behind_proxy} = $self->{is_behind_proxy};
$new_request->{vars} = $self->{vars};
# Clone any existing decoded & cached body params. (GH#1116 GH#1269)
$new_request->{'body_parameters'} = $self->body_parameters->clone;
# Delete merged HMV parameters, allowing them to be reconstructed on first use.
delete $new_request->{'merged_parameters'};
lib/Dancer2/Core/Request.pm view on Meta::CPAN
Returns the body of the request in data form, making it possible to distinguish
between C<body_parameters>, a representation of the request parameters
(L<Hash::MultiValue>) and other forms of content.
If a serializer is set, this is the deserialized request body. Otherwise this is
the decoded body parameters (if any), or the body content itself.
=head2 content
Returns the undecoded byte string POST body.
=head2 cookies
Returns a reference to a hash containing cookies, where the keys are the names of the
cookies and values are L<Dancer2::Core::Cookie> objects.
lib/Dancer2/Core/Request.pm view on Meta::CPAN
Alias to the C<method> accessor, for backward-compatibility with C<CGI> interface.
=head2 request_uri
Return the raw, undecoded request URI path.
=head2 route
Return the L<route|Dancer2::Core::Route> which this request matched.
view all matches for this distribution
view release on metacpan or search on metacpan
share/assets/dash_core_components/async~markdown.js.map view on Meta::CPAN
{"version":3,"sources":["webpack:///./node_modules/is-whitespace-character/index.js","webpack:///./node_modules/xtend/immutable.js","webpack:///./node_modules/trim/index.js","webpack:///./node_modules/is-decimal/index.js","webpack:///./node_modules/u...
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Data/Apache/mod_status.pm view on Meta::CPAN
my $response = $ua->get($url);
die 'failed to fetch "', $url, '" - '.$response->status_line
if $response->is_error();
# tidy mod_status page to be xhtml document
return $response->decoded_content;
}
"Zed's Dead, baby";
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Data/BISON/Decoder.pm view on Meta::CPAN
Create a new Data::BISON::Encoder.
=item C<< decode >>
Decode BISON serialized data. The data to be decoded may optionally have
been yEnc encoded; C<decode> will detect this and perform the
appropriate decoding.
The returned value is a scalar, hash reference or array reference.
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Data/Binary.pm view on Meta::CPAN
my $length = length($string);
my $odd = ($string =~ tr/\x01\x02\x03\x04\x05\x06\x07\x09\x0b\x0c\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f//d);
# Detecting >=128 and non-UTF-8 is interesting. Note that all UTF-8 >=128 has several bytes with
# >=128 set, so a quick test is possible by simply checking if any are >=128. However, the count
# from that is typically wrong, if this is binary data, it'll not have been decoded. So we do this
# in two steps.
my $copy = $string;
if (($copy =~ tr[\x80-\xff][]d) > 0) {
my $modified = decode_utf8($string, Encode::FB_DEFAULT);
view all matches for this distribution
view release on metacpan or search on metacpan
examples/integercoding.pl view on Meta::CPAN
$str = encode_delta(8); # die unless $str eq '00100000';
$str = encode_omega(8); # die unless $str eq '1110000';
$str = encode_fib(8); # die unless $str eq '000011';
The C<decode_> methods take a single binary string as input and produce an
unsigned integer output decoded from the bit encoding.
$n = decode_unary('000000000000001'); # die unless $n == 14;
$n = decode_gamma('0001110'); # die unless $n == 14;
$n = decode_delta('00100110'); # die unless $n == 14;
$n = decode_omega('1111100'); # die unless $n == 14;
view all matches for this distribution
view release on metacpan or search on metacpan
examples/compression-code.pl view on Meta::CPAN
my $e1 = int(tv_interval($s1)*1_000_000);
my $s2 = [gettimeofday];
@list = $stream->get_unary(-1);
my $e2 = int(tv_interval($s2)*1_000_000);
$listn = scalar @list;
printf "Slurped $listn numbers in %.1f ms, decoded in %.1f ms\n", $e1/1000,$e2/1000;
}
# average value
my $avg = int( ((sum @list) / $listn) + 0.5);
# bytes required in fixed size (FOR encoding)
view all matches for this distribution
view release on metacpan or search on metacpan
=over 4
=item _ReturnMap = 1 unless exists
_ReturnMap says that returns embedded in fields should be decoded on
read() and encoded again on write(). The industry-standard encoding
for embedded returns is ^K (ascii 11 -- but see next setting to change
it). This defaults to true but can be turned off if you want data
untouched by read(). This setting has no effect on data files where
no fields contain embedded returns. However, it is vital to leave
this option ON when writing any data file whose fields could contain
embedded returns -- if you have such data and call write() with
_ReturnMap turned off, the resulting file will be an invalid Merge/CSV
file and might not be re-readable.
When these fields are decoded on read(), encoded returns are converted
to C<"\n"> in memory, whatever its interpretation may be on the current
platform (\x0A on Unix or DOS; \x0D on MacPerl).
IMPORTANT NOTE: When these fields are encoded by write(), any
occurrence of the current _LineEnding being used to write the file is
view all matches for this distribution