source: main/trunk/greenstone2/perllib/cpan/Mojo/Cookie/Request.pm@ 32205

Last change on this file since 32205 was 32205, checked in by ak19, 6 years ago

First set of commits to do with implementing the new 'paged_html' output option of PDFPlugin that uses using xpdftools' new pdftohtml. So far tested only on Linux (64 bit), but things work there so I'm optimistically committing the changes since they work. 2. Committing the pre-built Linux binaries of XPDFtools for both 32 and 64 bit built by the XPDF group. 2. To use the correct bitness variant of xpdftools, setup.bash now exports the BITNESS env var, consulted by gsConvert.pl. 3. All the perl code changes to do with using xpdf tools' pdftohtml to generate paged_html and feed it in the desired form into GS(3): gsConvert.pl, PDFPlugin.pm and its parent ConvertBinaryPFile.pm have been modified to make it all work. xpdftools' pdftohtml generates a folder containing an html file and a screenshot for each page in a PDF (as well as an index.html linking to each page's html). However, we want a single html file that contains each individual 'page' html's content in a div, and need to do some further HTML style, attribute and structure modifications to massage the xpdftool output to what we want for GS. In order to parse and manipulate the HTML 'DOM' to do this, we're using the Mojo::DOM package that Dr Bainbridge found and which he's compiled up. Mojo::DOM is therefore also committed in this revision. Some further changes and some display fixes are required, but need to check with the others about that.

File size: 1.4 KB
Line 
1package Mojo::Cookie::Request;
2use Mojo::Base 'Mojo::Cookie';
3
4use Mojo::Util qw(quote split_header);
5
6sub parse {
7 my ($self, $str) = @_;
8
9 my @cookies;
10 my @pairs = map {@$_} @{split_header $str // ''};
11 while (my ($name, $value) = splice @pairs, 0, 2) {
12 next if $name =~ /^\$/;
13 push @cookies, $self->new(name => $name, value => $value // '');
14 }
15
16 return \@cookies;
17}
18
19sub to_string {
20 my $self = shift;
21 return '' unless length(my $name = $self->name // '');
22 my $value = $self->value // '';
23 return join '=', $name, $value =~ /[,;" ]/ ? quote $value : $value;
24}
25
261;
27
28=encoding utf8
29
30=head1 NAME
31
32Mojo::Cookie::Request - HTTP request cookie
33
34=head1 SYNOPSIS
35
36 use Mojo::Cookie::Request;
37
38 my $cookie = Mojo::Cookie::Request->new;
39 $cookie->name('foo');
40 $cookie->value('bar');
41 say "$cookie";
42
43=head1 DESCRIPTION
44
45L<Mojo::Cookie::Request> is a container for HTTP request cookies, based on
46L<RFC 6265|http://tools.ietf.org/html/rfc6265>.
47
48=head1 ATTRIBUTES
49
50L<Mojo::Cookie::Request> inherits all attributes from L<Mojo::Cookie>.
51
52=head1 METHODS
53
54L<Mojo::Cookie::Request> inherits all methods from L<Mojo::Cookie> and
55implements the following new ones.
56
57=head2 parse
58
59 my $cookies = Mojo::Cookie::Request->parse('f=b; g=a');
60
61Parse cookies.
62
63=head2 to_string
64
65 my $str = $cookie->to_string;
66
67Render cookie.
68
69=head1 SEE ALSO
70
71L<Mojolicious>, L<Mojolicious::Guides>, L<https://mojolicious.org>.
72
73=cut
Note: See TracBrowser for help on using the repository browser.