Apache2-API
view release on metacpan
or search on metacpan
README
view on Meta::CPAN
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | Given some data, this will decode it using base64 algorithm. It uses
"decode" in APR::Base64 in the background.
decode_json( $data )
This decode from utf8 some data into a perl structure using JSON
If an error occurs, it will return undef and set an exception that can
be accessed with the error method.
decode_url( $string )
Given a url-encoded string, this returns the decoded string using
"decode" in APR::Request
decode_utf8( $data )
Decode some data from ut8 into perl internal utf8 representation using
Encode
If an error occurs, it will return undef and set an exception that can
be accessed with the error method.
encode_base64( $data )
|
README.md
view on Meta::CPAN
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | |
lib/Apache2/API.pm
view on Meta::CPAN
845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 | return ( $api ->bailout({
message => "Oops" ,
code => Apache2::Const::BAD_REQUEST,
public_message => "An unexpected error occurred." ,
}) );
return ( $api ->bailout( @some_reasons ) );
$api ->compression_threshold(102400);
my $decoded = $api ->decode_base64( $b64_string );
my $ref = $api ->decode_json( $json_data );
my $decoded = $api ->decode_url;
my $perl_utf8 = $api ->decode_utf8( $data );
my $b64_string = $api ->encode_base64( $data );
my $json_data = $api ->encode_json( $ref );
my $encoded = $api ->encode_url( $uri );
my $utf8 = $api ->encode_utf8( $data );
my $uuid = $api ->generate_uuid;
my $auth = $api ->get_auth_bearer;
my $handlers = $api ->get_handlers;
my $dt = $api ->header_datetime( $http_datetime );
my $bool = $api ->is_perl_option_enabled;
|
lib/Apache2/API.pm
view on Meta::CPAN
959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 | Given some data, this will decode it using base64 algorithm. It uses L<APR::Base64/decode> in the background.
|
lib/Apache2/API/Query.pm
view on Meta::CPAN
187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 | |
lib/Apache2/API/Request.pm
view on Meta::CPAN
1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 | my $cookie = $req ->cookie( $name );
my $jar = $req ->cookies;
my $data = $req ->data;
my $formatter = $req ->datetime;
my $decoded = $req ->decode( $string );
my $do_not_track = $req ->dnt;
my $encoded = $req ->encode( $string );
$req ->discard_request_body(1);
my $document_root = $req ->document_root;
my $url = $req ->document_uri;
|
lib/Apache2/API/Request.pm
view on Meta::CPAN
1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 | my $dt = $req ->time2datetime( $time );
say $req ->time2str( $seconds );
my $type = $req ->type;
my $raw = $req ->unparsed_uri;
my $uploads = $req ->uploads;
my $uri = $req ->uri;
my $decoded = $req ->url_decode( $url );
my $encoded = $req ->url_encode( $url );
my $user = $req ->user;
my $agent = $req ->user_agent;
|
lib/Apache2/API/Request.pm
view on Meta::CPAN
1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 | Get the details from the basic authentication, by calling L<Apache2::Access/get_basic_auth_pw>
It returns:
|
lib/Apache2/API/Request.pm
view on Meta::CPAN
2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 | This is just an example and not a recommandation. Your mileage may vary.
|
lib/Apache2/API/Request.pm
view on Meta::CPAN
2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 | my $path_info = $req ->path_info();
my $prev_path_info = $req ->path_info( $path_info );
Get or set the C<PATH_INFO>, what is left in the path after the C<< URI --> filename >> translation, by calling L<Apache2::RequestRec/path_info>
Return a string as the current value.
|
lib/Apache2/API/Response.pm
view on Meta::CPAN
780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 | $resp ->cookie_replace( $cookie );
$resp ->cookie_set( $cookie );
my $policy = $resp ->cross_origin_embedder_policy;
my $policy = $resp ->cross_origin_opener_policy;
my $policy = $resp ->cross_origin_resource_policy;
my $cspro = $resp ->cspro;
$resp ->custom_response( Apache2::Const::AUTH_REQUIRED, "Authenticate please" );
my $decoded = $resp ->decode( $string );
my $digest = $resp ->digest;
my $encoded = $resp ->encode( $string );
my $env = $resp ->env;
my $headers = $resp ->err_headers;
my $headers = $resp ->err_headers_out;
my $escaped = $resp ->escape( $string );
my $etag = $resp ->etag;
|
lib/Apache2/API/Response.pm
view on Meta::CPAN
873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 | my $origin = $resp ->timing_allow_origin;
my $trailerv = $resp ->trailer;
my $enc = $resp ->transfer_encoding;
my $unescape = $resp ->unescape( $string );
my $upgrade = $resp ->upgrade;
$resp ->update_mtime( $seconds );
my $uri = $resp ->uri_escape( $uri );
my $uri = $resp ->uri_unescape( $uri );
my $decoded = $resp ->url_decode( $uri );
my $encoded = $resp ->url_encode( $uri );
my $vary = $resp ->vary;
my $via = $resp ->via;
my $want = $resp ->want_digest;
my $warn = $resp ->warning;
$resp -> write ( $buffer , $len , $offset );
|
lib/Apache2/API/Response.pm
view on Meta::CPAN
1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 | PerlAccessHandler MyApache2::MyShop::access
PerlResponseHandler MyApache2::MyShop::response
</Location>
When squirrels cannot run any more, the handler will return C<403>, with the custom message:
It is siesta time , please try later
|
lib/Apache2/API/Response.pm
view on Meta::CPAN
1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 | |
t/01.api.t
view on Meta::CPAN
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 | &simple_test ({ target => 'api' , name => 'auth' , code => Apache2::Const::HTTP_OK, headers => [ Authorization => "Bearer: $jwt" ] });
&simple_test ({ target => 'api' , name => 'header_datetime' , code => Apache2::Const::HTTP_OK });
&simple_test ({ target => 'api' , name => 'is_perl_option_enabled' , code => Apache2::Const::HTTP_OK });
&simple_test ({ target => 'api' , name => 'json' , code => Apache2::Const::HTTP_OK });
$resp = &make_request ( api => 'reply' );
my $j = JSON->new;
my $content = $resp ->decoded_content;
diag( "test 'reply' decoded_content is '$content'" ) if ( $DEBUG );
my $ref ;
eval
{
$ref = $j ->decode( $content );
};
ok( ref ( $ref ) eq 'HASH' , 'reply -> JSON decoded content is an hash reference' );
is( $resp ->code, Apache2::Const::HTTP_OK, 'reply code' );
is( $ref ->{message}, 'ok' , 'reply message' );
&simple_test ({ target => 'api' , name => 'server' , code => Apache2::Const::HTTP_OK });
&simple_test ({ target => 'api' , name => 'server_version' , code => Apache2::Const::HTTP_OK });
};
subtest 'request' => sub
{
|