.\" Automatically generated by Pod::Man 2.25 (Pod::Simple 3.16) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .ie \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . nr % 0 . rr F .\} .el \{\ . de IX .. .\} .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "Mojo::Headers 3pm" .TH Mojo::Headers 3pm "2012-09-05" "perl v5.14.2" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Mojo::Headers \- Headers .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& use Mojo::Headers; \& \& my $headers = Mojo::Headers\->new; \& $headers\->content_type(\*(Aqtext/plain\*(Aq); \& $headers\->parse("Content\-Type: text/html\en\en"); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" Mojo::Headers is a container and parser for \s-1HTTP\s0 headers. .SH "ATTRIBUTES" .IX Header "ATTRIBUTES" Mojo::Headers implements the following attributes. .ie n .SS """max_line_size""" .el .SS "\f(CWmax_line_size\fP" .IX Subsection "max_line_size" .Vb 2 \& my $size = $headers\->max_line_size; \& $headers = $headers\->max_line_size(1024); .Ve .PP Maximum line size in bytes, defaults to the value of the \&\f(CW\*(C`MOJO_MAX_LINE_SIZE\*(C'\fR environment variable or \f(CW10240\fR. .SH "METHODS" .IX Header "METHODS" Mojo::Headers inherits all methods from Mojo::Base and implements the following new ones. .ie n .SS """accept""" .el .SS "\f(CWaccept\fP" .IX Subsection "accept" .Vb 2 \& my $accept = $headers\->accept; \& $headers = $headers\->accept(\*(Aqapplication/json\*(Aq); .Ve .PP Shortcut for the \f(CW\*(C`Accept\*(C'\fR header. .ie n .SS """accept_language""" .el .SS "\f(CWaccept_language\fP" .IX Subsection "accept_language" .Vb 2 \& my $accept_language = $headers\->accept_language; \& $headers = $headers\->accept_language(\*(Aqde, en\*(Aq); .Ve .PP Shortcut for the \f(CW\*(C`Accept\-Language\*(C'\fR header. .ie n .SS """accept_ranges""" .el .SS "\f(CWaccept_ranges\fP" .IX Subsection "accept_ranges" .Vb 2 \& my $ranges = $headers\->accept_ranges; \& $headers = $headers\->accept_ranges(\*(Aqbytes\*(Aq); .Ve .PP Shortcut for the \f(CW\*(C`Accept\-Ranges\*(C'\fR header. .ie n .SS """add""" .el .SS "\f(CWadd\fP" .IX Subsection "add" .Vb 1 \& $headers = $headers\->add(\*(AqContent\-Type\*(Aq, \*(Aqtext/plain\*(Aq); .Ve .PP Add one or more header lines. .ie n .SS """authorization""" .el .SS "\f(CWauthorization\fP" .IX Subsection "authorization" .Vb 2 \& my $authorization = $headers\->authorization; \& $headers = $headers\->authorization(\*(AqBasic Zm9vOmJhcg==\*(Aq); .Ve .PP Shortcut for the \f(CW\*(C`Authorization\*(C'\fR header. .ie n .SS """cache_control""" .el .SS "\f(CWcache_control\fP" .IX Subsection "cache_control" .Vb 2 \& my $cache_control = $headers\->cache_control; \& $headers = $headers\->cache_control(\*(Aqmax\-age=1, no\-cache\*(Aq); .Ve .PP Shortcut for the \f(CW\*(C`Cache\-Control\*(C'\fR header. .ie n .SS """clone""" .el .SS "\f(CWclone\fP" .IX Subsection "clone" .Vb 1 \& my $clone = $headers\->clone; .Ve .PP Clone headers. .ie n .SS """connection""" .el .SS "\f(CWconnection\fP" .IX Subsection "connection" .Vb 2 \& my $connection = $headers\->connection; \& $headers = $headers\->connection(\*(Aqclose\*(Aq); .Ve .PP Shortcut for the \f(CW\*(C`Connection\*(C'\fR header. .ie n .SS """content_disposition""" .el .SS "\f(CWcontent_disposition\fP" .IX Subsection "content_disposition" .Vb 2 \& my $content_disposition = $headers\->content_disposition; \& $headers = $headers\->content_disposition(\*(Aqfoo\*(Aq); .Ve .PP Shortcut for the \f(CW\*(C`Content\-Disposition\*(C'\fR header. .ie n .SS """content_length""" .el .SS "\f(CWcontent_length\fP" .IX Subsection "content_length" .Vb 2 \& my $content_length = $headers\->content_length; \& $headers = $headers\->content_length(4000); .Ve .PP Shortcut for the \f(CW\*(C`Content\-Length\*(C'\fR header. .ie n .SS """content_range""" .el .SS "\f(CWcontent_range\fP" .IX Subsection "content_range" .Vb 2 \& my $range = $headers\->content_range; \& $headers = $headers\->content_range(\*(Aqbytes 2\-8/100\*(Aq); .Ve .PP Shortcut for the \f(CW\*(C`Content\-Range\*(C'\fR header. .ie n .SS """content_transfer_encoding""" .el .SS "\f(CWcontent_transfer_encoding\fP" .IX Subsection "content_transfer_encoding" .Vb 2 \& my $encoding = $headers\->content_transfer_encoding; \& $headers = $headers\->content_transfer_encoding(\*(Aqfoo\*(Aq); .Ve .PP Shortcut for the \f(CW\*(C`Content\-Transfer\-Encoding\*(C'\fR header. .ie n .SS """content_type""" .el .SS "\f(CWcontent_type\fP" .IX Subsection "content_type" .Vb 2 \& my $content_type = $headers\->content_type; \& $headers = $headers\->content_type(\*(Aqtext/plain\*(Aq); .Ve .PP Shortcut for the \f(CW\*(C`Content\-Type\*(C'\fR header. .ie n .SS """cookie""" .el .SS "\f(CWcookie\fP" .IX Subsection "cookie" .Vb 2 \& my $cookie = $headers\->cookie; \& $headers = $headers\->cookie(\*(Aqf=b\*(Aq); .Ve .PP Shortcut for the \f(CW\*(C`Cookie\*(C'\fR header. .ie n .SS """date""" .el .SS "\f(CWdate\fP" .IX Subsection "date" .Vb 2 \& my $date = $headers\->date; \& $headers = $headers\->date(\*(AqSun, 17 Aug 2008 16:27:35 GMT\*(Aq); .Ve .PP Shortcut for the \f(CW\*(C`Date\*(C'\fR header. .ie n .SS """dnt""" .el .SS "\f(CWdnt\fP" .IX Subsection "dnt" .Vb 2 \& my $dnt = $headers\->dnt; \& $headers = $headers\->dnt(1); .Ve .PP Shortcut for the \f(CW\*(C`DNT\*(C'\fR (Do Not Track) header. .ie n .SS """etag""" .el .SS "\f(CWetag\fP" .IX Subsection "etag" .Vb 2 \& my $etag = $headers\->etag; \& $headers = $headers\->etag(\*(Aqabc321\*(Aq); .Ve .PP Shortcut for the \f(CW\*(C`ETag\*(C'\fR header. .ie n .SS """expect""" .el .SS "\f(CWexpect\fP" .IX Subsection "expect" .Vb 2 \& my $expect = $headers\->expect; \& $headers = $headers\->expect(\*(Aq100\-continue\*(Aq); .Ve .PP Shortcut for the \f(CW\*(C`Expect\*(C'\fR header. .ie n .SS """expires""" .el .SS "\f(CWexpires\fP" .IX Subsection "expires" .Vb 2 \& my $expires = $headers\->expires; \& $headers = $headers\->expires(\*(AqThu, 01 Dec 1994 16:00:00 GMT\*(Aq); .Ve .PP Shortcut for the \f(CW\*(C`Expires\*(C'\fR header. .ie n .SS """from_hash""" .el .SS "\f(CWfrom_hash\fP" .IX Subsection "from_hash" .Vb 1 \& $headers = $headers\->from_hash({\*(AqContent\-Type\*(Aq => \*(Aqtext/html\*(Aq}); .Ve .PP Parse headers from a hash reference. .ie n .SS """header""" .el .SS "\f(CWheader\fP" .IX Subsection "header" .Vb 3 \& my $string = $headers\->header(\*(AqContent\-Type\*(Aq); \& my @lines = $headers\->header(\*(AqContent\-Type\*(Aq); \& $headers = $headers\->header(\*(AqContent\-Type\*(Aq => \*(Aqtext/plain\*(Aq); .Ve .PP Get or replace the current header values. .PP .Vb 3 \& # Multiple headers with the same name \& for my $header ($headers\->header(\*(AqSet\-Cookie\*(Aq)) { \& say \*(AqSet\-Cookie:\*(Aq; \& \& # Multiple lines per header \& say for @$header; \& } .Ve .ie n .SS """host""" .el .SS "\f(CWhost\fP" .IX Subsection "host" .Vb 2 \& my $host = $headers\->host; \& $headers = $headers\->host(\*(Aq127.0.0.1\*(Aq); .Ve .PP Shortcut for the \f(CW\*(C`Host\*(C'\fR header. .ie n .SS """if_modified_since""" .el .SS "\f(CWif_modified_since\fP" .IX Subsection "if_modified_since" .Vb 2 \& my $m = $headers\->if_modified_since; \& $headers = $headers\->if_modified_since(\*(AqSun, 17 Aug 2008 16:27:35 GMT\*(Aq); .Ve .PP Shortcut for the \f(CW\*(C`If\-Modified\-Since\*(C'\fR header. .ie n .SS """is_finished""" .el .SS "\f(CWis_finished\fP" .IX Subsection "is_finished" .Vb 1 \& my $success = $headers\->is_finished; .Ve .PP Check if header parser is finished. .ie n .SS """is_limit_exceeded""" .el .SS "\f(CWis_limit_exceeded\fP" .IX Subsection "is_limit_exceeded" .Vb 1 \& my $success = $headers\->is_limit_exceeded; .Ve .PP Check if a header has exceeded \f(CW\*(C`max_line_size\*(C'\fR. .ie n .SS """last_modified""" .el .SS "\f(CWlast_modified\fP" .IX Subsection "last_modified" .Vb 2 \& my $m = $headers\->last_modified; \& $headers = $headers\->last_modified(\*(AqSun, 17 Aug 2008 16:27:35 GMT\*(Aq); .Ve .PP Shortcut for the \f(CW\*(C`Last\-Modified\*(C'\fR header. .ie n .SS """leftovers""" .el .SS "\f(CWleftovers\fP" .IX Subsection "leftovers" .Vb 1 \& my $leftovers = $headers\->leftovers; .Ve .PP Leftovers. .ie n .SS """location""" .el .SS "\f(CWlocation\fP" .IX Subsection "location" .Vb 2 \& my $location = $headers\->location; \& $headers = $headers\->location(\*(Aqhttp://127.0.0.1/foo\*(Aq); .Ve .PP Shortcut for the \f(CW\*(C`Location\*(C'\fR header. .ie n .SS """names""" .el .SS "\f(CWnames\fP" .IX Subsection "names" .Vb 1 \& my $names = $headers\->names; .Ve .PP Generate a list of all currently defined headers. .ie n .SS """parse""" .el .SS "\f(CWparse\fP" .IX Subsection "parse" .Vb 1 \& $headers = $headers\->parse("Content\-Type: text/foo\en\en"); .Ve .PP Parse formatted headers. .ie n .SS """proxy_authenticate""" .el .SS "\f(CWproxy_authenticate\fP" .IX Subsection "proxy_authenticate" .Vb 2 \& my $authenticate = $headers\->proxy_authenticate; \& $headers = $headers\->proxy_authenticate(\*(AqBasic "realm"\*(Aq); .Ve .PP Shortcut for the \f(CW\*(C`Proxy\-Authenticate\*(C'\fR header. .ie n .SS """proxy_authorization""" .el .SS "\f(CWproxy_authorization\fP" .IX Subsection "proxy_authorization" .Vb 2 \& my $proxy_authorization = $headers\->proxy_authorization; \& $headers = $headers\->proxy_authorization(\*(AqBasic Zm9vOmJhcg==\*(Aq); .Ve .PP Shortcut for the \f(CW\*(C`Proxy\-Authorization\*(C'\fR header. .ie n .SS """range""" .el .SS "\f(CWrange\fP" .IX Subsection "range" .Vb 2 \& my $range = $headers\->range; \& $headers = $headers\->range(\*(Aqbytes=2\-8\*(Aq); .Ve .PP Shortcut for the \f(CW\*(C`Range\*(C'\fR header. .ie n .SS """referrer""" .el .SS "\f(CWreferrer\fP" .IX Subsection "referrer" .Vb 2 \& my $referrer = $headers\->referrer; \& $headers = $headers\->referrer(\*(Aqhttp://mojolicio.us\*(Aq); .Ve .PP Shortcut for the \f(CW\*(C`Referer\*(C'\fR header, there was a typo in \s-1RFC\s0 2068 which resulted in \f(CW\*(C`Referer\*(C'\fR becoming an official header. .ie n .SS """remove""" .el .SS "\f(CWremove\fP" .IX Subsection "remove" .Vb 1 \& $headers = $headers\->remove(\*(AqContent\-Type\*(Aq); .Ve .PP Remove a header. .ie n .SS """sec_websocket_accept""" .el .SS "\f(CWsec_websocket_accept\fP" .IX Subsection "sec_websocket_accept" .Vb 2 \& my $accept = $headers\->sec_websocket_accept; \& $headers = $headers\->sec_websocket_accept(\*(Aqs3pPLMBiTxaQ9kYGzzhZRbK+xOo=\*(Aq); .Ve .PP Shortcut for the \f(CW\*(C`Sec\-WebSocket\-Accept\*(C'\fR header. .ie n .SS """sec_websocket_key""" .el .SS "\f(CWsec_websocket_key\fP" .IX Subsection "sec_websocket_key" .Vb 2 \& my $key = $headers\->sec_websocket_key; \& $headers = $headers\->sec_websocket_key(\*(AqdGhlIHNhbXBsZSBub25jZQ==\*(Aq); .Ve .PP Shortcut for the \f(CW\*(C`Sec\-WebSocket\-Key\*(C'\fR header. .ie n .SS """sec_websocket_origin""" .el .SS "\f(CWsec_websocket_origin\fP" .IX Subsection "sec_websocket_origin" .Vb 2 \& my $origin = $headers\->sec_websocket_origin; \& $headers = $headers\->sec_websocket_origin(\*(Aqhttp://example.com\*(Aq); .Ve .PP Shortcut for the \f(CW\*(C`Sec\-WebSocket\-Origin\*(C'\fR header. .ie n .SS """sec_websocket_protocol""" .el .SS "\f(CWsec_websocket_protocol\fP" .IX Subsection "sec_websocket_protocol" .Vb 2 \& my $protocol = $headers\->sec_websocket_protocol; \& $headers = $headers\->sec_websocket_protocol(\*(Aqsample\*(Aq); .Ve .PP Shortcut for the \f(CW\*(C`Sec\-WebSocket\-Protocol\*(C'\fR header. .ie n .SS """sec_websocket_version""" .el .SS "\f(CWsec_websocket_version\fP" .IX Subsection "sec_websocket_version" .Vb 2 \& my $version = $headers\->sec_websocket_version; \& $headers = $headers\->sec_websocket_version(13); .Ve .PP Shortcut for the \f(CW\*(C`Sec\-WebSocket\-Version\*(C'\fR header. .ie n .SS """server""" .el .SS "\f(CWserver\fP" .IX Subsection "server" .Vb 2 \& my $server = $headers\->server; \& $headers = $headers\->server(\*(AqMojo\*(Aq); .Ve .PP Shortcut for the \f(CW\*(C`Server\*(C'\fR header. .ie n .SS """set_cookie""" .el .SS "\f(CWset_cookie\fP" .IX Subsection "set_cookie" .Vb 2 \& my $set_cookie = $headers\->set_cookie; \& $headers = $headers\->set_cookie(\*(Aqf=b; path=/\*(Aq); .Ve .PP Shortcut for the \f(CW\*(C`Set\-Cookie\*(C'\fR header. .ie n .SS """status""" .el .SS "\f(CWstatus\fP" .IX Subsection "status" .Vb 2 \& my $status = $headers\->status; \& $headers = $headers\->status(\*(Aq200 OK\*(Aq); .Ve .PP Shortcut for the \f(CW\*(C`Status\*(C'\fR header. .ie n .SS """to_hash""" .el .SS "\f(CWto_hash\fP" .IX Subsection "to_hash" .Vb 2 \& my $single = $headers\->to_hash; \& my $multi = $headers\->to_hash(1); .Ve .PP Turn headers into hash reference, nested array references to represent multi line values are disabled by default. .ie n .SS """to_string""" .el .SS "\f(CWto_string\fP" .IX Subsection "to_string" .Vb 1 \& my $string = $headers\->to_string; .Ve .PP Turn headers into a string, suitable for \s-1HTTP\s0 1.1 messages. .ie n .SS """trailer""" .el .SS "\f(CWtrailer\fP" .IX Subsection "trailer" .Vb 2 \& my $trailer = $headers\->trailer; \& $headers = $headers\->trailer(\*(AqX\-Foo\*(Aq); .Ve .PP Shortcut for the \f(CW\*(C`Trailer\*(C'\fR header. .ie n .SS """transfer_encoding""" .el .SS "\f(CWtransfer_encoding\fP" .IX Subsection "transfer_encoding" .Vb 2 \& my $transfer_encoding = $headers\->transfer_encoding; \& $headers = $headers\->transfer_encoding(\*(Aqchunked\*(Aq); .Ve .PP Shortcut for the \f(CW\*(C`Transfer\-Encoding\*(C'\fR header. .ie n .SS """upgrade""" .el .SS "\f(CWupgrade\fP" .IX Subsection "upgrade" .Vb 2 \& my $upgrade = $headers\->upgrade; \& $headers = $headers\->upgrade(\*(Aqwebsocket\*(Aq); .Ve .PP Shortcut for the \f(CW\*(C`Upgrade\*(C'\fR header. .ie n .SS """user_agent""" .el .SS "\f(CWuser_agent\fP" .IX Subsection "user_agent" .Vb 2 \& my $user_agent = $headers\->user_agent; \& $headers = $headers\->user_agent(\*(AqMojo/1.0\*(Aq); .Ve .PP Shortcut for the \f(CW\*(C`User\-Agent\*(C'\fR header. .ie n .SS """www_authenticate""" .el .SS "\f(CWwww_authenticate\fP" .IX Subsection "www_authenticate" .Vb 2 \& my $authenticate = $headers\->www_authenticate; \& $headers = $headers\->www_authenticate(\*(AqBasic realm="realm"\*(Aq); .Ve .PP Shortcut for the \f(CW\*(C`WWW\-Authenticate\*(C'\fR header. .SH "SEE ALSO" .IX Header "SEE ALSO" Mojolicious, Mojolicious::Guides, .