… | |
… | |
18 | This module is alpha. While it probably won't destroy (much :) of your |
18 | This module is alpha. While it probably won't destroy (much :) of your |
19 | data, it currently works only with the Event module (alkthough the event |
19 | data, it currently works only with the Event module (alkthough the event |
20 | mechanism is fully pluggable). |
20 | mechanism is fully pluggable). |
21 | |
21 | |
22 | THE Net::FCP CLASS |
22 | THE Net::FCP CLASS |
|
|
23 | $meta = Net::FCP::parse_metadata $string |
|
|
24 | Parse a metadata string and return it. |
|
|
25 | |
|
|
26 | The metadata will be a hashref with key "version" (containing the |
|
|
27 | mandatory version header entries). |
|
|
28 | |
|
|
29 | All other headers are represented by arrayrefs (they can be |
|
|
30 | repeated). |
|
|
31 | |
|
|
32 | Since this is confusing, here is a rather verbose example of a |
|
|
33 | parsed manifest: |
|
|
34 | |
|
|
35 | ( |
|
|
36 | version => { revision => 1 }, |
|
|
37 | document => [ |
|
|
38 | { |
|
|
39 | "info.format" => "image/jpeg", |
|
|
40 | name => "background.jpg", |
|
|
41 | "redirect.target" => "freenet:CHK\@ZcagI,ra726bSw" |
|
|
42 | }, |
|
|
43 | { |
|
|
44 | "info.format" => "text/html", |
|
|
45 | name => ".next", |
|
|
46 | "redirect.target" => "freenet:SSK\@ilUPAgM/TFEE/3" |
|
|
47 | }, |
|
|
48 | { |
|
|
49 | "info.format" => "text/html", |
|
|
50 | "redirect.target" => "freenet:CHK\@8M8Po8ucwI,8xA" |
|
|
51 | } |
|
|
52 | ] |
|
|
53 | ) |
|
|
54 | |
23 | $fcp = new Net::FCP [host => $host][, port => $port] |
55 | $fcp = new Net::FCP [host => $host][, port => $port] |
24 | Create a new virtual FCP connection to the given host and port |
56 | Create a new virtual FCP connection to the given host and port |
25 | (default 127.0.0.1:8481, or the environment variables "FREDHOST" and |
57 | (default 127.0.0.1:8481, or the environment variables "FREDHOST" and |
26 | "FREDPORT"). |
58 | "FREDPORT"). |
27 | |
59 | |
… | |
… | |
99 | of the given document. |
131 | of the given document. |
100 | |
132 | |
101 | UNTESTED. |
133 | UNTESTED. |
102 | |
134 | |
103 | $txn = $fcp->txn_client_get ($uri [, $htl = 15 [, $removelocal = 0]]) |
135 | $txn = $fcp->txn_client_get ($uri [, $htl = 15 [, $removelocal = 0]]) |
104 | ($data, $metadata) = @{ $fcp->client_get ($uri, $htl, $removelocal) |
136 | ($metadata, $data) = @{ $fcp->client_get ($uri, $htl, $removelocal) |
105 | Fetches a (small, as it should fit into memory) file from freenet. |
137 | Fetches a (small, as it should fit into memory) file from freenet. |
|
|
138 | $meta is the metadata (as returned by "parse_metadata" or "undef"). |
106 | |
139 | |
107 | Due to the overhead, a better method to download big fiels should be |
140 | Due to the overhead, a better method to download big files should be |
108 | used. |
141 | used. |
109 | |
142 | |
110 | my ($data, $meta) = @{ |
143 | my ($meta, $data) = @{ |
111 | $fcp->client_get ( |
144 | $fcp->client_get ( |
112 | "freenet:CHK@hdXaxkwZ9rA8-SidT0AN-bniQlgPAwI,XdCDmBuGsd-ulqbLnZ8v~w" |
145 | "freenet:CHK@hdXaxkwZ9rA8-SidT0AN-bniQlgPAwI,XdCDmBuGsd-ulqbLnZ8v~w" |
113 | ) |
146 | ) |
114 | }; |
147 | }; |
115 | |
148 | |