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


Catalyst-Plugin-Authentication-Credential-GooglePlus

 view release on metacpan or  search on metacpan

lib/Catalyst/Plugin/Authentication/Credential/GooglePlus.pm  view on Meta::CPAN

=back

=head3 RETURNS

User found by calling L<Catalyst::Authentication::Realm/find_user> with the
decoded token's information, if any.

=cut

sub authenticate {
    my ($self, $c, $realm, $authinfo) = @_;

lib/Catalyst/Plugin/Authentication/Credential/GooglePlus.pm  view on Meta::CPAN

}

=head2 retrieve_certs

Retrieves a pair of JSON-encoded certificates from the given $url (defaults to
Google's public cert url), and returns the decoded JSON object.

If a cache plugin is loaded, the certificate pair is cached; however one of the
certificates is expired, a new pair is fetched from $url.

=head3 ARGUMENTS

lib/Catalyst/Plugin/Authentication/Credential/GooglePlus.pm  view on Meta::CPAN

    return time > $expiry;
}

=head2 decode

Returns the decoded information contained in a user's token.

=head3 ARGUMENTS

=over

 view all matches for this distribution


Catalyst-Plugin-ConfigLoader-Environment

 view release on metacpan or  search on metacpan

lib/Catalyst/Plugin/ConfigLoader/Environment.pm  view on Meta::CPAN


Double colons are converted into double underscores.  For
compatibility's sake, support for the 0.01-style use of
bourne-incompatible variable names is retained.

