view release on metacpan or search on metacpan
# en_GB
my $lang = $api->lang_unix;
# en-GB
my $lang = $api->lang_web;
$api->log_error( "Oops" );
$api->print( @some_data );
$api->push_handlers( $name => $code_reference );
return( $api->reply( Apache2::Const::HTTP_OK => {
message => "All good!",
# arbitrary property
client_id => "efe4bcf3-730c-4cb2-99df-25d4027ec404",
# special property
cleanup => sub
{
# Some code here to be executed after the reply is sent out to the client.
}
}) );
# Apache2::API::Request
my $req = $api->request;
# Apache2::API::Response
my $req = $api->response;
# en_GB
my $lang = $api->lang_unix;
# en-GB
my $lang = $api->lang_web;
$api->log_error( "Oops" );
$api->print( @some_data );
$api->push_handlers( $name => $code_reference );
return( $api->reply( Apache2::Const::HTTP_OK => {
message => "All good!",
# arbitrary property
client_id => "efe4bcf3-730c-4cb2-99df-25d4027ec404",
# special property
cleanup => sub
{
# Some code here to be executed after the reply is sent out to the client.
}
}) );
# Apache2::API::Request
my $req = $api->request;
# Apache2::API::Response
my $req = $api->response;
SHA256 3198471e2b96dcb3c40acfdb6f850236fcb8eb6cb448de9cff3785a82edb4a5a t/07.accept.t
SHA256 f1723cb11eca5b344a1705f90a49fb1ab648c7b4d2cff7c8c5a12065d18e5cff t/08.accept_language.t
SHA256 f493598fe4163465ad7539d49c32b84f335f320055e9715d554493b2cecac4c5 t/90.coverage.t
SHA256 4078280a2bd703e111776029e90998fec7e4401924a2272fe69f0122bee659be t/91.pod.t
SHA256 30bfc1987ae524f686d277a49167fac052caa782be018e4e581a8dd17d251474 t/92.signature.t
SHA256 3f93bfcebfe0951d578634d012f65734b40a0d68af4d32de03689b69b54c034d t/93.manifest.t
SHA256 610bb2233eaefa594359fd529387118cd79768ff3bdb1ce9a462dd382120df41 t/99.kwalitee.t
SHA256 926482972612b4093e5029c5701664d47e45ddda3989406366638ab563f4ea5c t/TEST.PL
SHA256 f5b29a1ddcebaf72d1221472b716f5afc7f14c8d016cf1617e3a3fa5a48ecb74 t/conf/extra.conf.in
SHA256 f457a704fb3849dcf8850402630672af57f6708b8689bd30b90addc4318ba8cc t/conf/options.conf.in
SHA256 bc96ffe5c07b48dce0acc8b4bc40732b4043bd9f7ac49ddfdb8f008b8833360a t/lib/Test/Apache2/API.pm
SHA256 de05f108a0799829c22c942f3d4d62811a737ecfd69ada3400ee4276b43cdc4b t/lib/Test/Apache2/API/Request.pm
SHA256 f6a8e6d44ab5d81c58be30709936f4cd0576e3dc5931da9fe2ec4338ff2c4862 t/lib/Test/Apache2/API/Response.pm
SHA256 26ec4e6759f280de9c870de9543341f0a40b4e5acac69af4bf808998d3122aeb t/lib/Test/Apache2/Common.pm
SHA256 ca4beff78eb1f5944fb9409db0c3fd48cccd4610d839a8b855d62a6980c1b086 t/server.crt
SHA256 15f7f65457b3abc0ee1b454bf06f658b88f685d233dcf96d1e11a5978f6be291 t/server.key
-----BEGIN PGP SIGNATURE-----
iQIzBAEBAwAdFiEENa28Ovg1XoRROdiWXzwCYc2y51IFAmnexWEACgkQXzwCYc2y
51LDFA/+ONv1bCCKGG1+5rQJ2V2qKsRVI2daH7pPNPLAKQf7+3SBBVRiWa2zLjql
2XkUSUv2HtdRcghZHcQN5zmOjAebBH363jUeMEJ1SYMn3C9/cY2dX0OKad8pr/jg
lib/Apache2/API.pm view on Meta::CPAN
{
my $self = shift( @_ );
my( $code, $ref );
my $use_rfc_error = $self->{use_rfc_error} // $USE_RFC_ERROR;
# rfc9457 standard for REST API error response: <https://www.rfc-editor.org/rfc/rfc9457.html>
# Legacy JSON payload like Google, Twitter, Facebook
# Modern REST APIs now uses rfc9457 with a flattened payload.
# When the use_rfc_error object property is true, we use rfc9457 flattened error, this will produce something like:
# {
# error => 'not_found',
# status => 404,
# title => 'Not found!',
# detail => q{The requested URL was not found on this server. If you entered the URL manually please check your spelling and try again.},
# locale => 'en-US',
# type => 'https://api.example.com/problems/not-found',
# }
# otherwise, the legacy approach would be:
# {
# error =>
# {
# code => 404,
# message => q{The requested URL was not found on this server. If you entered the URL manually please check your spelling and try again.},
# },
# locale => 'en-US',
# }
# $self->reply( Apache2::Const::HTTP_OK, { message => "All is well" } );
if( scalar( @_ ) == 2 )
{
( $code, $ref ) = @_;
}
elsif( scalar( @_ ) == 1 &&
lib/Apache2/API.pm view on Meta::CPAN
# en_GB
my $lang = $api->lang_unix;
# en-GB
my $lang = $api->lang_web;
$api->log_error( "Oops" );
$api->print( @some_data );
$api->push_handlers( $name => $code_reference );
return( $api->reply( Apache2::Const::HTTP_OK => {
message => "All good!",
# arbitrary property
client_id => "efe4bcf3-730c-4cb2-99df-25d4027ec404",
# special property
cleanup => sub
{
# Some code here to be executed after the reply is sent out to the client.
}
}) );
# Apache2::API::Request
my $req = $api->request;
# Apache2::API::Response
my $req = $api->response;
lib/Apache2/API/Request.pm view on Meta::CPAN
# APR::Finfo
sub finfo { return( shift->_try( 'request', 'finfo' ) ) }
# example: CGI/1.1
sub gateway_interface { return( shift->env( 'GATEWAY_INTERFACE', @_ ) ); }
# $handlers_list = $r->get_handlers($hook_name);
# https://perl.apache.org/docs/2.0/api/Apache2/RequestUtil.html#C_get_handlers_
sub get_handlers { return( shift->_try( 'request', 'get_handlers', @_ ) ); }
# e.g. get_status_line( 404 ) would return 404 Not Found
sub get_status_line { return( shift->_try( 'request', 'get_status_line', @_ ) ); }
sub global_request { return( Apache2::RequestUtil->request ); }
sub has_auth { return( shift->_try( 'request', 'some_auth_required' ) ); }
sub header
{
my $self = shift( @_ );
return( $self->error( "No header field name was provided to set or retrieve its value." ) ) if( !scalar( @_ ) );
lib/Apache2/API/Request.pm view on Meta::CPAN
my $hash_ref = $req->env;
my $headers = $req->err_headers_out;
# request filename
my $filename = $req->filename;
# APR::Finfo object
my $finfo = $req->finfo;
# e.g.: CGI/1.1
my $gateway = $req->gateway_interface;
my $code_ref = $req->get_handlers( $name );
# 404 Not Found
my $str = $req->get_status_line(404);
my $r = $req->global_request;
my $is_head = $req->header_only;
# same
my $is_head = $req->is_header_only;
my $content_type = $req->headers( 'Content-Type' );
# or (since it is case insensitive)
my $content_type = $req->headers( 'content-type' );
# or
my $content_type = $req->headers->{'Content-Type'};
lib/Apache2/API/Request.pm view on Meta::CPAN
If nothing is provided, it returns a L<APR::Table> object.
=head2 err_headers_out
Get or sets HTTP response headers, which are printed out even on errors and persist across internal redirects.
According to the L<Apache2::RequestRec> documentation:
The difference between L</headers_out> (L<Apache2::RequestRec/headers_out>) and L</err_headers_out> (L<Apache2::RequestRec/err_headers_out>), is that the latter are printed even on error, and persist across internal redirects (so the headers printed ...
For example, if a handler wants to return a C<404> response, but nevertheless to set a cookie, it has to be:
$req->err_headers_out->add( 'Set-Cookie' => $cookie );
return( Apache2::Const::NOT_FOUND );
If the handler does:
$req->headers_out->add( 'Set-Cookie' => $cookie );
return( Apache2::Const::NOT_FOUND );
the C<Set-Cookie> header will not be sent.
lib/Apache2/API/Response.pm view on Meta::CPAN
Given one or more name => value pair, this will set them in the HTTP header using the L</err_headers_out> method.
=head2 err_headers_out
Get or sets HTTP response headers, which are printed out even on errors and persist across internal redirects.
According to the L<Apache2::RequestRec> documentation:
The difference between L</headers_out> (L<Apache2::RequestRec/headers_out>) and L</err_headers_out> (L<Apache2::RequestRec/err_headers_out>), is that the latter are printed even on error, and persist across internal redirects (so the headers printed ...
For example, if a handler wants to return a C<404> response, but nevertheless to set a cookie, it has to be:
$resp->err_headers_out->add( 'Set-Cookie' => $cookie );
return( Apache2::Const::NOT_FOUND );
If the handler does:
$resp->headers_out->add( 'Set-Cookie' => $cookie );
return( Apache2::Const::NOT_FOUND );
the C<Set-Cookie> header will not be sent.
lib/Apache2/API/Status.pm view on Meta::CPAN
HTTP_MOVED_TEMPORARILY => 302,
HTTP_SEE_OTHER => 303,
HTTP_NOT_MODIFIED => 304,
HTTP_USE_PROXY => 305,
HTTP_TEMPORARY_REDIRECT => 307,
HTTP_PERMANENT_REDIRECT => 308,
HTTP_BAD_REQUEST => 400,
HTTP_UNAUTHORIZED => 401,
HTTP_PAYMENT_REQUIRED => 402,
HTTP_FORBIDDEN => 403,
HTTP_NOT_FOUND => 404,
HTTP_METHOD_NOT_ALLOWED => 405,
HTTP_NOT_ACCEPTABLE => 406,
HTTP_PROXY_AUTHENTICATION_REQUIRED => 407,
HTTP_REQUEST_TIME_OUT => 408,
HTTP_CONFLICT => 409,
HTTP_GONE => 410,
HTTP_LENGTH_REQUIRED => 411,
HTTP_PRECONDITION_FAILED => 412,
HTTP_REQUEST_ENTITY_TOO_LARGE => 413,
# Compatibility with HTTP::Status
lib/Apache2/API/Status.pm view on Meta::CPAN
303 => Apache2::Const::HTTP_SEE_OTHER,
304 => Apache2::Const::HTTP_NOT_MODIFIED,
305 => Apache2::Const::HTTP_USE_PROXY,
307 => Apache2::Const::HTTP_TEMPORARY_REDIRECT,
308 => Apache2::Const::HTTP_PERMANENT_REDIRECT,
# Client error 4xx
400 => Apache2::Const::HTTP_BAD_REQUEST,
401 => Apache2::Const::HTTP_UNAUTHORIZED,
402 => Apache2::Const::HTTP_PAYMENT_REQUIRED,
403 => Apache2::Const::HTTP_FORBIDDEN,
404 => Apache2::Const::HTTP_NOT_FOUND,
405 => Apache2::Const::HTTP_METHOD_NOT_ALLOWED,
406 => Apache2::Const::HTTP_NOT_ACCEPTABLE,
407 => Apache2::Const::HTTP_PROXY_AUTHENTICATION_REQUIRED,
408 => Apache2::Const::HTTP_REQUEST_TIME_OUT,
409 => Apache2::Const::HTTP_CONFLICT,
410 => Apache2::Const::HTTP_GONE,
411 => Apache2::Const::HTTP_LENGTH_REQUIRED,
412 => Apache2::Const::HTTP_PRECONDITION_FAILED,
413 => Apache2::Const::HTTP_REQUEST_ENTITY_TOO_LARGE,
414 => Apache2::Const::HTTP_REQUEST_URI_TOO_LARGE,
lib/Apache2/API/Status.pm view on Meta::CPAN
302 => "DoÄasnÄ pÅesunuto!",
303 => "Viz jiné",
304 => "NezmÄnÄno",
305 => "PoužÃt proxy",
307 => "DoÄasné pÅesmÄrovánÃ!",
308 => "Trvalé pÅesmÄrovánÃ!",
400 => "Chybný požadavek!",
401 => "Požadováno ovÄÅenÃ!",
402 => "Platba vyžadována!",
403 => "PÅÃstup odmÃtnut!",
404 => "Objekt nenalezen!",
405 => "Metoda nepovolena!",
406 => "NepÅijatelné!",
407 => "Požadováno ovÄÅenà proxy!",
408 => "VyprÅ¡el Äasový limit požadavku!",
409 => "Konflikt!",
410 => "Zdroj již nenà dále dostupný!",
411 => "Chybná hlaviÄka Content-Length!",
412 => "PÅedbÄžná podmÃnka nesplnÄna!",
413 => "Požadovaná entita je pÅÃliÅ¡ velká!",
414 => "Požadované URI je pÅÃliÅ¡ dlouhé!",
lib/Apache2/API/Status.pm view on Meta::CPAN
302 => "Vorübergehend verschoben!",
303 => "Andere sehen",
304 => "Nicht geändert",
305 => "Proxy verwenden",
307 => "Vorübergehende Umleitung!",
308 => "Dauerhafte Umleitung!",
400 => "Fehlerhafte Anfrage!",
401 => "Authentifizierung erforderlich!",
402 => "Zahlung erforderlich!",
403 => "Zugriff verweigert!",
404 => "Objekt nicht gefunden!",
405 => "Methode nicht erlaubt!",
406 => "Nicht akzeptabel!",
407 => "Proxy-Authentifizierung erforderlich!",
408 => "Zeitlimit überschritten!",
409 => "Konflikt!",
410 => "Objekt nicht mehr verfügbar!",
411 => "Content-Length-Angabe fehlerhaft!",
412 => "Vorbedingung nicht erfüllt!",
413 => "Ãbergebene Daten zu groÃ!",
414 => "Ãbergebener URI zu lang!",
lib/Apache2/API/Status.pm view on Meta::CPAN
302 => "Found (temporary redirect)!",
303 => "See Other",
304 => "Not Modified",
305 => "Use Proxy",
307 => "Temporary redirect!",
308 => "Permanent redirect!",
400 => "Bad request!",
401 => "Authentication required!",
402 => "Payment required!",
403 => "Access forbidden!",
404 => "Object not found!",
405 => "Method not allowed!",
406 => "Not acceptable!",
407 => "Proxy authentication required!",
408 => "Request time-out!",
409 => "Conflict!",
410 => "Resource is no longer available!",
411 => "Bad Content-Length!",
412 => "Precondition failed!",
413 => "Request entity too large!",
414 => "Submitted URI too long!",
lib/Apache2/API/Status.pm view on Meta::CPAN
302 => "¡Encontrado (redirección temporal)!",
303 => "Ver otros",
304 => "No modificado",
305 => "Usar proxy",
307 => "¡Redirección temporal!",
308 => "¡Redirección permanente!",
400 => "¡Petición errónea!",
401 => "¡Autenticación requerida!",
402 => "¡Pago requerido!",
403 => "¡Acceso prohibido!",
404 => "¡Objeto no localizado!",
405 => "¡Método no permitido!",
406 => "¡No aceptable!",
407 => "¡Se requiere autenticación de proxy!",
408 => "¡Tiempo de espera excedido!",
409 => "¡Conflicto!",
410 => "¡El recurso ya no está disponible!",
411 => "¡Error en la longitud del contenido!",
412 => "¡Fallo de precondición!",
413 => "¡La entidad solicitada es demasiado grande!",
414 => "¡El URI enviado es demasiado largo!",
lib/Apache2/API/Status.pm view on Meta::CPAN
302 => "Trouvé (redirection temporaire) !",
303 => "Voir ailleurs",
304 => "Non modifié",
305 => "Utiliser le proxy",
307 => "Redirection temporaire !",
308 => "Redirection permanente !",
400 => "Requête incorrecte !",
401 => "Authentification requise !",
402 => "Paiement requis !",
403 => "Accès interdit!",
404 => "Objet non trouvé!",
405 => "Méthode interdite!",
406 => "Non acceptable !",
407 => "Authentification proxy requise !",
408 => "Délai dâattente de la requête dépassé !",
409 => "Conflit !",
410 => "Cette ressource n'existe plus!",
411 => "Longueur du contenu invalide!",
412 => "Ãchec de la précondition !",
413 => "Corps de requête trop volumineux !",
414 => "LâURI transmis est trop long !",
lib/Apache2/API/Status.pm view on Meta::CPAN
302 => "AimsÃodh (atreorú sealadach)!",
303 => "Féach eile",
304 => "Gan athrú",
305 => "Ãsáid seachfhreastalaÃ",
307 => "Atreorú sealadach!",
308 => "Atreorú buan!",
400 => "Iarratas mÃcheart!",
401 => "Is gá fÃordheimhniú!",
402 => "ÃocaÃocht de dhÃth!",
403 => "Rochtain neamhcheadaithe!",
404 => "Aidhm ar iarraidh!",
405 => "Modh neamhcheadaithe!",
406 => "Neamhghlactha!",
407 => "FÃordheimhniú seachfhreastalaà de dhÃth!",
408 => "Iarratas thar am!",
409 => "Coinbhleacht!",
410 => "Acmhainn imithe!",
411 => "Content-Length mÃcheart!",
412 => "Theip ar réamhchoinnÃoll!",
413 => "Eintiteas an iarratais ró-mhór!",
414 => "URI ró-fhada cuirthe isteach!",
lib/Apache2/API/Status.pm view on Meta::CPAN
302 => "Trovato (reindirizzamento temporaneo)!",
303 => "Vedi altro",
304 => "Non modificato",
305 => "Usa proxy",
307 => "Reindirizzamento temporaneo!",
308 => "Reindirizzamento permanente!",
400 => "Richiesta non valida!",
401 => "Autenticazione richiesta!",
402 => "Ã richiesto il pagamento!",
403 => "Accesso negato!",
404 => "Oggetto non trovato!",
405 => "Metodo non consentito!",
406 => "Non accettabile!",
407 => "Autenticazione proxy richiesta!",
408 => "Time-out della richiesta!",
409 => "Conflitto!",
410 => "La risorsa non è più disponibile!",
411 => "Campo Content-Length non valido!",
412 => "Precondizione non soddisfatta!",
413 => "Entità della richiesta troppo grande!",
414 => "URI troppo lungo!",
lib/Apache2/API/Status.pm view on Meta::CPAN
302 => "䏿çã«ç§»åãã¾ããï¼",
303 => "ä»ãåç
§ãã",
304 => "æªæ´æ°",
305 => "ãããã·ã使ç¨ãã",
307 => "䏿çãªãªãã¤ã¬ã¯ãï¼",
308 => "æä¹
çãªãªãã¤ã¬ã¯ãï¼",
400 => "䏿£ãªãªã¯ã¨ã¹ãï¼",
401 => "èªè¨¼ãå¿
è¦ã§ãï¼",
402 => "ãæ¯æããå¿
è¦ã§ãï¼",
403 => "ã¢ã¯ã»ã¹æå¦ï¼",
404 => "æªæ¤åºï¼",
405 => "許å¯ããã¦ããªãã¡ã½ããï¼",
406 => "åçã§ãã¾ããï¼",
407 => "ãããã·èªè¨¼ãå¿
è¦ã§ãï¼",
408 => "ãªã¯ã¨ã¹ãã¿ã¤ã ã¢ã¦ãï¼",
409 => "ç«¶åãçºçãã¾ããï¼",
410 => "ãªã½ã¼ã¹ã¯ãã使ããªãï¼",
411 => "䏿£ãªContent-Lengthï¼",
412 => "åææ¡ä»¶ãæºããã¦ãã¾ããï¼",
413 => "ãã¤ãã¼ãã大ããããï¼",
414 => "URI ãé·ããã¾ãï¼",
lib/Apache2/API/Status.pm view on Meta::CPAN
302 => "ììë¡ ì´ëëììµëë¤!",
303 => "ë¤ë¥¸ 참조",
304 => "ìì ëì§ ìì",
305 => "íë¡ì ì¬ì©",
307 => "ìì 리ëë ì
!",
308 => "ì구 리ëë ì
!",
400 => "ì못ë ìì²!",
401 => "ì¸ì¦ íì!",
402 => "ê²°ì ê° íìí©ëë¤!",
403 => "ì ê·¼ì´ ê±°ë¶ë¨!",
404 => "ê°ì²´ ìì!",
405 => "íì©ëì§ ìë ìì² ë°©ì!",
406 => "íì©ëì§ ìì!",
407 => "íë¡ì ì¸ì¦ì´ íìí©ëë¤!",
408 => "ìì² ìê° ì´ê³¼!",
409 => "ì¶©ë!",
410 => "ìì²í 리ìì¤ë ë ì´ì ì ê³µëì§ ììµëë¤!",
411 => "ì못ë Content-Length!",
412 => "ì¬ì ì¡°ê±´ì´ ì¶©ì¡±ëì§ ìììµëë¤!",
413 => "ìì² ë³¸ë¬¸ì´ ë무 í½ëë¤!",
414 => "ì ì¶í URIê° ë무 ê¹ëë¤!",
lib/Apache2/API/Status.pm view on Meta::CPAN
302 => "Funnet (midlertidig omdirigering)!",
303 => "Se annet",
304 => "Ikke endret",
305 => "Bruk proxy",
307 => "Midlertidig omdirigering!",
308 => "Permanent omdirigering!",
400 => "Ugyldig forespørsel!",
401 => "Autentisering kreves!",
402 => "Betaling kreves!",
403 => "Adgang forbudt!",
404 => "Objektet ble ikke funnet!",
405 => "Metoden er ikke tillatt!",
406 => "Ikke akseptabelt!",
407 => "Proxy-autentisering kreves!",
408 => "Tidsgrense overskredet!",
409 => "Konflikt!",
410 => "Ressursen er ikke lenger tilgjengelig!",
411 => "Feil Content-Length!",
412 => "Forutsetning ikke oppfylt!",
413 => "Forespørselens innhold er for stort!",
414 => "Forespurt URI for lang!",
lib/Apache2/API/Status.pm view on Meta::CPAN
302 => "Gevonden (tijdelijke omleiding)!",
303 => "Zie andere",
304 => "Niet gewijzigd",
305 => "Proxy gebruiken",
307 => "Tijdelijke omleiding!",
308 => "Permanente omleiding!",
400 => "Ongeldig verzoek!",
401 => "Authenticatie vereist!",
402 => "Betaling vereist!",
403 => "Toegang verboden!",
404 => "Object niet gevonden!",
405 => "Methode niet toegestaan!",
406 => "Niet acceptabel!",
407 => "Proxy-authenticatie vereist!",
408 => "Tijdlimiet overschreden!",
409 => "Conflict!",
410 => "Dit object is niet langer beschikbaar!",
411 => "Ongeldige Content-Length!",
412 => "Voorwaarde niet voldaan!",
413 => "Aanvraaginhoud te groot!",
414 => "Aangeboden URI te lang!",
lib/Apache2/API/Status.pm view on Meta::CPAN
302 => "Znaleziono (tymczasowe przekierowanie)!",
303 => "Zobacz inne",
304 => "Nie zmodyfikowano",
305 => "Użyj serwera proxy",
307 => "Tymczasowe przekierowanie!",
308 => "StaÅe przekierowanie!",
400 => "NieprawidÅowe żÄ
danie!",
401 => "Wymagane uwierzytelnienie!",
402 => "Wymagana pÅatnoÅÄ!",
403 => "Zabroniony dostÄp!",
404 => "Nie znaleziono obiektu!",
405 => "Niedozwolona metoda!",
406 => "Nieakceptowalne!",
407 => "Wymagana autoryzacja proxy!",
408 => "Przedawnione żÄ
danie!",
409 => "Konflikt!",
410 => "Zasób usuniÄty!",
411 => "BÅÄdny nagÅówek Content-Length!",
412 => "Warunek wstÄpny niespeÅniony!",
413 => "TreÅÄ Å¼Ä
dania zbyt duża!",
414 => "Zbyt dÅugie URI!",
lib/Apache2/API/Status.pm view on Meta::CPAN
302 => "Encontrado (redirecionamento temporário)!",
303 => "Ver outro",
304 => "Não modificado",
305 => "Usar proxy",
307 => "Redirecionamento temporário!",
308 => "Redirecionamento permanente!",
400 => "Requisição inválida!",
401 => "Autenticação necessária!",
402 => "Pagamento necessário!",
403 => "Acesso Proibido!",
404 => "Objeto não encontrado!",
405 => "Método não permitido!",
406 => "Não aceitável!",
407 => "Autenticação de proxy necessária!",
408 => "Tempo excedido!",
409 => "Conflito!",
410 => "Recurso não está mais disponÃvel!",
411 => "Content-Length inválido!",
412 => "Falha na pré-condição!",
413 => "Volume de dados muito grande!",
414 => "URI enviado é muito longo!",
lib/Apache2/API/Status.pm view on Meta::CPAN
302 => "Encontrado (redirecionamento temporário)!",
303 => "Ver outro",
304 => "Não modificado",
305 => "Usar proxy",
307 => "Redirecionamento temporário!",
308 => "Redirecionamento permanente!",
400 => "Pedido incorreto!",
401 => "Autenticação necessária!",
402 => "Pagamento exigido!",
403 => "Acesso proibido!",
404 => "Objeto não encontrado!",
405 => "Método não permitido!",
406 => "Não aceitável!",
407 => "Autenticação de proxy necessária!",
408 => "Tempo excedido!",
409 => "Conflito!",
410 => "Recurso já não está disponÃvel!",
411 => "Content-Length incorreto!",
412 => "Falha na pré-condição!",
413 => "Volume de dados demasiado grande!",
414 => "URI demasiado longo!",
lib/Apache2/API/Status.pm view on Meta::CPAN
302 => "GÄsit (redirecÈionare temporarÄ)!",
303 => "Vezi altele",
304 => "Neschimbat",
305 => "UtilizaÈi proxy",
307 => "RedirecÈionare temporarÄ!",
308 => "RedirecÈionare permanentÄ!",
400 => "Cerere nevalidÄ!",
401 => "Autentificare necesarÄ!",
402 => "Plata necesarÄ!",
403 => "Accesul interzis!",
404 => "Obiectul nu a fost gasit!",
405 => "MetodÄ nepermisÄ!",
406 => "Inacceptabil!",
407 => "Este necesarÄ autentificarea prin proxy!",
408 => "Time-out al cererii!",
409 => "Conflict!",
410 => "Resursa nu mai este disponibilÄ!",
411 => "Content-Length invalid!",
412 => "PrecondiÈia a eÈuat!",
413 => "Entitatea cererii este prea mare!",
414 => "URI-ul trimis este prea lung!",
lib/Apache2/API/Status.pm view on Meta::CPAN
302 => "Ðайдено (вÑеменное пеÑенапÑавление)!",
303 => "ÑмоÑÑеÑÑ Ð´ÑÑгое",
304 => "не изменÑлоÑÑ",
305 => "иÑполÑзоваÑÑ Ð¿ÑокÑи",
307 => "ÐÑеменное пеÑенапÑавление!",
308 => "ÐоÑÑоÑнное пеÑенапÑавление!",
400 => "ÐевеÑнÑй запÑоÑ!",
401 => "ÐеобÑ
одима аÑÑенÑиÑикаÑиÑ!",
402 => "ТÑебÑеÑÑÑ Ð¾Ð¿Ð»Ð°Ñа!",
403 => "ÐоÑÑÑп запÑеÑÑн!",
404 => "ÐбÑÐµÐºÑ Ð½Ðµ найден!",
405 => "ÐеÑод не поддеÑживаеÑÑÑ!",
406 => "ÐепÑиемлемо!",
407 => "ТÑебÑеÑÑÑ Ð°ÑÑенÑиÑикаÑÐ¸Ñ Ð¿ÑокÑи!",
408 => "ÐÑÑекло вÑÐµÐ¼Ñ Ð¾Ð¶Ð¸Ð´Ð°Ð½Ð¸Ñ!",
409 => "ÐонÑликÑ!",
410 => "ÐокÑÐ¼ÐµÐ½Ñ ÑдалÑн!",
411 => "ÐевеÑнÑй заголовок Content-Length!",
412 => "ÐÑедÑÑловие не вÑполнено!",
413 => "Ð Ð°Ð·Ð¼ÐµÑ Ð·Ð°Ð¿ÑоÑа ÑлиÑком велик!",
414 => "URI ÑлиÑком длиннÑй!",
lib/Apache2/API/Status.pm view on Meta::CPAN
302 => "ÐÑонаÑено (пÑивÑемено пÑеÑÑмеÑаваÑе)!",
303 => "ÐÐ¾Ð³Ð»ÐµÐ´Ð°Ñ Ð´ÑÑго",
304 => "ÐиÑе измеÑено",
305 => "ÐоÑиÑÑи пÑокÑи",
307 => "ÐÑивÑемено пÑеÑÑмеÑаваÑе!",
308 => "ТÑаÑно пÑеÑÑмеÑаваÑе!",
400 => "ÐÐ¾Ñ Ð·Ð°Ñ
Ñев!",
401 => "Ðбавезна аÑÑенÑиÑикаÑиÑа!",
402 => "ÐоÑÑебно плаÑаÑе!",
403 => "ÐабÑаÑен пÑиÑÑÑп!",
404 => "ÐбÑÐµÐºÐ°Ñ Ð½Ð¸Ñе пÑонаÑен!",
405 => "ÐеÑод ниÑе дозвоÑен!",
406 => "ÐепÑиÑ
ваÑÑиво!",
407 => "ÐоÑÑебна Ñе пÑокÑи аÑÑенÑикаÑиÑа!",
408 => "ÐаÑ
ÑÐµÐ²Ñ Ñе иÑÑекло вÑеме!",
409 => "СÑкоб!",
410 => "РеÑÑÑÑ Ð½Ð¸Ñе виÑе доÑÑÑпан!",
411 => "ÐеиÑпÑавно Content-Length заглавÑе!",
412 => "ÐÑедÑÑлов ниÑе иÑпÑÑен!",
413 => "Тело заÑ
Ñева Ñе пÑевелико!",
414 => "ÐоÑлаÑи УРРÑе пÑедÑгаÑак!",
lib/Apache2/API/Status.pm view on Meta::CPAN
302 => "Hittad (tillfällig omdirigering)!",
303 => "Se annat",
304 => "Inte ändrad",
305 => "Använd proxy",
307 => "Tillfällig omdirigering!",
308 => "Permanent omdirigering!",
400 => "Felaktig förfrågan!",
401 => "Autentisering krävs!",
402 => "Betalning krävs!",
403 => "Ã
tkomst förbjuden!",
404 => "Objektet hittas ej!",
405 => "Metoden inte tillåten!",
406 => "Inte acceptabelt!",
407 => "Proxyautentisering krävs!",
408 => "Tidsgränsen överskreds!",
409 => "Konflikt!",
410 => "Resursen är inte längre tillgänglig!",
411 => "Felaktig Content-Length!",
412 => "Förhandsvillkor uppfylldes inte!",
413 => "Begärans innehåll är för stort!",
414 => "Efterfrågad URI för lång!",
lib/Apache2/API/Status.pm view on Meta::CPAN
302 => "Bulundu (geçici yönlendirme)!",
303 => "BaÅka bir yere bakın",
304 => "DeÄiÅtirilmedi",
305 => "Vekil sunucu kullan",
307 => "Geçici yönlendirme!",
308 => "Kalıcı yönlendirme!",
400 => "Hatalı istek!",
401 => "Kimlik doÄrulama gerekli!",
402 => "Ãdeme gerekli!",
403 => "EriÅim engellendi!",
404 => "Nesne mevcut deÄil!",
405 => "Yönteme izin verilmedi!",
406 => "Kabul edilemez!",
407 => "Vekil sunucu kimlik doÄrulaması gerekli!",
408 => "İstekte zaman aÅımı!",
409 => "ÃakıÅma!",
410 => "Kaynak artık mevcut deÄil!",
411 => "Hatalı Content-Length baÅlıÄı!",
412 => "ÃnkoÅul karÅılanamadı!",
413 => "İstek gövdesi çok büyük!",
414 => "Gönderilen URI çok uzun!",
lib/Apache2/API/Status.pm view on Meta::CPAN
302 => "å·²æ¾å°ï¼ä¸´æ¶éå®åï¼ï¼",
303 => "æ¥çå
¶ä»",
304 => "æªä¿®æ¹",
305 => "使ç¨ä»£ç",
307 => "临æ¶éå®åï¼",
308 => "æ°¸ä¹
éå®åï¼",
400 => "æ æè¯·æ±ï¼",
401 => "éè¦è®¤è¯ï¼",
402 => "éè¦ä»æ¬¾ï¼",
403 => "ç¦æ¢è®¿é®ï¼",
404 => "æ¾ä¸å°å¯¹è±¡ï¼",
405 => "请æ±çæ¹æ³ä¸å
许ï¼",
406 => "ä¸å¯æ¥åï¼",
407 => "éè¦ä»£ç身份éªè¯ï¼",
408 => "请æ±è¶
æ¶ï¼",
409 => "å²çªï¼",
410 => "èµæºä¸åå¯ç¨ï¼",
411 => "æ æç Content-Lengthï¼",
412 => "å
峿¡ä»¶æªæ»¡è¶³ï¼",
413 => "请æ±ä½è¿å¤§ï¼",
414 => "æäº¤ç URI è¿é¿ï¼",
lib/Apache2/API/Status.pm view on Meta::CPAN
302 => "å·²æ¾å°ï¼è¨æéæ°å°åï¼ï¼",
303 => "æ¥çå
¶ä»",
304 => "æªä¿®æ¹",
305 => "使ç¨ä»£ç",
307 => "è¨æéæ°å°åï¼",
308 => "æ°¸ä¹
éæ°å°åï¼",
400 => "è«æ±é¯èª¤ï¼",
401 => "éè¦èªèï¼",
402 => "éè¦ä»æ¬¾ï¼",
403 => "ç¦æ¢è¨ªåï¼",
404 => "æ¾ä¸å°ç©ä»¶ï¼",
405 => "è«æ±çæ¹æ³ä¸å
許ï¼",
406 => "ä¸å¯æ¥åï¼",
407 => "éè¦ä»£ç伺æå¨é©èï¼",
408 => "è«æ±è¶
æï¼",
409 => "è¡çªï¼",
410 => "è³æºä¸åå¯ç¨ï¼",
411 => "ç¡æç Content-Lengthï¼",
412 => "å
決æ¢ä»¶æªæ»¿è¶³ï¼",
413 => "è«æ±é«é大ï¼",
414 => "æäº¤ç URI éé·ï¼",
lib/Apache2/API/Status.pm view on Meta::CPAN
our $STATUS_TO_TYPE =
{
301 => "moved_permanently",
302 => "moved_temporarily",
307 => "redirect_temporarily",
308 => "redirect_permanent",
400 => "bad_request",
401 => "unauthorized",
402 => "payment_required",
403 => "forbidden",
404 => "not_found",
405 => "method_not_allowed",
406 => "not_acceptable",
407 => "proxy_authentication_required",
408 => "request_time_out",
409 => "conflict",
410 => "gone",
411 => "length_required",
412 => "precondition_failed",
413 => "request_entity_too_large",
414 => "request_uri_too_large",
lib/Apache2/API/Status.pm view on Meta::CPAN
my $code = shift( @_ );
return( $self->error( "A 3 digit code is required." ) ) if( !defined( $code ) || $code !~ /^\d{3}$/ );
return(
$code == 200 # OK
|| $code == 203 # Non-Authoritative Information
|| $code == 204 # No Content
|| $code == 206 # Not Acceptable
|| $code == 300 # Multiple Choices
|| $code == 301 # Moved Permanently
|| $code == 308 # Permanent Redirect
|| $code == 404 # Not Found
|| $code == 405 # Method Not Allowed
|| $code == 410 # Gone
|| $code == 414 # Request-URI Too Large
|| $code == 451 # Unavailable For Legal Reasons
|| $code == 501 # Not Implemented
);
}
sub is_client_error { return( shift->_min_max( 400 => 500, @_ ) ); }
lib/Apache2/API/Status.pm view on Meta::CPAN
if( !defined( $sep ) ||
( defined( $sep ) && $sep eq '_' ) )
{
return( $STATUS_TO_TYPE->{ $code } );
}
( my $type = $STATUS_TO_TYPE->{ $code } ) =~ s/_/$sep/g;
return( $type );
}
# Returns a status line for a given code
# e.g. status_message( 404 ) would yield "Not found"
sub status_message
{
my $self = shift( @_ );
my( $code, $lang );
if( scalar( @_ ) == 2 )
{
( $code, $lang ) = @_;
}
else
{
lib/Apache2/API/Status.pm view on Meta::CPAN
my $status = Apache2::API::Status->new;
say $status->status_message( 429 => 'ja_JP' );
# Or without the language code parameter, it will default to en_GB
say $status->status_message( 429 );
# Is success
say $status->is_info( 102 ); # true
say $status->is_success( 200 ); # true
say $status->is_redirect( 302 ); # true
say $status->is_error( 404 ); # true
say $status->is_client_error( 403 ); # true
say $status->is_server_error( 501 ); # true
=head1 VERSION
v0.2.1
=head1 DESCRIPTION
This module allows to get the localised version of the HTTP status for a given code for currently supported languages: fr_FR (French), en_GB (British English) and ja_JP (Japanese), de_DE (German), ko_KR (Korean), ru_RU (Russian), zh_CN (simplified Ch...
lib/Apache2/API/Status.pm view on Meta::CPAN
Provided with a 3-digits HTTP code and an optional language code such as C<en_GB> and this will return the status message in its localised form.
This is useful to provide response to error in the user preferred language. L<Apache2::API/reply> uses it to set a json response with the HTTP error code along with a localised status message.
If no language code is provided, this will default to C<en_GB>.
See L</supported_languages> for the supported languages.
=head2 status_to_type
Provided with a status code, such as C<404>, and this returns a status type such as C<not_found>.
This is used to build a rfc9457 compliant error.
=head2 supported_languages
This will return a sorted array reference of support languages for status codes.
The following language codes are currently supported: de_DE (German), en_GB (British English), fr_FR (French), ja_JP (Japanese), ko_KR (Korean), ru_RU (Russian) and zh_TW (Traditional Chinese as spoken in Taiwan).
Feel free to contribute those codes in other languages.
lib/Apache2/API/Status.pm view on Meta::CPAN
=head2 HTTP_FORBIDDEN (403)
See L<rfc 7231, section 6.5.3|https://tools.ietf.org/html/rfc7231#section-6.5.3>
See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/403>
This is returned to indicate the client is barred from accessing the resource.
This is different from C<405 Method Not Allowed>, which is used when the client has proper permission to access the resource, but is using a method not allowed, such as using C<PUT> instead of C<GET> method.
=head2 HTTP_NOT_FOUND (404)
See L<rfc 7231, section 6.5.4|https://tools.ietf.org/html/rfc7231#section-6.5.4>
See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/404>
This is returned to indicate the resource does not exist anymore.
=head2 HTTP_METHOD_NOT_ALLOWED (405)
See L<rfc 7231, section 6.5.5|https://tools.ietf.org/html/rfc7231#section-6.5.5>
This is returned to indicate the client it used a L<method|https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods> not allowed, such as using C<PUT> instead of C<GET>. The server can point out the supported methods with the C<Allow> header, such a...
HTTP/1.1 405 Method Not Allowed
lib/Apache2/API/Status.pm view on Meta::CPAN
=head2 HTTP_CONFLICT (409)
See L<rfc 7231, section 6.5.8|https://tools.ietf.org/html/rfc7231#section-6.5.8>
This is returned to indicate a request conflict with the current state of the target resource, such as uploading with C<PUT> a file older than the remote one.
=head2 HTTP_GONE (410)
See L<rfc 7231, section 6.5.9|https://tools.ietf.org/html/rfc7231#section-6.5.9>
This is returned to indicate that the target resource is gone permanently. The subtle difference with the status code C<404> is that with C<404>, the resource may be only temporally unavailable whereas with C<410>, this is irremediable. For example:
HTTP/1.1 410 Gone
Server: Apache/2.4
Content-Type: text/plain
Content-Length: 30
The resource has been removed.
=head2 HTTP_LENGTH_REQUIRED (411)
t/04.status.t view on Meta::CPAN
'HTTP_MOVED_TEMPORARILY' => 302,
'HTTP_SEE_OTHER' => 303,
'HTTP_NOT_MODIFIED' => 304,
'HTTP_USE_PROXY' => 305,
'HTTP_TEMPORARY_REDIRECT' => 307,
'HTTP_PERMANENT_REDIRECT' => 308,
'HTTP_BAD_REQUEST' => 400,
'HTTP_UNAUTHORIZED' => 401,
'HTTP_PAYMENT_REQUIRED' => 402,
'HTTP_FORBIDDEN' => 403,
'HTTP_NOT_FOUND' => 404,
'HTTP_METHOD_NOT_ALLOWED' => 405,
'HTTP_NOT_ACCEPTABLE' => 406,
'HTTP_PROXY_AUTHENTICATION_REQUIRED' => 407,
'HTTP_REQUEST_TIME_OUT' => 408,
'HTTP_CONFLICT' => 409,
'HTTP_GONE' => 410,
'HTTP_LENGTH_REQUIRED' => 411,
'HTTP_PRECONDITION_FAILED' => 412,
'HTTP_REQUEST_ENTITY_TOO_LARGE' => 413,
'HTTP_REQUEST_URI_TOO_LARGE' => 414,
t/04.status.t view on Meta::CPAN
ok( $s->is_error( HTTP_REQUEST_RANGE_NOT_SATISFIABLE ), 'is_error' );
ok( $s->is_error( HTTP_RANGE_NOT_SATISFIABLE ), 'is_error' );
ok( $s->is_error( HTTP_NO_CODE ), 'is_error' );
ok( $s->is_error( HTTP_UNORDERED_COLLECTION ), 'is_error' );
ok( Apache2::API::Status->is_error( HTTP_TOO_EARLY ), 'is_error' );
ok( !$s->is_success( HTTP_NOT_FOUND ), 'is_success' );
is( $s->status_message(0), undef, 'status_message' );
is( $s->status_message(200), 'OK', 'status_message' );
is( $s->status_message(404), 'Object not found!', 'status_message' );
is( $s->status_message(999), undef, 'status_message' );
ok( !$s->is_info( HTTP_NOT_FOUND ), 'is_info' );
ok( !$s->is_success( HTTP_NOT_FOUND ), 'is_success' );
ok( !$s->is_redirect( HTTP_NOT_FOUND ), 'is_redirect' );
ok( !$s->is_error( HTTP_CONTINUE ), 'is_error' );
ok( !$s->is_client_error( HTTP_CONTINUE ), 'is_client_error' );
ok( !$s->is_server_error( HTTP_NOT_FOUND ), 'is_server_error' );
ok( !$s->is_server_error(999), 'is_server_error' );
ok( !$s->is_info(99), 'is_info' );
ok( !$s->is_success(99), 'is_success' );
ok( !$s->is_redirect(99), 'is_redirect' );
ok( $s->is_cacheable_by_default( $_ ),
"Cacheable by default [$_] " . $s->status_message( $_ )
) for( 200, 203, 204, 206, 300, 301, 308, 404, 405, 410, 414, 451, 501 );
ok( !$s->is_cacheable_by_default( $_ ),
"... is not cacheable [$_] " . $s->status_message( $_ )
) for( 100, 201, 302, 400, 500 );
done_testing();
__END__