.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.40) .\" .\" 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" '' . ds C` . ds C' '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 >0, 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. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "HTTP::LRDD 3pm" .TH HTTP::LRDD 3pm "2021-09-11" "perl v5.32.1" "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" HTTP::LRDD \- link\-based resource descriptor discovery .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& use HTTP::LRDD; \& \& my $lrdd = HTTP::LRDD\->new; \& my @descriptors = $lrdd\->discover($resource); \& foreach my $descriptor (@descriptors) \& { \& my $description = $lrdd\->parse($descriptor); \& # $description is an RDF::Trine::Model \& } .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" Note: the \s-1LRDD\s0 specification has ceased to be, with some parts being merged into the host-meta Internet Draft. This \s-1CPAN\s0 module will go in its own direction, bundling up best-practice techniques for discovering links and descriptors for a given \s-1URI.\s0 .SS "Import Routine" .IX Subsection "Import Routine" .ie n .IP """use HTTP::LRDD (@predicates)""" 4 .el .IP "\f(CWuse HTTP::LRDD (@predicates)\fR" 4 .IX Item "use HTTP::LRDD (@predicates)" When importing \s-1HTTP::LRDD,\s0 you can optionally provide a list of predicate URIs (i.e. the URIs which rel values expand to). This may also include IANA-registered link types, which are short tokens rather than full URIs. If you do not provide a list of predicate URIs, then a sensible default set is used. .Sp Because this configuration is global in nature, it is not recommended. It is better to supply a list of predicates to the constructor instead, or rely on the defaults. This feature should be regarded as deprecated. .SS "Constructors" .IX Subsection "Constructors" .ie n .IP """HTTP::LRDD\->new(@predicates)""" 4 .el .IP "\f(CWHTTP::LRDD\->new(@predicates)\fR" 4 .IX Item "HTTP::LRDD->new(@predicates)" Create a new \s-1LRDD\s0 discovery object using the given predicate URIs. If \f(CW@predicates\fR is omitted, then the predicates passed to the import routine are used instead. .ie n .IP """HTTP::LRDD\->new_strict""" 4 .el .IP "\f(CWHTTP::LRDD\->new_strict\fR" 4 .IX Item "HTTP::LRDD->new_strict" Create a new \s-1LRDD\s0 discovery object using the 'describedby' and \&'lrdd' IANA-registered predicates. .ie n .IP """HTTP::LRDD\->new_default""" 4 .el .IP "\f(CWHTTP::LRDD\->new_default\fR" 4 .IX Item "HTTP::LRDD->new_default" Create a new \s-1LRDD\s0 discovery object using the default set of predicates ('describedby', 'lrdd', 'wdrs:describedby', 'xhv:meta' and 'rdfs:seeAlso'). .SS "Public Methods" .IX Subsection "Public Methods" .ie n .IP """$lrdd\->discover($resource_uri)""" 4 .el .IP "\f(CW$lrdd\->discover($resource_uri)\fR" 4 .IX Item "$lrdd->discover($resource_uri)" Discovers a descriptor for the given resource; or if called in a list context, a list of descriptors. .Sp A descriptor is a resource that provides a description for something. So, if the given resource \s-1URI\s0 was the web address for an image, then the descriptor might be the web address for a metadata file about the image. If the given \s-1URI\s0 was an e\-mail address, then the descriptor might be a profile document for the person to whom the address belongs. .Sp The following sources are checked (in order) to find links to descriptors. .RS 4 .IP "\(bu" 4 \&\s-1HTTP\s0 response headers (\*(L"Link\*(R" header; \*(L"303 See Other\*(R" status) .IP "\(bu" 4 \&\s-1HTTP\s0 response message (\s-1RDF\s0 or RDFa) .IP "\(bu" 4 https://HOSTNAME/.well\-known/host\-meta .IP "\(bu" 4 http://HOSTNAME/.well\-known/host\-meta .RE .RS 4 .Sp If none of the above is able to yield a link to a descriptor, then the resource \s-1URI\s0 itself may be returned if it is in a self-describing format (e.g. \s-1RDF\s0). .Sp There is no guaranteed file format for the descriptor, but it is usually \s-1RDF, POWDER XML\s0 or \s-1XRD.\s0 .Sp This method can also be called without an object (as a class method) in which case, a temporary object is created automatically using \&\f(CW\*(C`new\*(C'\fR. .RE .ie n .IP """$lrdd\->parse($descriptor_uri)""" 4 .el .IP "\f(CW$lrdd\->parse($descriptor_uri)\fR" 4 .IX Item "$lrdd->parse($descriptor_uri)" Parses a descriptor in \s-1XRD\s0 or \s-1RDF\s0 (\s-1RDF/XML,\s0 RDFa, Turtle, etc). .Sp Returns an RDF::Trine::Model or undef if unable to process. .Sp This method can also be called without an object (as a class method) in which case, a temporary object is created automatically using \&\f(CW\*(C`new\*(C'\fR. .ie n .IP """$lrdd\->process($resource_uri)""" 4 .el .IP "\f(CW$lrdd\->process($resource_uri)\fR" 4 .IX Item "$lrdd->process($resource_uri)" Performs the equivalent of \f(CW\*(C`discover\*(C'\fR and \f(CW\*(C`parse\*(C'\fR in one easy step. .Sp Calls \f(CW\*(C`discover\*(C'\fR in a non-list context, so only the first descriptor is used. .ie n .IP """$lrdd\->process_all($resource_uri)""" 4 .el .IP "\f(CW$lrdd\->process_all($resource_uri)\fR" 4 .IX Item "$lrdd->process_all($resource_uri)" Performs the equivalent of \f(CW\*(C`discover\*(C'\fR and \f(CW\*(C`parse\*(C'\fR in one easy step. .Sp Calls \f(CW\*(C`discover\*(C'\fR in a list context, so multiple descriptors are combined into the resulting graph. .SH "EXAMPLES" .IX Header "EXAMPLES" Discover the hub address (PubSubHubub) for a feed: .PP .Vb 2 \& my $lrdd = HTTP::LRDD\->new(\*(Aqhub\*(Aq); \& my $hub = $lrdd\->discover(\*(Aqhttp://example.net/feed.atom\*(Aq); .Ve .PP Discover an author link (rel=\*(L"author\*(R") from an \s-1HTML\s0 page: .PP .Vb 2 \& my $lrdd = HTTP::LRDD\->new(\*(Aqauthor\*(Aq); \& my $author = $lrdd\->discover(\*(Aqhttp://example.com/page.html\*(Aq); .Ve .PP (For \s-1RDF\s0 people, you should note that rel=\*(L"author\*(R" is not semantically equivalent to the \*(L"foaf:maker\*(R" property but closer to the \&\*(L"foaf:maker/foaf:homepage\*(R" \s-1SPARQL 1.1\s0 property path \- i.e. the rel=\*(L"author\*(R" link destination is not a \s-1URI\s0 for the author themselves, but a page about the author.) .PP If that author resource is in a machine-readable format (e.g. \s-1RDF\s0), then parse the data: .PP .Vb 1 \& my $author_data = $lrdd\->parse($author); .Ve .PP Or, you can combine \f(CW\*(C`discover\*(C'\fR and \f(CW\*(C`parse\*(C'\fR: .PP .Vb 2 \& my $lrdd = HTTP::LRDD\->new(\*(Aqauthor\*(Aq); \& my $author_data = $lrdd\->process(\*(Aqhttp://example.com/page.html\*(Aq); .Ve .PP Get metadata for an image: .PP .Vb 2 \& my $lrdd = HTTP::LRDD\->new; \& my $data = $lrdd\->process_all(\*(Aqhttp://example.org/flower.jpeg\*(Aq); .Ve .PP As we're not passing any arguments to the constructor, we can use a shortcut: .PP .Vb 1 \& my $data = HTTP::LRDD\->process_all(\*(Aqhttp://example.org/flower.jpeg\*(Aq); .Ve .PP Find the title of the image: .PP .Vb 1 \& use RDF::QueryX::Lazy; \& \& my $image = q; \& my $results = RDF::QueryX::Lazy \& \-> new("SELECT * WHERE { <$image> dc:title ?t }") \& \-> execute( HTTP::LRDD\->process_all($image) ); .Ve .SH "BUGS" .IX Header "BUGS" Please report any bugs to . .PP \&\fBNote\fR: many problems can stem from servers that send incorrect \&\f(CW\*(C`Content\-Type\*(C'\fR headers. If you send an \s-1XRD\s0 file as \*(L"text/html\*(R", then this module will not guess what you're doing \- it will assume the file is really \s-1HTML,\s0 and inspect it for RDFa. For host-meta files, this module is slightly more relaxed, as there's a strong assumption that they are \s-1XRD...\s0 but \s-1YOU SHOULD NOT RELY ON THIS.\s0 If you're running a server, use the correct media type. .SH "SEE ALSO" .IX Header "SEE ALSO" HTTP::Link::Parser, XRD::Parser, XML::Atom::OWL WWW::Finger. .PP . .SH "AUTHOR" .IX Header "AUTHOR" Toby Inkster . .SH "COPYRIGHT AND LICENCE" .IX Header "COPYRIGHT AND LICENCE" Copyright 2010\-2012 Toby Inkster .PP This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. .SH "DISCLAIMER OF WARRANTIES" .IX Header "DISCLAIMER OF WARRANTIES" \&\s-1THIS PACKAGE IS PROVIDED \*(L"AS IS\*(R" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.\s0