Values are JSON-decoded if they look like JSON arrays or objects
(i.e. if they're enclosed in []s or {}s). Taking advantage of that, we
can write the same example this way:

    MYAPP_name=MyApp
    MYAPP_title=This is My App!

 view all matches for this distribution


Catalyst-Plugin-EncryptID

 view release on metacpan or  search on metacpan

lib/Catalyst/Plugin/EncryptID.pm  view on Meta::CPAN


=head2 encrypt_data

C<encrypt_data(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

sub encrypt_data {
	my( $c, $text, $prefix ) = @_;

 view all matches for this distribution


Catalyst-Plugin-HTML-Scrubber

 view release on metacpan or  search on metacpan

lib/Catalyst/Plugin/HTML/Scrubber.pm  view on Meta::CPAN


    # Firstly, if an entry in ignore_urls matches, then we don't want to
    # scrub anything for this request...
    return if ($c->_req_path_exempt_from_scrubbing($conf));

    # If there's body_data - for e.g. a POSTed JSON body that was decoded -
    # then we need to walk through it, scrubbing as appropriate; don't call
    # body_data unless the content type is one there's a data handler for
    # though, otherwise we'll trigger an exception (see GH#4)
    if (exists $c->req->data_handlers->{ $c->req->content_type }) {
        if (my $body_data = $c->request->body_data) {

 view all matches for this distribution


Catalyst-Plugin-Session-Store-Cookie

 view release on metacpan or  search on metacpan

lib/Catalyst/Plugin/Session/Store/Cookie.pm  view on Meta::CPAN


sub get_session_data {
  my ($self, $key) = @_;
  $self->_needs_early_session_finalization(1);

  # Don't decode if we've decoded this context already.
  return $self->{__cookie_session_store_cache__}->{$key} if
    exists($self->{__cookie_session_store_cache__}) &&
      exists($self->{__cookie_session_store_cache__}->{$key});

  my $cookie = $self->req->cookie($self->_store_cookie_name);

lib/Catalyst/Plugin/Session/Store/Cookie.pm  view on Meta::CPAN

  return $self->{__cookie_session_store_cache__}->{$key};
}

sub _decode_secure_store {
  my ($self, $cookie, $key) = @_;
  my $decoded = eval {
    $self->_secure_store->decode($cookie->value);
  } || do {
    $self->log->error("Issue decoding cookie for key '$key': $@");
    return +{};
  };
  return $decoded;
}

sub store_session_data {
  my ($self, $key, $data) = @_;

 view all matches for this distribution


Catalyst-Plugin-Session

 view release on metacpan or  search on metacpan

t/live_expiry_threshold.t  view on Meta::CPAN

my $ua = MiniUA->new('SessionExpiry');

my $res = $ua->get( "http://localhost/session_data_expires" );
ok($res->is_success, "session_data_expires");

my $expiry = $res->decoded_content + 0;

$res = $ua->get( "http://localhost/session_expires" );
ok($res->is_success, "session_expires");
is($res->decoded_content, $expiry, "session_expires == session_data_expires");

sleep(1);

$res = $ua->get( "http://localhost/session_data_expires" );
ok($res->is_success, "session_data_expires");

is($res->decoded_content, $expiry, "expiration not updated");

$res = $ua->get( "http://localhost/session_expires" );
ok($res->is_success, "session_expires");
is($res->decoded_content, $expiry, "session_expires == session_data_expires");

#

$res = $ua->get( "http://localhost/update_session" );
ok($res->is_success, "update_session");

$res = $ua->get( "http://localhost/session_data_expires" );
ok($res->is_success, "session_data_expires");

my $updated = $res->decoded_content + 0;
ok($updated > $expiry, "expiration updated");

$expiry = $updated;

$res = $ua->get( "http://localhost/session_data_expires" );
ok($res->is_success, "session_data_expires");

is($res->decoded_content, $expiry, "expiration not updated");

$res = $ua->get( "http://localhost/session_expires" );
ok($res->is_success, "session_expires");
is($res->decoded_content, $expiry, "session_expires == session_data_expires");

sleep(10);

$res = $ua->get( "http://localhost/session_data_expires" );
ok($res->is_success, "session_data_expires");

$updated = $res->decoded_content + 0;
ok($updated > $expiry, "expiration updated");

$res = $ua->get( "http://localhost/session_expires" );
ok($res->is_success, "session_expires");
is($res->decoded_content, $updated, "session_expires == session_data_expires");

done_testing;

 view all matches for this distribution


Catalyst-Plugin-Shorten

 view release on metacpan or  search on metacpan

t/05-fails.t  view on Meta::CPAN

$content = request('/params?s=FU');
is_deeply($content->code, 500, 'invalid');

$content = request('/extract');
is_deeply($content->code, 200, 'invalid as missing s param but returns {}');
is($content->decoded_content, '{}', 'content empty {}');


done_testing();

 view all matches for this distribution


Catalyst-Plugin-Static-File

 view release on metacpan or  search on metacpan

t/10-catalyst.t  view on Meta::CPAN

    my $res = request( GET '/?file=' . $file->basename );
    is $res->code,            HTTP_OK,            "status";
    is $res->content_type,    "text/plain",       "content_type";
    is $res->content_length,  $file->stat->size,  "content_length";
    is $res->last_modified,   $file->stat->mtime, "last_modified";
    is $res->decoded_content, $file->slurp_raw,   "content";
};

subtest "file with type" => sub {

    my $file = path($Bin)->child("static/hello.txt");

t/10-catalyst.t  view on Meta::CPAN

    my $res = request( GET '/?type=foo/bar&file=' . $file->basename );
    is $res->code,            HTTP_OK,            "status";
    is $res->content_type,    "foo/bar",          "content_type";
    is $res->content_length,  $file->stat->size,  "content_length";
    is $res->last_modified,   $file->stat->mtime, "last_modified";
    is $res->decoded_content, $file->slurp_raw,   "content";
};

subtest "bad file" => sub {

    my $file = path($Bin)->child("static/hello.txt.bad");

 view all matches for this distribution


Catalyst-Plugin-Unicode

 view release on metacpan or  search on metacpan

t/lib/TestApp/Controller/Root.pm  view on Meta::CPAN

}

sub unicode :Local {
    my ($self, $c) = @_;
    my $data = "ほげ"; # hoge!
    $c->response->body($data); # should be decoded
}

sub not_unicode :Local {
    my ($self, $c) = @_;
    my $data = "\x{1234}\x{5678}";

 view all matches for this distribution


Catalyst-Runtime

 view release on metacpan or  search on metacpan

lib/Catalyst.pm  view on Meta::CPAN

Hook to let you customize how encoding errors are handled. By default
we just throw an exception and the default error page will pick it up.
Receives a hashref of debug information. Example of call (from the
Catalyst internals):

  my $decoded_after_fail = $c->handle_unicode_encoding_exception({
        param_value => $value,
        error_msg => $_,
        encoding_step => 'params',
   });

The calling code expects to receive a decoded string or an exception.

You can override this for custom handling of unicode errors. By
default we just die. If you want a custom response here, one approach
is to throw an HTTP style exception, instead of returning a decoded
string or throwing a generic exception.

    sub handle_unicode_encoding_exception {
      my ($c, $params) = @_;
      HTTP::Exception::BAD_REQUEST->throw(status_message=>$params->{error_msg});

lib/Catalyst.pm  view on Meta::CPAN

The allows the application to behave correctly when C<mod_rewrite> is being used to redirect requests
into the application, as these variables are adjusted by mod_rewrite to take account for the redirect.

However this method has the major disadvantage that it is impossible to correctly decode some elements
of the path, as RFC 3875 says: "C<< Unlike a URI path, the PATH_INFO is not URL-encoded, and cannot
contain path-segment parameters. >>" This means PATH_INFO is B<always> decoded, and therefore Catalyst
can't distinguish / vs %2F in paths (in addition to other encoded values).

=item use_request_uri_for_path => 1

This method uses the C<REQUEST_URI> and C<SCRIPT_NAME> environment variables. As C<REQUEST_URI> is never
decoded, this means that applications using this mode can correctly handle URIs including the %2F character
(i.e. with C<AllowEncodedSlashes> set to C<On> in Apache).

Given that this method of path resolution is provably more correct, it is recommended that you use
this unless you have a specific need to deploy your application in a non-standard environment, and you are
aware of the implications of not being able to handle encoded URI paths correctly.

lib/Catalyst.pm  view on Meta::CPAN


=over

=item param_value

The value which was not able to be decoded.

=item error_msg

The exception received from L<Encode>.

=item encoding_step

What type of data was being decoded. Valid values are (currently)
C<params> - for request parameters / arguments / captures
and C<uploads> - for request upload filenames.

=back

 view all matches for this distribution


Catalyst-TraitFor-Request-DecodedParams

 view release on metacpan or  search on metacpan

lib/Catalyst/TraitFor/Request/DecodedParams.pm  view on Meta::CPAN

has '_params_decoder' => (
    init_arg => undef, is => 'ro',
    lazy => 1, builder => '_build_params_decoder',
);

has decoded_params => (
    init_arg => undef, isa => 'HashRef',
    is => 'ro', lazy => 1, builder => '_build_decoded_params',
);

sub _build_decoded_params {
    my $self = shift;
    return $self->_do_decode_params($self->params);
}

sub decoded_parameters { return shift->decoded_params }

sub dparams { return shift->decoded_params }

has decoded_query_params => (
    init_arg => undef, isa => 'HashRef',
    is => 'ro', lazy => 1, builder => '_build_decoded_query_params',
);

sub _build_decoded_query_params {
    my $self = shift;
    return $self->_do_decode_params($self->query_params);
}

sub decoded_query_parameters { return shift->decoded_query_params }

sub dquery_params { return shift->decoded_query_params }

has decoded_body_params => (
    init_arg => undef, isa => 'HashRef',
    is => 'ro', lazy => 1, builder => '_build_decoded_body_params',
);

sub _build_decoded_body_params {
    my $self = shift;
    return $self->_do_decode_params($self->body_params);
}

sub decoded_body_parameters { return shift->decoded_body_params }

sub dbody_params { return shift->decoded_body_params }

1;

__END__

lib/Catalyst/TraitFor/Request/DecodedParams.pm  view on Meta::CPAN


=head1 METHODS

=over

=item decoded_query_parameters

decoded_query_params, dquery_params

=item decoded_body_parameters

decoded_body_params, dbody_params

=item decoded_parameters

decoded_params, dparams

=back

=head1 AUTHOR

 view all matches for this distribution


Catalyst-View-TT

 view release on metacpan or  search on metacpan

t/utf8.t  view on Meta::CPAN

use Catalyst::Test 'MyApp';

if(MyApp->can('encoding') and MyApp->can('clear_encoding') ) {
  ok my $res = request '/root/♥';
  is $res->code, 200, 'OK';
  is $res->decoded_content, "<p>This heart literal ♥</p><p>This is heart var ♥♥♥</p>\n", 'correct body';
  is $res->content_charset, 'UTF-8';
} else {
  ok 1, 'Skipping the UTF8 Tests for older installed catalyst';
}

 view all matches for this distribution


Catalyst-View-Template

 view release on metacpan or  search on metacpan

t/basic.t  view on Meta::CPAN

SKIP: {
	skip 'No UTF-8 tests on older Catalyst', 4 unless $have_encoding;
	ok $response = request( '/♥' ), 'Unicode path request';
	is $response->code, 200, '... succeeds';
	is $response->content_charset, 'UTF-8', '... with the expected response charset';
	is $response->decoded_content, "<p>Heart literal ♥</p><p>Heart variable ♥♥♥</p>\n", '... and the expected body';
}

my @view;
BEGIN { $num_tests += 6 * ( @view = qw( PkgConfig AppConfig TemplateClass ) ) }
for my $view ( @view ) {

 view all matches for this distribution


Catalyst-View-Vega

 view release on metacpan or  search on metacpan

t/basic.t  view on Meta::CPAN


{
    my ($res, $c) = ctx_request('/error/bad-name');
    ok($res, '/error/bad-name');
    is($res->code, 500, "status is 500")
        or die $res->decoded_content;
    like($c->error->[-1], qr/cannot find a dataset named «DNE»/, "error message matches");
}

done_testing;

 view all matches for this distribution


CatalystX-Controller-PSGI

 view release on metacpan or  search on metacpan

t/00-catalyst-controller-psgi.t  view on Meta::CPAN

subtest 'normal actions' => sub {
    plan tests => 5;

    my $res = request('/ascii/');
    ok( $res->is_success, "/ascii/ is succcess" );
    is( $res->decoded_content, 'sub index: Private content', "sub index: Private works" );

    my $c;
    ( $res, $c ) = ctx_request('/ascii/other');
    ok( $res->is_success, "/ascii/other is succcess" );
    is( $res->decoded_content, 'normal controller methods work as well!', "normal controller action" );

    foreach my $action ( keys %{$c->dispatcher->_action_hash} ) {
        next if $action =~ m{\w+/_(?:ACTION|END|DISPATCH|AUTO|BEGIN)};
        $actions->{ $action } = $c->dispatcher->_action_hash->{ $action };
    }

t/00-catalyst-controller-psgi.t  view on Meta::CPAN

        close $fh;
    }

    my $res = request('/file/');
    ok( $res->is_success, "response is succcess" );
    is( $res->decoded_content, $content, 'content is correct' );

    subtest 'action' => sub {
        plan tests => 5;

        my $call = $actions->{'file/call'};

t/00-catalyst-controller-psgi.t  view on Meta::CPAN

    plan tests => 3;

    my ( $res, $c ) = ctx_request('/ascii/lol/copter');

    ok( $res->is_success, "response is succcess" );
    is( $res->decoded_content, $c->controller('Ascii')->lolcopter, "content is correct" );

    subtest 'action' => sub {
        plan tests => 5;

        my $call = $actions->{'ascii/lol/copter'};

t/00-catalyst-controller-psgi.t  view on Meta::CPAN

    plan tests => 3;

    my ( $res, $c ) = ctx_request('/ascii/not/copter');

    ok( $res->is_success, "response is succcess" );
    is( $res->decoded_content, "totally not a lolcopter", "content is correct" );

    subtest 'action' => sub {
        plan tests => 5;

        my $call = $actions->{'ascii/not/copter'};

t/00-catalyst-controller-psgi.t  view on Meta::CPAN

    plan tests => 3;

    my ( $res, $c ) = ctx_request('/ascii/hypnotoad');

    ok( $res->is_success, "response is succcess" );
    is( $res->decoded_content, $c->controller('Ascii')->hypnotoad, "content is correct" );

    subtest 'action' => sub {
        plan tests => 5;

        my $call = $actions->{'ascii/hypnotoad'};

 view all matches for this distribution



CatalystX-OAuth2

 view release on metacpan or  search on metacpan

lib/Catalyst/Authentication/Credential/OAuth2.pm  view on Meta::CPAN

    die "Unrecognized 'token_uri_method' of '${\$self->token_uri_method}'";
  }

  my $response = $self->ua->request($req);
  if($response->is_success) {
    my $data = $j->jsonToObj( $response->decoded_content ); # Eval wrap
    return $data;
  } else {
    return;
  }
}

 view all matches for this distribution


CatalystX-Resource

 view release on metacpan or  search on metacpan

t/02_crud.t  view on Meta::CPAN

# test / for no special reason
{
    my $path = '/';
    my $res = request($path);
    ok($res->is_success, "$path returns HTTP 200");
    like($res->decoded_content, '/TestApp/', "$path content contains string 'TestApp'");
}

# identifier_candidates
{
    my $path = '/artists/' . $artist->id . '/concerts/'. $concert->id .  '/edit';

t/02_crud.t  view on Meta::CPAN

    my $res = request(POST $path, [ location => 'Madison Square Garden' ]);
    ok($res->is_redirect, "$path returns HTTP 302");
    my $uri = URI->new($res->header('location'));
    is($uri->path, '/artists/' . $artist->id . '/concerts/list', 'redirect location is correct');
    my $cookie = $res->header('Set-Cookie');
    my $content = request(GET $uri->path, Cookie => $cookie)->decoded_content;
    like($content, '/Madison Square Garden updated/', 'check update success notification');
}

# SHOW
{
    my $path ='/artists/1/show';
    my $res = request($path);
    ok($res->is_success, "$path returns HTTP 200");
    like($res->decoded_content, '/davewood/', "$path content contains string 'davewood'");
    $path = '/artists/99/show';
    ok(request($path)->code == 404, "Unknown resource $path returns HTTP 404");
}

# LIST
{
    my $path ='/artists/list';
    my $res = request($path);
    ok($res->is_success, "Get $path");
    like($res->decoded_content, '/davewood[\s\S]*flipper/', "$path content contains 'davewood' and 'flipper'");
}

# DELETE
{
    my $path ='/artists/1/delete';

t/02_crud.t  view on Meta::CPAN

# CREATE
{
    my $path ='/artists/create';
    my $res = request($path);
    ok($res->is_success, "$path returns HTTP 200");
    like($res->decoded_content, '/method="post".*password/s', "$path content contains 'method=\"post\"'");
    $res = request(POST $path, [ name => 'simit', password => 'asdf', password_repeat => 'asdf' ]);
    ok($res->is_redirect, "$path returns HTTP 302");
    $path ='/artists/list';
    $res = request($path);
    like($res->decoded_content, '/simit/', "$path content contains 'simit'");
}

# EDIT
{
    my $path ='/artists/2/edit';
    my $res = request($path);
    ok($res->is_success, "$path returns HTTP 200");
    my $content = $res->decoded_content;
    like($content, '/method="post"/', "$path content contains 'method=\"post\"'");
    like($content, '/flipper/', "$path content contains 'flipper'");
    unlike($content, '/password/', "$path does not contain 'password'");
    $res = request(POST $path, [ name => 'willy' ]);
    ok($res->is_redirect, "$path returns HTTP 302");
    $path ='/artists/2/show';
    $res = request($path);
    like($res->decoded_content, '/willy/', "$path content contains 'willy'");
}

# and now for nested resources
# SHOW
{
    my $path ='/artists/2/albums/1/show';
    my $res = request($path);
    ok($res->is_success, "$path returns HTTP 200");
    like($res->decoded_content, '/Mach et einfach/', "$path content contains string 'Mach et einfach'");
    $path = '/artists/2/albums/99/show';
    ok(request($path)->code == 404, "Unknown resource $path returns HTTP 404");
}

# LIST
{
    my $path ='/artists/2/albums/list';
    my $res = request($path);
    ok($res->is_success, "Get $path");
    like($res->decoded_content, '/Mach et einfach/', "$path content contains 'Mach et einfach'");
}

# DELETE
{
    my $path ='/artists/2/albums/1/delete';

t/02_crud.t  view on Meta::CPAN

# CREATE
{
    my $path ='/artists/2/albums/create';
    my $res = request($path);
    ok($res->is_success, "$path returns HTTP 200");
    like($res->decoded_content, '/method="post"/', "$path content contains 'method=\"post\"'");
    $res = request(POST $path, [ name => 'I Brake Together' ]);
    ok($res->is_redirect, "$path returns HTTP 302");
    $path ='/artists/2/albums/list';
    $res = request($path);
    like($res->decoded_content, '/I Brake Together/', "$path content contains 'I Brake Together'");
}

# EDIT
{
    my $path ='/artists/2/albums/1/edit';
    my $res = request($path);
    ok($res->is_success, "$path returns HTTP 200");
    like($res->decoded_content, '/method="post"/', "$path content contains 'method=\"post\"'");
    like($res->decoded_content, '/I Brake Together/', "$path content contains 'I Brake Together'");
    $res = request(POST $path, [ name => 'Es gibt Reis, Baby' ]);
    ok($res->is_redirect, "$path returns HTTP 302");
    $path ='/artists/2/albums/1/show';
    $res = request($path);
    like($res->decoded_content, '/Es gibt Reis, Baby/', "$path content contains 'Es gibt Reis, Baby'");
}

# EDIT with TT variable interpolation (example: [% moby %])
# album.name is using an inline form template
# artist.name is using a form.tt file
# this test makes sure the behaviour of the two is the same
{
    my $path ='/artists/2/albums/1/edit';
    my $res = request($path);
    ok($res->is_success, "$path returns HTTP 200");
    like($res->decoded_content, '/method="post"/', "$path content contains 'method=\"post\"'");
    like($res->decoded_content, '/Es gibt Reis, Baby/', "POST $path content contains 'Es gibt Reis, Baby'");
    $res = request(POST $path, [ name => 'Es gibt [% Reis %], Baby' ]);
    ok($res->is_redirect, "$path returns HTTP 302");
    $path ='/artists/2/albums/1/show';
    $res = request($path);
    like($res->decoded_content, '/Es gibt \[% Reis %\], Baby/', "GET $path content contains 'Es gibt [% Reis %], Baby'");

    $path ='/artists/2/albums/1/edit';
    $res = request($path);
    ok($res->is_success, "$path returns HTTP 200");
    like($res->decoded_content, '/value="Es gibt \[% Reis %\], Baby/', "GET $path content contains 'Es gibt [% Reis %], Baby'");

    $path ='/artists/2/edit';
    $res = request($path);
    ok($res->is_success, "$path returns HTTP 200");
    my $content = $res->decoded_content;
    like($content, '/method="post"/', "$path content contains 'method=\"post\"'");
    like($content, '/willy/', "$path content contains 'willy'");
    unlike($content, '/password/', "$path does not contain 'password'");
    $res = request(POST $path, [ name => '[% moby %]' ]);
    ok($res->is_redirect, "$path returns HTTP 302");
    $path ='/artists/2/show';
    $res = request($path);
    like($res->decoded_content, '/\[% moby %\]/', "$path content contains '[% moby %]'");
}

done_testing;

 view all matches for this distribution


Catmandu-AAT

 view release on metacpan or  search on metacpan

lib/Catmandu/AAT/SPARQL.pm  view on Meta::CPAN

    my $form = {
        'query' => $self->query
    };
    my $response = $self->ua->post($self->url, $form);
    if ($response->is_success) {
        return decode_json($response->decoded_content);
    } else {
         Catmandu::HTTPError->throw({
            code             => $response->code,
            message          => $response->status_line,
            url              => $response->request->uri,
            method           => $response->request->method,
            request_headers  => [],
            request_body     => $response->request->decoded_content,
            response_headers => [],
            response_body    => $response->decoded_content
        });
        return undef;
    }
}

 view all matches for this distribution


Catmandu-Adlib

 view release on metacpan or  search on metacpan

lib/Catmandu/Adlib/API.pm  view on Meta::CPAN

            code             => $response->code,
            message          => $response->status_line,
            url              => $response->request->uri,
            method           => $response->request->method,
            request_headers  => [],
            request_body     => $response->request->decoded_content,
            response_headers => [],
            response_body    => $response->decoded_content,
        });
        return {};
    }
    my $json = decode_json($response->decoded_content);
    # If there are multiple results for the same object_id, I'm gonna turn violent.
    return $self->get_by_priref($self->get_priref($json->{'adlibXML'}->{'recordList'}->{'record'}->[0]));
}

sub get_by_priref {
    my ($self, $priref) = @_;
    my $url = sprintf('%s/%s', $self->endpoint, $self->qb->priref($priref));
    my $response = $self->ua->get($url);
    if ($response->is_success) {
        # It's XML - is it already structured? TODO: see
        return $response->decoded_content;
    } elsif ($response->code == 404) {
        return {};
    } else {
        Catmandu::HTTPError->throw({
            code             => $response->code,
            message          => $response->status_line,
            url              => $response->request->uri,
            method           => $response->request->method,
            request_headers  => [],
            request_body     => $response->request->decoded_content,
            response_headers => [],
            response_body    => $response->decoded_content,
        });
    }
}

sub by_object_id {

lib/Catmandu/Adlib/API.pm  view on Meta::CPAN

        $url = sprintf('%s&startfrom=1', $url);
    }
    warn $url;
    my $response = $self->ua->get($url);
    if ($response->is_success) {
        return decode_json($response->decoded_content);
    } elsif ($response->code == 404) {
        return [];
    } else {
        Catmandu::HTTPError->throw({
            code             => $response->code,
            message          => $response->status_line,
            url              => $response->request->uri,
            method           => $response->request->method,
            request_headers  => [],
            request_body     => $response->request->decoded_content,
            response_headers => [],
            response_body    => $response->decoded_content,
        });
    }
}

sub get_priref {

 view all matches for this distribution


Catmandu-CA

 view release on metacpan or  search on metacpan

lib/Catmandu/CA/API/Login.pm  view on Meta::CPAN

    my $url = sprintf('%s/service.php/auth/login', $self->url);
    my $request = GET $url;
    $request->authorization_basic($self->username, $self->password);
    my $response = $self->ua->request($request);
    if ($response->is_success) {
        my $content = decode_json($response->decoded_content);
        return $content->{'authToken'};
    } else {
        Catmandu::HTTPError->throw({
                code             => $response->code,
                message          => $response->status_line,
                url              => $response->request->uri,
                method           => $response->request->method,
                request_headers  => [],
                request_body     => $response->request->decoded_content,
                response_headers => [],
                response_body    => $response->decoded_content,
        });
        return undef;
    }
}

 view all matches for this distribution


Catmandu-Importer-MWTemplates

 view release on metacpan or  search on metacpan

lib/Catmandu/Importer/MWTemplates.pm  view on Meta::CPAN

        if (defined $self->page) {
            my $page = $self->page;
            my $url = $self->site . "wiki/$page?action=raw";
            my $res = $client->get($url);
            if ($res->is_success) {
                $text = $res->decoded_content;
            } else {
                die "failed to get $url";
            }
        } else {
            # TODO: read pages from input unless page is set

 view all matches for this distribution


Catmandu-Importer-getJSON

 view release on metacpan or  search on metacpan

lib/Catmandu/Importer/getJSON.pm  view on Meta::CPAN

    }
    $self->time(time);

    my $response = $self->client->get( $url, $self->headers );
    if ( $response->is_success ) {
        my $content = $response->decoded_content;
        my $data    = $self->json->decode($content);
        $json = $self->response_hook($data);
    }
    else {
        warn "request failed: $url\n" if $self->warn;

 view all matches for this distribution


Catmandu-MediaHaven

 view release on metacpan or  search on metacpan

lib/Catmandu/MediaHaven.pm  view on Meta::CPAN


        if ($response->is_success) {
            return { ok => 1};
        }
        else {
            my $json = $response->decoded_content;
            return decode_json $json;
        }
    }
    else {
        $client->POST($url);

 view all matches for this distribution


Catmandu-RDF

 view release on metacpan or  search on metacpan

lib/Catmandu/RDF.pm  view on Meta::CPAN

See documentation of modules for more examples.

=head1 DESCRIPTION

Catmandu::RDF contains modules for handling RDF data within the L<Catmandu>
framework. RDF data is encoded/decoded in L<aREF|http://gbv.github.io/aREF/> as
implemented with L<RDF::aREF>. Please keep in mind that RDF is a graph-based
data structuring format with specialized technologies such as SPARQL and triple
stores.  Using Catmandu::RDF to transform RDF to RDF (e.g. conversion from one
RDF serialization to another) is possible but probably less performant than
decent RDF tools. Catmandu::RDF, however, is more conventient to convert

 view all matches for this distribution


Catmandu-RKD

 view release on metacpan or  search on metacpan

lib/Catmandu/RKD/API/Search.pm  view on Meta::CPAN

    } else {
        $url = $self->url;
    }
    my $response = $self->engine->get($url);
    if ($response->is_success) {
        return $response->decoded_content;
    } else {
        Catmandu::HTTPError->throw({
                code             => $response->code,
                message          => $response->status_line,
                url              => $response->request->uri,
                method           => $response->request->method,
                request_headers  => [],
                request_body     => $response->request->decoded_content,
                response_headers => [],
                response_body    => $response->decoded_content,
            });
        return undef;
    }
}

 view all matches for this distribution


Catmandu-Resolver

 view release on metacpan or  search on metacpan

lib/Catmandu/Store/Resolver/API.pm  view on Meta::CPAN

            code             => $response->code,
            message          => $response->status_line,
            url              => $response->request->uri,
            method           => $response->request->method,
            request_headers  => [],
            request_body     => $response->request->decoded_content,
            response_headers => [],
            response_body    => $response->decoded_content
        });
        return undef;
    }
}

lib/Catmandu/Store/Resolver/API.pm  view on Meta::CPAN

            code             => $response->code,
            message          => $response->status_line,
            url              => $response->request->uri,
            method           => $response->request->method,
            request_headers  => [],
            request_body     => $response->request->decoded_content,
            response_headers => [],
            response_body    => $response->decoded_content
        });
        return undef;
    }
}

