e|SPVM::Mojo::Headers/"max_line_size"> field.
=head2 json
C<method json : object ();>
Decode JSON message body directly using L<JSON|SPVM::JSON> if possible, an C<undef> return value indicates a ba
's a 16MiB limit for requests and a 2GiB limit for responses by default.
# Extract JSON values
say $msg->json->(Hash)->get("foo")->(Hash)->get("bar")->(List)->get(23)->(string);
=head2 parse
C<
[(object)form => {a => "b"}])->req->to_string;
# PUT request with JSON data
say $t->tx(PUT => "example.com" => [(object)json => {a => "b"}])->req->to_string;
=head1 Generators
These content ge
ntent. See L</"tx"> for more.
=head2 json
$t->tx(PATCH => "http://example.com" => [(object)json => {a => "b"}]);
Generate JSON content with L<JSON|SPVM::JSON>. See L</"tx"> for more.
=head2 mult
nt::Transactor::Callback::Generator>;>
Registered content generators, by default only C<form>, C<json> and C<multipart> are already defined.
=head2 name
C<has name : rw string;>
Value for C<User-A
GET");
$tx->req->url->parse("http://example.com");
$tx->req->headers->set_accept("application/json");
say $tx->res->code;
say $tx->res->headers->content_type;
say $tx->res->body;
say $tx->
header value, shortcut for the C<Accept> header.
Examples:
$headers->set_accept("application/json");
=head2 accept_charset
C<method accept_charset : string ();>
Get current header value, short
WebSocket::Frame) {
});
=head2 json
Emitted when a complete WebSocket message has been received, all text and binary messages will be automatically JSON
decoded. Note that this event only get
id ($ws : L<Mojo::Transaction::WebSocket|SPVM::Mojo::Transaction::WebSocket>, $json : object);>
Examples:
$ws->on(json => method : void ($ws : Mojo::Transaction::WebSocket, $hash : object) { say "
$bytes});
my $frame = $ws->build_message({text => $bytes});
my $frame = $ws->build_message({json => $data});
my $frame = $ws->build_message($chars);
=head2 client_read
C<method client_read
JSON API request with Basic authentication
my $url = (my $_ = Mojo::URL->new("https://example.com/test.json"), $_->set_userinfo("sri:☃"), $_);
my $value = $ua->get($url)->result->json;
# JSON
POST (application/json) with TLS certificate authentication
my $tx = ($ua->set_cert("tls.crt"), $ua->set_key("tls.key"), $ua->post("https://example.com" => [(object)json => {top => "secret"}]));
p("socks://127.0.0.1:9050");
$ua->get("api.3g2upl4pq6kufc4m.onion/?q=mojolicious&format=json")->result->json;
# GET request via UNIX domain socket "/tmp/myapp.sock" (percent encoded slash)
say
y $hash = $tx->req->params->to_hash;
my $all = $tx->req->uploads;
my $value = $tx->req->json;
=head2 res
C<has res : rw L<Mojo::Message::Response|SPVM::Mojo::Message::Response>;>
HTTP res
ader");
my $bytes = $tx->res->body;
my $str = $tx->res->text;
my $value = $tx->res->json;
=head2 connection
C<has connection : rw L<Mojo::Connection|SPVM::Mojo::Connection>;>
Connecti