Whatpm::CacheManifest - An HTML5 Cache Manifest Parser
use Whatpm::CacheManifest; my $manifest_uri = q<http://www.example.com/manifest>; my ($manifest_data, $manifest_base_uri) = some_function_to_retrieve_content ($manifest_uri); # or, my $manifest = Whatpm::CacheManifest->parse_byte_string ($manifest_data, $manifest_uri, $manifest_base_uri, sub { my %err = @_; warn $err{type}, "\n"; }); $manifest_data = Encode::decode ('utf-8', $manifest_data); my $manifest = Whatpm::CacheManifest->parse_char_string ($manifest_data, $manifest_uri, $manifest_base_uri, sub { my %err = @_; warn $err{type}, "\n"; }); # $manifest->[0]: Array reference of explicit URIs. # $manifest->[1]: Hash reference of fallback URIs. # $manifest->[2]: Array reference of online whitelist.
The Whatpm::CacheManifest
module implements the parsing algorithm
for HTML5 cache manifest format, used to describe an offline Web
application.
This module provides two class methods to parse cache manifests:
These methods parse a cache manifest and return that cache manifest in the MANIFEST DATA STRUCTURE.
Parameters:
U+0000
NULL
characters; they are converted to
U+FFFD
REPLACEMENT CHARACTER
s as defined in the specification.
warn
ed with its type
.
@@ TBW
For the list of the error types, see Whatpm Error Types <http://suika.fam.cx/gate/2005/sw/Whatpm%20Error%20Types>.
In addition, a class method to check conformance of cache manifests is provided:
warn
ed with its type
.
@@ TBW
For the list of the error types, see Whatpm Error Types <http://suika.fam.cx/gate/2005/sw/Whatpm%20Error%20Types>.
A cache manifest is conforming if (a) it is correctly labeled
as a cache manifest (e.g. as Internet media type text/cache-manifest
)
in the transfer layer, (b) parsing the cache manifest by
parse_byte_string
or parse_char_string
raises no error
with level m
or s
, and (c) checking the cache manifest by
check_manifest
raises no error with level m
or s
.
If $m is in manifest data structure, $m is a reference to the array with three items: $explicit_uris, $fallback_uris, and $online_whitelist.
$explicit_uris is a reference to the array, which contains zero or more strings. The strings are IRI references of the explicit entries.
$fallback_uris is a reference to the hash, which contains zero or more mappings of strings (keys) to strings (values). The keys are IRI references of the oppotunistic caching namespaces. The values are IRI references of the fallback entries corresponding to the oppotunistic caching namespaces.
$online_whitelist is a reference to the array, which contains zero or more strings. The strings are IRI references in the online whitelist.
This module depends on the Message::URI::URIReference manpage, which is part of manakai.
Whatpm Error Types <http://suika.fam.cx/gate/2005/sw/Whatpm%20Error%20Types>.
HTML5 <http://whatwg.org/html5>.
the Message::URI::URIReference manpage <http://suika.fam.cx/www/manakai-core/lib/Message/URI/URIReference.html>.
``Same scheme/host/port'' comparison algorithm is not correctly implemented yet.
Wakaba <w@suika.fam.cx>
Copyright 2007 Wakaba <w@suika.fam.cx>
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.