lib/Catmandu/Store/Resolver/API.pm  view on Meta::CPAN


    my $response = $self->ua->get($req_url);

    if ($response->is_success) {
        # New API
        return decode_json($response->decoded_content);
    } else {
        # If it is 404, it could be that the "new" api works,
        # but that the entity doesn't exist. So we check for
        # the presence of the error "Entity not found"
        # Also, the new API returns the application/json content-type

lib/Catmandu/Store/Resolver/API.pm  view on Meta::CPAN

        # is not equal to the PID
        $url = '%s/resolver/api/entity/%s';
        $req_url = sprintf($url, $self->url, $id);
        $response = $self->ua->get($req_url);
        if ($response->is_success) {
            return decode_json($response->decoded_content);
        } elsif ($response->code == 404) {
            return {
                'data' => {}
            };
        } else {

lib/Catmandu/Store/Resolver/API.pm  view on Meta::CPAN

                code             => $response->code,
                message          => $response->status_line,
                url              => $response->request->uri,
                method           => $response->request->method,
                request_headers  => [],
                request_body     => $response->request->decoded_content,
                response_headers => [],
                response_body    => $response->decoded_content
            });
            return undef;
        }
    }
}

lib/Catmandu/Store/Resolver/API.pm  view on Meta::CPAN

    $self->ua->cookie_jar($self->login());

    my $response = $self->ua->post($req_url, Content_Type => 'application/json', Content => $json_data);

    if ($response->is_success) {
        return decode_json($response->decoded_content);
    } else {
        Catmandu::HTTPError->throw({
                code             => $response->code,
                message          => $response->status_line,
                url              => $response->request->uri,
                method           => $response->request->method,
                request_headers  => [],
                request_body     => $response->request->decoded_content,
                response_headers => [],
                response_body    => $response->decoded_content
            });
        return undef;
    }

}

