NAME
Mojo::Headers - HTTP Headers
SYNOPSIS
use Mojo::Headers;
my $headers = Mojo::Headers->new;
$headers->content_type('text/plain');
$headers->parse("Content-Type: text/html\n\n");
print "$headers";
DESCRIPTION
Mojo::Headers is a generic container for HTTP headers.
ATTRIBUTES
Mojo::Headers inherits all attributes from Mojo::Stateful and implements the following new ones.
connection
my $connection = $headers->connection;
$headers = $headers->connection('close');
content_length
my $content_length = $headers->content_length;
$headers = $headers->content_length(4000);
content_type
my $content_type = $headers->content_type;
$headers = $headers->content_type('text/plain');
cookie
my $cookie = $headers->cookie;
$headers = $headers->cookie('$Version=1; f=b; $Path=/');
date
my $date = $headers->date;
$headers = $headers->date('Sun, 17 Aug 2008 16:27:35 GMT');
expect
my $expect = $headers->expect;
$headers = $headers->expect('100-continue');
host
my $host = $headers->host;
$headers = $headers->host('127.0.0.1');
proxy_authorization
my $proxy_authorization = $headers->proxy_authorization;
$headers = $headers->proxy_authorization('Basic Zm9vOmJhcg==');
set_cookie
my $set_cookie = $headers->set_cookie;
$headers = $headers->set_cookie('f=b; Version=1; Path=/');
set_cookie2
my $set_cookie2 = $headers->set_cookie2;
$headers = $headers->set_cookie2('f=b; Version=1; Path=/');
trailer
my $trailer = $headers->trailer;
$headers = $headers->trailer('X-Foo');
transfer_encoding
my $transfer_encoding = $headers->transfer_encoding;
$headers = $headers->transfer_encoding('chunked');
user_agent
my $user_agent = $headers->user_agent;
$headers = $headers->user_agent('Mojo/1.0');
METHODS
Mojo::Headers inherits all methods from Mojo::Stateful and implements the following new ones.
add_line
$headers = $headers->add_line('Content-Type', 'text/plain');
build
my $string = $headers->build;
my $string = $headers->as_string;
my $string = "$headers";
header
my $string = $headers->header('Content-Type');
my @lines = $headers->header('Content-Type');
$headers = $headers->header('Content-Type', 'text/plain');
names
my @names = $headers->names;
parse
my $success = $headers->parse("Content-Type: text/foo\n\n");
remove
$headers = $headers->remove('Content-Type');