tps://example.com',
Authorization => "Bearer $some_token",
Accept => 'application/json',
Query => {
param1 => $value1,
param2 => $value2,
},
automatically and transparently managed with L<Cookie::Jar> which can load and store cookies to a json file you specify. You can create a L<cookie object|Cookie::Jar> and pass it to the constructor wi
ise qw( fetch );
my $prom = fetch( 'http://example.com/something.json' );
# or
fetch( 'http://example.com/something.json' )->then(sub
{
my( $resolve, $reject ) = @$_;
m
tml, application/json, application/xml;q=0.9, */*;q=0.8' ) ||
die( HTTP::Promise::Headers::Accept->error, "\n" );
$ac->add( 'text/html' );
$ac->add( 'application/json' => 0.7 );
$
h->accept( $ac->as_string ); Accept: text/html, application/json;q=0.7
# or
$h->accept( "$ac" );
my $qv_elements = $ac->elements;
my $obj = $ac->get( 'text/html' );
# change the we
>sort(1);
# Returns a Module::Generic::Array object
my $ok = $ac->match( [qw( application/json text/html )] );
=head1 VERSION
v0.1.0
=head1 DESCRIPTION
The following description is tak
ta' )
{
return( $self->entity->as_form_data );
}
elsif( $type eq 'application/json' )
{
return( HTTP::Promise::Body::Form->new ) unless( length( $payload ) );
m
>new_json->decode( $payload );
$form = HTTP::Promise::Body::Form->new( $hash );
};
if( $@ )
{
return( $self->error( "Error trying to decode the JSON pay
gth($1)) =~ s/\sencoding\s*=\s*(["']).*?\1//;
}
}
return( $data );
}
sub decoded_json
{
my $self = shift( @_ );
my $opts = $self->_get_args_as_hash( @_ );
$opts->{binmode}
$self->SUPER::init( @_ ) || return( $self->pass_error );
# my $json_file = $self->new_file( __FILE__ )->parent->child( 'mime.json' );
my $types;
if( defined( $file ) )
{
$types
$types = $TYPES;
}
else
{
my $ref = $self->_data;
my $j = $self->new_json;
$types = $TYPES = $j->decode( $$ref );
}
$self->types( $types );
return( $se
at":["str"],"application/vnd.oasis.opendocument.spreadsheet-template":["ots"],"application/jsonml+json":["jsonml"],"application/vnd.ms-cab-compressed":["cab"],"application/vnd.dvb.ait":["ait"],"applic
e = lc( $type );
return( $type eq 'text/html' || $self->content_is_xhtml );
}
sub content_is_json
{
my $self = shift( @_ );
my $type = $self->type;
return(0) if( !defined( $type ) ||
ndard API error payload as per RFC9457: application/problem+json
return( $type eq 'application/json' || $type =~ m,^application/\w+\+json, );
}
sub content_is_text
{
my $self = shift( @_ );
f = shift( @_ );
if( @_ )
{
# mime-type like text/html, text/plain or application/json, etc...
my $type = shift( @_ );
$self->{type} = $type;
# We are being pro
>mime_name : $encoding ) if( $encoding );
}
elsif( $headers->content_type eq 'application/json' )
{
# RFC 4627, ch 3
return( 'UTF-32BE' ) if( $$cref =~ /^\x00\x00\x00./s );
zip
application/atom+xml gzip
application/javascript gzip
application/json gzip
application/pdf none
application/rss+xml gzip
app
/x-font-ttf gzip
application/x-javascript gzip
application/x-web-app-manifest+json gzip
application/xhtml+xml gzip
application/xml gzip
applicatio
ent to report attempts to violate the Content Security Policy. These violation reports consist of JSON documents sent via an HTTP POST request to the specified URI.
Example:
Content-Security-Po
>), which is per-object and thread-safe for independent operations. Operations like L</merge>, L</json>, and L</clone> operate on local data. However, concurrent modifications to a shared object are n
useful to provide response to error in the user preferred language. You can also use 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