lib/Catmandu/Store/Resolver/API.pm  view on Meta::CPAN

    $self->ua->cookie_jar($self->login());

    my $response = $self->ua->put($req_url, Content_Type => 'application/json', Content => $json_data);

    if ($response->is_success) {
        return decode_json($response->decoded_content);
    } else {
        Catmandu::HTTPError->throw({
                code             => $response->code,
                message          => $response->status_line,
                url              => $response->request->uri,
                method           => $response->request->method,
                request_headers  => [],
                request_body     => $response->request->decoded_content,
                response_headers => [],
                response_body    => $response->decoded_content
            });
        return undef;
    }
}

lib/Catmandu/Store/Resolver/API.pm  view on Meta::CPAN

    $self->ua->cookie_jar($self->login());

    my $response = $self->ua->delete($req_url);

    if ($response->is_success) {
        return $response->decoded_content;
    } else {
        Catmandu::HTTPError->throw({
                code             => $response->code,
                message          => $response->status_line,
                url              => $response->request->uri,
                method           => $response->request->method,
                request_headers  => [],
                request_body     => $response->request->decoded_content,
                response_headers => [],
                response_body    => $response->decoded_content
            });
        return undef;
    }
}

 view all matches for this distribution


Catmandu-Store-AAT

 view release on metacpan or  search on metacpan

