use APR::Base64 ();
use APR::Request ();
use APR::UUID ();
use Exporter ();
use JSON ();
use Scalar::Util ();
our @EXPORT = qw( apr1_md5 );
$DEBUG = 0;
$VERSION = '
age}->locale;
}
my $ctype = $self->response->content_type;
if( $ctype eq 'application/json' )
{
return( $self->reply( $msg->{code}, { error => $msg->{message} } ) );
}
$rv );
}
sub decode_json
{
my $self = shift( @_ );
my $raw = shift( @_ ) || return( $self->error( "No json data was provided to decode." ) );
my $json = $self->json;
my $hash;
#
ion/json');
my $mime = $accept->match(['text/html', 'application/json']); # => 'text/html'
# inspect client preferences (by q, desc):
my $prefs = $a->preferences; # [ 'application/json', '
::Headers::Accept->new( '*/*;q=0.9, application/json;q=0.9' );
$a->match( [ 'image/png', 'text/html', 'application/json' ] );
# "application/json"
=head2 3. */* with higher q wins and chooses
= Apache2::API::Headers::Accept->new( '*/*;q=1.0, application/json;q=0.9' );
$a->match( [ 'image/png', 'text/html', 'application/json' ] );
# "image/png"
=head1 LEGACY MATCH PRIORITY
Set C<
quest
See also L</status_line>
=head2 header
$resp->header( 'Content-Type' => 'application/json' );
my $ct = $resp->header( 'Content-Type' );
Sets or gets an HTTP header.
=head2 headers
pt} = 'application/json';
$resp->headers->{Accept} = undef; # unset it
or
my $accept = $resp->headers->get( 'Accept' );
$resp->headers->set( Accept => 'application/json' );
$resp->he
use DateTime;
use Encode ();
use File::Which ();
use HTTP::AcceptLanguage;
use JSON ();
use Module::Generic::HeaderValue;
use Scalar::Util;
use URI;
use URI::Escape;
th( $auth ) );
# Content-Type: application/json; charset=utf-8
my $ctype_raw = $self->content_type;
# Accept: application/json; version=1.0; charset=utf-8
my $accept_ra
$self->accept_charset( $accept_def->param( 'charset' ) );
}
my $json = $self->json;
my $payload = $self->data;
# An error occurred while reading the payload,
nt type is: %s\n", $up->info->{'Content-type'} );
# could yield for example: application/json; charset=utf-8
See also L</type>, but be careful C<< $up->info->{'Content-type'} >> is not neces
Apache2::API::Headers::Accept->new( 'text/html;q=0.9,application/json' );
my $mime = $accept->match( ['text/html', 'application/json'] ); # => 'text/html'
my $al = Apache2::API::Headers::Acce
Apache2::API::Headers::Accept->new( 'text/html;q=0.9,application/json' );
my $prefs = $accept->preferences; # ['application/json', 'text/html']
If an error occurred, it sets an error that can b
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
e a link in the header. For example:
POST /some/where HTTP/1.1
Content-Type: application/json
Then the server response:
HTTP/1.1 202 Accepted
Link: </some/status/1234> rel="https://
TTP/Headers/Accept-Language> headers
For example:
GET /foo HTTP/1.1
Accept: application/json
Accept-Language: fr-FR,en-GB;q=0.8,fr;q=0.6,en;q=0.4,ja;q=0.2
HTTP/1.1 406 Not Acceptabl