Skip to content

Commit

Permalink
no need to keep list of headers
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Feb 19, 2014
1 parent 67de86a commit dfdb30f
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 15 deletions.
2 changes: 1 addition & 1 deletion Changes
Expand Up @@ -2,8 +2,8 @@
4.82 2014-02-19
- Added decode_json and encode_json functions to Mojo::JSON.
- Added data attribute to Mojo::JSON::Pointer.
- Fixed small decoding error bug in Mojo::JSON.
- Fixed bug in "user_agent_online.t".
- Fixed small decoding bug in Mojo::JSON.

4.81 2014-02-15
- Added direct array access for child nodes to Mojo::DOM.
Expand Down
15 changes: 7 additions & 8 deletions lib/Mojo/DOM/HTML.pm
Expand Up @@ -49,12 +49,6 @@ my $TOKEN_RE = qr/
)??
/xis;

# HTML elements that break paragraphs
my @PARAGRAPH = (
qw(address article aside blockquote dir div dl fieldset footer form h1 h2),
qw(h3 h4 h5 h6 header hr main menu nav ol p pre section table ul)
);

# HTML elements with optional end tags
my %END = (
body => ['head'],
Expand All @@ -63,8 +57,13 @@ my %END = (
rp => [qw(rt rp)],
rt => [qw(rt rp)]
);
$END{$_} = [$_] for qw(optgroup option);
$END{$_} = ['p'] for @PARAGRAPH;
$END{$_} = [$_] for qw(optgroup option);

# HTML elements that break paragraphs
map { $END{$_} = ['p'] } (
qw(address article aside blockquote dir div dl fieldset footer form h1 h2),
qw(h3 h4 h5 h6 header hr main menu nav ol p pre section table ul)
);

# HTML table elements with optional end tags
my %TABLE = map { $_ => 1 } qw(colgroup tbody td tfoot th thead tr);
Expand Down
7 changes: 2 additions & 5 deletions lib/Mojo/Headers.pm
Expand Up @@ -6,7 +6,7 @@ use Mojo::Util 'monkey_patch';
has max_line_size => sub { $ENV{MOJO_MAX_LINE_SIZE} || 10240 };

# Common headers
my @HEADERS = (
my %NORMALCASE = map { lc($_) => $_ } (
qw(Accept Accept-Charset Accept-Encoding Accept-Language Accept-Ranges),
qw(Allow Authorization Cache-Control Connection Content-Disposition),
qw(Content-Encoding Content-Length Content-Range Content-Type Cookie DNT),
Expand All @@ -16,15 +16,12 @@ my @HEADERS = (
qw(Sec-WebSocket-Protocol Sec-WebSocket-Version Server Set-Cookie Status),
qw(TE Trailer Transfer-Encoding Upgrade User-Agent Vary WWW-Authenticate)
);
for my $header (@HEADERS) {
for my $header (values %NORMALCASE) {
my $name = lc $header;
$name =~ s/-/_/g;
monkey_patch __PACKAGE__, $name, sub { scalar shift->header($header => @_) };
}

# Lowercase headers
my %NORMALCASE = map { lc($_) => $_ } @HEADERS;

sub add {
my ($self, $name) = (shift, shift);

Expand Down
2 changes: 1 addition & 1 deletion lib/Mojo/Message/Response.pm
Expand Up @@ -47,7 +47,7 @@ my %MESSAGES = (
415 => 'Unsupported Media Type',
416 => 'Request Range Not Satisfiable',
417 => 'Expectation Failed',
418 => "I'm a teapot", # :)
418 => "I'm a teapot", # RFC 2324 :)
422 => 'Unprocessable Entity', # RFC 2518 (WebDAV)
423 => 'Locked', # RFC 2518 (WebDAV)
424 => 'Failed Dependency', # RFC 2518 (WebDAV)
Expand Down

0 comments on commit dfdb30f

Please sign in to comment.