lib/Catmandu/Store/AAT/SPARQL.pm  view on Meta::CPAN

    my $form = {
        'query' => $self->query
    };
    my $response = $self->ua->post($self->url, $form);
    if ($response->is_success) {
        return decode_json($response->decoded_content);
    } else {
         Catmandu::HTTPError->throw({
            code             => $response->code,
            message          => $response->status_line,
            url              => $response->request->uri,
            method           => $response->request->method,
            request_headers  => [],
            request_body     => $response->request->decoded_content,
            response_headers => [],
            response_body    => $response->decoded_content
        });
        return undef;
    }
}

 view all matches for this distribution


Catmandu-Store-Datahub

 view release on metacpan or  search on metacpan

lib/Catmandu/Store/Datahub/API.pm  view on Meta::CPAN

    my $url = sprintf('%s/api/v1/data/%s', $self->url, $id);

    my $response = $self->client->get($url, Authorization => sprintf('Bearer %s', $self->access_token));

    if ($response->is_success) {
        return decode_json($response->decoded_content);
    } elsif ($response->code == 401) {
        my $error = decode_json($response->decoded_content);
        if ($error->{'error_description'} eq 'The access token provided has expired.') {
            $self->set_access_token();
            return $self->get($id);
        }
    } elsif ($response->code == 404) {
        return {};
    } else {
        my $message = decode_json($response->decoded_content);
        Catmandu::HTTPError->throw({
            code             => $response->code,
            message          => $message->{error}->{msg},
            url              => $response->request->uri->as_string,
            method           => $response->request->method,
            request_headers  => [],
            request_body     => $response->request->decoded_content,
            response_headers => [],
            response_body    => $response->decoded_content,
        });
        return undef;
    }
}

