Mojo::Headers(3p)

NAME
Mojo::Headers - 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 container and parser 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_disposition"
    my $content_disposition = $headers->content_disposition;
    $headers                = $headers->content_disposition('foo');

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

  "location"
    my $location = $headers->location;
    $headers     = $headers->location('http://127.0.0.1/foo');

  "proxy_authorization"
    my $proxy_authorization = $headers->proxy_authorization;
    $headers = $headers->proxy_authorization('Basic Zm9vOmJhcg==');

  "server"
    my $server = $headers->server;
    $headers   = $headers->server('Mojo');

  "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=/');

  "status"
    my $status = $headers->status;
    $headers   = $headers->status('200 OK');

  "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.

  "new"
    my $headers = Mojo::Headers->new;

  "add"
    $headers = $headers->add('Content-Type', 'text/plain');

  "to_string"

  "build"
    my $string = $headers->build;
    my $string = $headers->to_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');