
Mojo::Content - Content

use Mojo::Content;
my $content = Mojo::Content->new;
$content->parse("Content-Length: 12\r\n\r\nHello World!");

Mojo::Content is a container for HTTP content.

Mojo::Content inherits all attributes from Mojo::Stateful and implements the following new ones.
body_cb my $cb = $content->body_cb;
$counter = 1;
$content = $content->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_lengthmy $body_length = $content->body_length;
buffer my $buffer = $content->buffer;
$content = $content->buffer(Mojo::Buffer->new);
builder_progress_cb my $cb = $content->builder_progress_cb;
$content = $content->builder_progress_cb(sub {
my $self = shift;
print '+';
});
file my $file = $content->file;
$content = $content->file(Mojo::File::Memory->new);
filter_buffer my $filter_buffer = $content->filter_buffer;
$content = $content->filter_buffer(Mojo::Buffer->new);
header_lengthmy $header_length = $content->header_length;
headers my $headers = $content->headers;
$content = $content->headers(Mojo::Headers->new);
raw_header_lengthmy $raw_header_length = $content->raw_header_length;
raw_body_lengthmy $raw_body_length = $content->raw_body_length;

Mojo::Content inherits all methods from Mojo::Stateful and implements the following new ones.
build_bodymy $string = $content->build_body;
build_headersmy $string = $content->build_headers;
body_containsmy $found = $content->body_contains;
get_body_chunkmy $chunk = $content->get_body_chunk(0);
get_header_chunkmy $chunk = $content->get_header_chunk(13);
is_chunkedmy $chunked = $content->is_chunked;
is_multipartmy $multipart = $content->is_multipart;
parse $content = $content->parse("Content-Length: 12\r\n\r\nHello World!");