lib/Catmandu/Store/Datahub/API.pm  view on Meta::CPAN

    my $response;

    $response = $self->client->post($url, Content_Type => 'application/lido+xml', Authorization => sprintf('Bearer %s', $token), Content => $data);

    if ($response->is_success) {
        return $response->decoded_content;
    } elsif ($response->code == 401) {
        my $error = decode_json($response->decoded_content);
        if ($error->{'error_description'} eq 'The access token provided has expired.') {
            $self->set_access_token();
            return $self->add($data);
        }
    } else {
        my $message = decode_json($response->decoded_content);
        Catmandu::HTTPError->throw({
            code             => $response->code,
            message          => $message->{error}->{msg},
            url              => $response->request->uri->as_string,
            method           => $response->request->method,
            request_headers  => [],
            request_body     => $response->request->decoded_content,
            response_headers => [],
            response_body    => $response->decoded_content,
        });
        return undef;
    }
}

lib/Catmandu/Store/Datahub/API.pm  view on Meta::CPAN

    my $response;

    $response = $self->client->put($url, Content_Type => 'application/lido+xml', Authorization => sprintf('Bearer %s', $token), Content => $data);

    if ($response->is_success) {
        return $response->decoded_content;
    } elsif ($response->code == 401) {
        my $error = decode_json($response->decoded_content);
        if ($error->{'error_description'} eq 'The access token provided has expired.') {
            $self->set_access_token();
            return $self->update($id, $data);
        }
    } else {
        my $message = decode_json($response->decoded_content);
        Catmandu::HTTPError->throw({
            code             => $response->code,
            message          => $message->{error}->{msg},
            url              => $response->request->uri->as_string,
            method           => $response->request->method,
            request_headers  => [],
            request_body     => $response->request->decoded_content,
            response_headers => [],
            response_body    => $response->decoded_content,
        });
        return undef;
    }
}

