.\" Automatically generated by Pod::Man 4.07 (Pod::Simple 3.32) .\" .\" 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 .. .if !\nF .nr F 0 .if \nF>0 \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} .\} .\" ======================================================================== .\" .IX Title "RDF::Generator::HTTP 3pm" .TH RDF::Generator::HTTP 3pm "2017-06-24" "perl v5.24.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" RDF::Generator::HTTP \- Generate RDF from a HTTP message .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 3 \& use LWP::UserAgent; \& my $ua = LWP::UserAgent\->new; \& my $response = $ua\->get(\*(Aqhttp://search.cpan.org/\*(Aq); \& \& use RDF::Generator::HTTP; \& use RDF::Trine qw(iri); \& my $g = RDF::Generator::HTTP\->new(message => $response, \& graph => iri(\*(Aqhttp://example.org/graphname\*(Aq), \& blacklist => [\*(AqLast\-Modified\*(Aq, \*(AqAccept\*(Aq]); \& my $model = $g\->generate; \& print $model\->size; \& my $s = RDF::Trine::Serializer\->new(\*(Aqturtle\*(Aq, namespaces => \& { httph => \*(Aqhttp://www.w3.org/2007/ont/httph#\*(Aq, \& http => \*(Aqhttp://www.w3.org/2007/ont/http#\*(Aq } ); \& $s\->serialize_model_to_file(\e*STDOUT, $model); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" This module simply takes a HTTP::Message object, and based on its content, especially the content the HTTP::Header object(s) it contains, creates a simple \s-1RDF\s0 representation of the contents. It is useful chiefly for recording data when crawling resources on the Web, but it may also have other uses. .SS "Constructor" .IX Subsection "Constructor" .ie n .IP """new(%attributes)""" 4 .el .IP "\f(CWnew(%attributes)\fR" 4 .IX Item "new(%attributes)" Moose-style constructor function. .SS "Attributes" .IX Subsection "Attributes" These attributes may be passed to the constructor to set them, or called like methods to get them. .ie n .IP """message""" 4 .el .IP "\f(CWmessage\fR" 4 .IX Item "message" A HTTP::Message (or subclass thereof) object to generate \s-1RDF\s0 for. Required. .ie n .IP """blacklist""" 4 .el .IP "\f(CWblacklist\fR" 4 .IX Item "blacklist" An \f(CW\*(C`ArrayRef\*(C'\fR of header field names that you do not want to see in the output. .ie n .IP """whitelist""" 4 .el .IP "\f(CWwhitelist\fR" 4 .IX Item "whitelist" An \f(CW\*(C`ArrayRef\*(C'\fR of the only header field names that you want to see in the output. The whitelist will be ignored if the blacklist is set. .ie n .IP """graph""" 4 .el .IP "\f(CWgraph\fR" 4 .IX Item "graph" You may pass an optional graph name to be used for all triples in the output. This must be an object of RDF::Trine::Node::Resource. .ie n .IP """ns""" 4 .el .IP "\f(CWns\fR" 4 .IX Item "ns" An URI::NamespaceMap object containing namespace prefixes used in the module. You should probably not override this even though you can. .ie n .IP """request_subject""" 4 .el .IP "\f(CWrequest_subject\fR" 4 .IX Item "request_subject" An RDF::Trine::Node object containing the subject of any statements describing requests. If unset, it will default to a blank node. .ie n .IP """response_subject""" 4 .el .IP "\f(CWresponse_subject\fR" 4 .IX Item "response_subject" An RDF::Trine::Node object containing the subject of any statements describing responses. If unset, it will default to a blank node. .SS "Methods" .IX Subsection "Methods" The above attributes all have read-accessors by the same name. \f(CW\*(C`blacklist\*(C'\fR, \f(CW\*(C`whitelist\*(C'\fR and \f(CW\*(C`graph\*(C'\fR also has writers and predicates, which is used to test if the attribute has been set, by prefixing \f(CW\*(C`has_\*(C'\fR to the attribute name. .PP This class has two methods: .ie n .IP """generate ( [ $model ] )""" 4 .el .IP "\f(CWgenerate ( [ $model ] )\fR" 4 .IX Item "generate ( [ $model ] )" This method will generate the \s-1RDF.\s0 It may optionally take an RDF::Trine::Model as parameter. If it exists, the \s-1RDF\s0 will be added to this model, if not, a new Memory model will be created and returned. .ie n .IP """ok_to_add ( $field )""" 4 .el .IP "\f(CWok_to_add ( $field )\fR" 4 .IX Item "ok_to_add ( $field )" This method will look up in the blacklists and whitelists and return true if the given field and value may be added to the model. .SH "EXAMPLES" .IX Header "EXAMPLES" For an example of what the module can be used to create, consider the example in the \*(L"\s-1SYNOPSIS\*(R"\s0, which at the time of this writing outputs the following Turtle: .PP .Vb 2 \& @prefix http: . \& @prefix httph: . \& \& [] a http:RequestMessage ; \& http:hasResponse [ \& a http:ResponseMessage ; \& http:status "200" ; \& httph:client_date "Sun, 14 Dec 2014 21:28:21 GMT" ; \& httph:client_peer "207.171.7.59:80" ; \& httph:client_response_num "1" ; \& httph:connection "close" ; \& httph:content_length "3643" ; \& httph:content_type "text/html" ; \& httph:date "Sun, 14 Dec 2014 21:28:21 GMT" ; \& httph:link "; rel=\e"alternate\e"; title=\e"RSS 1.0\e"; type=\e"application/rss+xml\e"", "; rel=\e"search\e"; title=\e"SearchCPAN\e"; type=\e"application/opensearchdescription+xml\e"", "; media=\e"print\e"; rel=\e"stylesheet\e"; type=\e"text/css\e"", "; rel=\e"stylesheet\e"; type=\e"text/css\e"" ; \& httph:server "Plack/Starman (Perl)" ; \& httph:title "The CPAN Search Site \- search.cpan.org" ; \& httph:x_proxy "proxy2" \& ] ; \& http:method "GET" ; \& http:requestURI ; \& httph:user_agent "libwww\-perl/6.05" . .Ve .SH "NOTES" .IX Header "NOTES" .SS "\s-1HTTP\s0 Vocabularies" .IX Subsection "HTTP Vocabularies" There have been many efforts to create \s-1HTTP\s0 vocabularies (or ontologies), where the most elaborate and complete is the \&\s-1HTTP\s0 Vocabulary in \s-1RDF 1.0\s0 . Nevertheless, I decided not to support this, but rather support an older and much less complete vocabulary that has been in the Tabulator project, with the namespace prefixes and . The problem of modelling \s-1HTTP \s0 is that headers modify each other, so if you want to record the \s-1HTTP \s0 headers so that they can be used in an actual \s-1HTTP\s0 dialogue afterwards, they have to be in a container so that the order can be reconstructed. Moreover, there is a lot of microstructure in the values, and that also adds complexity if you want to translate all that to \s-1RDF.\s0 That's what the former vocabulary does. However, for now, all the author wants to do is to record them, and then neither of these concerns are important. Therefore, I opted to go for a much simpler vocabulary, where each field is a simple predicate. That is not to say that the former approach isn't valid, it is just not something I need now. .SH "BUGS" .IX Header "BUGS" This is a very early release, but it works for the author. .PP Please report any bugs to . .SH "AUTHOR" .IX Header "AUTHOR" Kjetil Kjernsmo . .SH "COPYRIGHT AND LICENCE" .IX Header "COPYRIGHT AND LICENCE" This software is copyright (c) 2014 by Kjetil Kjernsmo. .PP This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system 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