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_length
my $body_length = $message->body_length;
buffer
my $buffer = $message->buffer;
$message = $message->buffer(Mojo::Buffer->new);
build_body_cb
my $cb = $message->build_body_cb;
$counter = 1;
$message = $message->build_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;
});
build_headers_cb
my $cb = $message->build_headers_cb;
$message = $message->build_headers_cb(sub {
my $h = Mojo::Headers->new;
$h->content_type('text/plain');
return $h->to_string;
});
build_start_line_cb
my $cb = $message->build_start_line_cb;
$message = $content->build_start_line_cb(sub {
return "HTTP/1.1 200 OK\r\n\r\n";
});
builder_progress_cb
my $cb = $message->builder_progress_cb;
$message = $message->builder_progress_cb(sub {
my $self = shift;
print '+';
});
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);
parser_progress_cb
my $cb = $message->parser_progress_cb;
$message = $message->parser_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.
body
my $string = $message->body;
$message = $message->body('Hello!');
body_params
my $params = $message->body_params;
Returns a Mojo::Parameters object, containing POST parameters.
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');
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);
is_chunked
my $is_chunked = $message->is_chunked;
is_multipart
my $is_multipart = $message->is_multipart;
is_version
my $is_version = $message->is_version('1.1);
param
my $param = $message->param('foo');
parse
$message = $message->parse('HTTP/1.1 200 OK...');
upload
my $upload = $message->upload('foo');
Returns a Mojo::Upload object or a arrayref of Mojo::Upload objects.
uploads
my $uploads = $message->uploads;
Returns a arrayref of Mojo::Upload objects.