lib/Catmandu/Store/Datahub/API.pm  view on Meta::CPAN

    my $response;

    $response = $self->client->delete($url, Authorization => sprintf('Bearer %s', $token));

    if ($response->is_success) {
        return $response->decoded_content;
    } elsif ($response->code == 401) {
        my $error = decode_json($response->decoded_content);
        if ($error->{'error_description'} eq 'The access token provided has expired.') {
            $self->set_access_token();
            return $self->delete($id);
        }
    } else {
        my $message = decode_json($response->decoded_content);
        Catmandu::HTTPError->throw({
            code             => $response->code,
            message          => $message->{error}->{msg},
            url              => $response->request->uri->as_string,
            method           => $response->request->method,
            request_headers  => [],
            request_body     => $response->request->decoded_content,
            response_headers => [],
            response_body    => $response->decoded_content,
        });
        return undef;
    }
}

lib/Catmandu/Store/Datahub/API.pm  view on Meta::CPAN


    my $token = $self->access_token;
    my $response = $self->client->get($url, Authorization => sprintf('Bearer %s', $token));

    if ($response->is_success) {
        return decode_json($response->decoded_content);
    } else {
        my $message = decode_json($response->decoded_content);
        Catmandu::HTTPError->throw({
            code             => $response->code,
            message          => $message->{error}->{msg},
            url              => $response->request->uri->as_string,
            method           => $response->request->method,
            request_headers  => [],
            request_body     => $response->request->decoded_content,
            response_headers => [],
            response_body    => $response->decoded_content,
        });
        return undef;
    }
}

 view all matches for this distribution


Catmandu

 view release on metacpan or  search on metacpan

lib/Catmandu/Importer.pm  view on Meta::CPAN

            $res = $client->request($req->clone);
            last if $res->code !~ /^408|500|502|503|504$/;
        }
    }

    my $res_body = $res->decoded_content;

    unless ($res->is_success) {
        my $res_headers = [];
        for my $header ($res->header_field_names) {
            my $val = $res->header($header);

 view all matches for this distribution


( run in 0.410 second using v1.01-cache-2.11-cpan-26ccb49234f )