Mojo::T...on::HTTP(3)
π Mojo::T...on::HTTP(3) β like, the HTTP transaction page, bestie
okay so real talk: this is the manual page for Mojo::Transaction::HTTP, and up in the header it gets squished down to Mojo::T...on::HTTP(3) because terminal widths are rude. It's user contributed Perl documentation, and it is genuinely iconic. Let's get into it. π
β¨ NAME β¨
Mojo::Transaction::HTTP β HTTP transaction. That's the whole vibe. One transaction. Very main character. π¦
πΈ SYNOPSIS πΈ
Like, here's the whole thing in action, no notes:
use Mojo::Transaction::HTTP;
# Client
my $tx = Mojo::Transaction::HTTP->new;
$tx->req->method('GET');
$tx->req->url->parse('http://example.com');
$tx->req->headers->accept('application/json');
say $tx->res->code;
say $tx->res->headers->content_type;
say $tx->res->body;
say $tx->remote_address;
# Server
my $tx = Mojo::Transaction::HTTP->new;
say $tx->req->method;
say $tx->req->url->to_abs;
say $tx->req->headers->accept;
say $tx->remote_address;
$tx->res->code(200);
$tx->res->headers->content_type('text/plain');
$tx->res->body('Hello World!');
Two whole moods in one synopsis β client side and server side. We love a dual-threat. π
π«Ά DESCRIPTION π«Ά
Mojo::Transaction::HTTP is, like, a container for HTTP transactions. It's based on RFC 7230 <https://tools.ietf.org/html/rfc7230> and RFC 7231 <https://tools.ietf.org/html/rfc7231>. So it's standards-compliant and cute. Periodt. β¨
π₯ EVENTS π₯
Mojo::Transaction::HTTP inherits all events from Mojo::Transaction, and it can emit these new ones too. Obsessed.
π« request
$tx->on(request => sub ($tx) {...});
Emitted when a request is ready and needs to be handled. Like, the request is up and it's asking you to do something about it.
$tx->on(request => sub ($tx) { $tx->res->headers->header('X-Bender' => 'Bite my shiny metal ass!') });
X-Bender really said it with their whole chest, honestly. π
π« resume
$tx->on(resume => sub ($tx) {...});
Emitted when the transaction is resumed. Welcome back, king. π
π« unexpected
$tx->on(unexpected => sub ($tx, $res) {...});
Emitted for unexpected "1xx" responses that will be ignored. Rude of them, but okay.
$tx->on(unexpected => sub ($tx) { $tx->res->on(finish => sub { say 'Follow-up response is finished.' }) });
π ATTRIBUTES π
Mojo::Transaction::HTTP inherits all attributes from Mojo::Transaction and implements this new one. Yes, just the one. Quality over quantity, iykyk.
π previous
my $previous = $tx->previous;
$tx = $tx->previous(Mojo::Transaction::HTTP->new);
The previous transaction that triggered this follow-up transaction β usually a Mojo::Transaction::HTTP object.
# Paths of previous requests
say $tx->previous->previous->req->url->path;
say $tx->previous->req->url->path;
Look at that double previous. It's giving ancestry dot com. π³
β METHODS β
Mojo::Transaction::HTTP inherits all methods from Mojo::Transaction and implements these new ones. Strap in, there's a bunch. π’
π¦ client_read
$tx->client_read($bytes);
Read data client-side β this is the one used to implement user agents like Mojo::UserAgent. π§
π¦ client_write
my $bytes = $tx->client_write;
Write data client-side β again, used to implement user agents like Mojo::UserAgent.
π¦ is_empty
my $bool = $tx->is_empty;
Check the transaction for a "HEAD" request and a "1xx", 204 or 304 response. Basically a vibe check for emptiness. π
π¦ keep_alive
my $bool = $tx->keep_alive;
Check if the connection can be kept alive. Not to be dramatic but this is literally life or death for the connection. π
π¦ redirects
my $redirects = $tx->redirects;
Returns an array reference with all previous transactions that preceded this follow-up transaction.
# Paths of all previous requests
say $_->req->url->path for @{$tx->redirects};
All of them. Every single one. We're going through the whole group chat history, no skipping. π
π¦ resume
$tx = $tx->resume;
Resume the transaction. That's it, that's the method. Slay.
π¦ server_read
$tx->server_read($bytes);
Read data server-side β this is the one used to implement web servers such as Mojo::Server::Daemon.
π¦ server_write
my $bytes = $tx->server_write;
Write data server-side β used to implement web servers such as Mojo::Server::Daemon. Matching set with client_write, we love symmetry. π
π SEE ALSO π
MojoliciousMojolicious::Guides- <https://mojolicious.org>
Go read them, bestie, they're iconic.
okay that's the whole page, every last flag and method accounted for, no cap. Now go build something cute. π
sign-off time: this beauty is perl v5.42.0, dated 2026-07-15, and yes the footer also calls it Mojo::T...on::HTTP(3) because the truncation never stops. mwah π π¦ β¨
π¦ where this page comes from
- opensuse-leap 16.0: perl-Mojolicious 9.480.0-bp160.2.1 Β· Artistic-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms