NAME

Mojo::Message - HTTP 1.1 Message Base Class

SYNOPSIS

    use base 'Mojo::Message';

DESCRIPTION

Mojo::Message is an abstract base class for HTTP 1.1 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;
    });

buffer

    my $buffer = $message->buffer;
    $message   = $message->buffer(Mojo::ByteStream->new);

content

    my $content = $message->content;
    $message    = $message->content(Mojo::Content::Single->new);

default_charset

    my $charset = $message->default_charset;
    $message    = $message->default_charset('UTF-8');

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 '+';
    });

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;

body_size

    my $size = $message->body_size;

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;
    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;

header_size

    my $size = $message->header_size;

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...');

start_line_size

    my $size = $message->start_line_size;

upload

    my $upload  = $message->upload('foo');
    my @uploads = $message->upload('foo');

uploads

    my $uploads = $message->uploads;

version

    my $version = $message->version;
    $message    = $message->version('1.1');

SEE ALSO

Mojolicious, Mojolicious::Book, http://mojolicious.org.