NAME
Mojo::Message - Message Base Class
SYNOPSIS
use base 'Mojo::Message';
DESCRIPTION
Mojo::Message is a base class for HTTP messages.
ATTRIBUTES
Mojo::Message inherits all attributes from Mojo::Stateful and implements the following new ones.
body_cb
my $cb = $message->body_cb;
$counter = 1;
$message = $message->body_cb(sub {
my $self = shift;
my $chunk = '';
$chunk = "hello world!" if $counter == 1;
$chunk = "hello world2!\n\n" if $counter == 2;
$counter++;
return $chunk;
});
body_length
my $body_length = $message->body_length;
buffer
my $buffer = $message->buffer;
$message = $message->buffer(Mojo::Buffer->new);
content
my $content = $message->content;
$message = $message->content(Mojo::Content->new);
header_length
my $header_length = $message->header_length;
headers
my $headers = $message->headers;
$message = $message->headers(Mojo::Headers->new);
major_version
my $major_version = $message->major_version;
$message = $message->major_version(1);
minor_version
my $minor_version = $message->minor_version;
$message = $message->minor_version(1);
progress_cb
my $cb = $message->progress_cb;
$message = $message->progress_cb(sub {
my $self = shift;
print '+';
});
raw_body_length
my $raw_body_length = $message->raw_body_length;
start_line_length
my $start_line_length = $message->start_line_length;
version
my $version = $message->version;
$message = $message->version('1.1');
METHODS
Mojo::Message inherits all methods from Mojo::Stateful and implements the following new ones.
at_least_version
my $success = $message->at_least_version('1.1');
body
my $string = $message->body;
$message = $message->body('Hello!');
$counter = 1;
$message = $message->body(sub {
my $self = shift;
my $chunk = '';
$chunk = "hello world!" if $counter == 1;
$chunk = "hello world2!\n\n" if $counter == 2;
$counter++;
return $chunk;
});
body_params
my $params = $message->body_params;
to_string
build
my $string = $message->build;
build_body
my $string = $message->build_body;
build_headers
my $string = $message->build_headers;
build_start_line
my $string = $message->build_start_line;
cookie
my $cookie = $message->cookie('foo');
my @cookies = $message->cookie('foo');
fix_headers
$message = $message->fix_headers;
get_body_chunk
my $string = $message->get_body_chunk($offset);
get_header_chunk
my $string = $message->get_header_chunk($offset);
get_start_line_chunk
my $string = $message->get_start_line_chunk($offset);
has_leftovers
my $leftovers = $message->has_leftovers;
is_chunked
my $chunked = $message->is_chunked;
is_multipart
my $multipart = $message->is_multipart;
leftovers
my $bytes = $message->leftovers;
param
my $param = $message->param('foo');
my @params = $message->param('foo');
parse
$message = $message->parse('HTTP/1.1 200 OK...');
parse_until_body
$message = $message->parse_until_body('HTTP/1.1 200 OK...');
upload
my $upload = $message->upload('foo');
my @uploads = $message->upload('foo');
uploads
my $uploads = $message->uploads;