HTTP-Message-6.11/ 000755 000766 000024 00000000000 12574114206 014057 5 ustar 00ether staff 000000 000000 HTTP-Message-6.11/Changes 000644 000766 000024 00000007052 12574114142 015355 0 ustar 00ether staff 000000 000000 Revision history for HTTP-Message
6.11 2015-09-09
- fix an undefined value warning in HTTP::Headers::as_string
6.10 2015-07-19
- fix uses of qr/.../m in tests that do not work in 5.8.x
6.09 2015-07-19
- converted all uses of Test.pm to Test::More
- fix uninitialized warning in HTTP::Config (RT#105929)
6.08 2015-07-10
- Resolve new uninitialized warning from
HTTP::Request::Common::request_type_with_data (RT#105787)
6.07 2015-07-09
- Allow subclasses to override the class of parts - it used to be
hardcoded to HTTP::Message. (Gisle Aas, RT#79239)
- Added support for is_client_error, is_server_error to HTTP::Response
(Karen Etheridge)
- Added flatten interface to HTTP::Headers (Tokuhiro Matsuno, GH#5)
- Allow PUT to pass content data via hashrefs just like with POST (Michael
Schilli, GH#9)
- Fix for "Content-Encoding: none" header (Gisle Aas, RT#94882)
- Add support for HTTP status 308, defined in RFC 7238 (Olivier Mengué,
RT#104102)
- drop the use of "use vars" (Karen Etheridge)
_______________________________________________________________________________
2012-10-21 HTTP-Message 6.06
Gisle Aas (2):
More forgiving test on croak message [RT#80302]
Added test for multipart parsing
Mark Overmeer (1):
Multipart end boundary doesn't need match a complete line [RT#79239]
_______________________________________________________________________________
2012-10-20 HTTP-Message 6.05
Gisle Aas (5):
Updated ignores
No need to prevent visiting field values starting with '_'
Report the correct croak caller for delegated methods
Disallow empty field names or field names containing ':'
Make the extra std_case entries local to each header
_______________________________________________________________________________
2012-09-30 HTTP-Message 6.04
Gisle Aas (5):
Updated repository URL
Avoid undef warning for empty content
Teach $m->content_charset about JSON
Use the canonical charset name for UTF-16LE (and frieds)
Add option to override the "(no content)" marker of $m->dump
Christopher J. Madsen (2):
Use IO::HTML for encoding sniffing
mime_name was introduced in Encode 2.21
Tom Hukins (1):
Remove an unneeded "require"
Ville Skyttä (1):
Spelling fixes.
chromatic (1):
Sanitized PERL_HTTP_URI_CLASS environment variable.
Martin H. Sluka (1):
Add test from RT#77466
Father Chrysostomos (1):
Fix doc grammo [RT#75831]
_______________________________________________________________________________
2012-02-16 HTTP-Message 6.03
Support 'bzip2' as alternative to Content-Encoding: x-bzip2. Some
servers seem to return it.
Make newlines in forms be "\r\n" terminated.
Added some more status codes.
Restore perl-5.8.1 compatibility.
_______________________________________________________________________________
2011-03-20 HTTP-Message 6.02
Declare dependency on Bunzip2 v2.021 [RT#66593]
_______________________________________________________________________________
2011-03-07 HTTP-Message 6.01
Avoid loading XML::Simple to avoid test failures.
Eliminate the HTML::Entities dependency.
_______________________________________________________________________________
2011-02-27 HTTP-Message 6.00
Initial release of HTTP-Message as a separate distribution. There are no code
changes besides incrementing the version number since libwww-perl-5.837.
The HTTP::Message module with friends used to be bundled with the libwww-perl
distribution.
HTTP-Message-6.11/LICENSE 000644 000766 000024 00000043644 12547327271 015107 0 ustar 00ether staff 000000 000000 This software is copyright (c) 1994 by Gisle Aas.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
Terms of the Perl programming language system itself
a) the GNU General Public License as published by the Free
Software Foundation; either version 1, or (at your option) any
later version, or
b) the "Artistic License"
--- The GNU General Public License, Version 1, February 1989 ---
This software is Copyright (c) 1994 by Gisle Aas.
This is free software, licensed under:
The GNU General Public License, Version 1, February 1989
GNU GENERAL PUBLIC LICENSE
Version 1, February 1989
Copyright (C) 1989 Free Software Foundation, Inc.
51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The license agreements of most software companies try to keep users
at the mercy of those companies. By contrast, our General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. The
General Public License applies to the Free Software Foundation's
software and to any other program whose authors commit to using it.
You can use it for your programs, too.
When we speak of free software, we are referring to freedom, not
price. Specifically, the General Public License is designed to make
sure that you have the freedom to give away or sell copies of free
software, that you receive source code or can get it if you want it,
that you can change the software or use pieces of it in new free
programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of a such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must tell them their rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License Agreement applies to any program or other work which
contains a notice placed by the copyright holder saying it may be
distributed under the terms of this General Public License. The
"Program", below, refers to any such program or work, and a "work based
on the Program" means either the Program or any work containing the
Program or a portion of it, either verbatim or with modifications. Each
licensee is addressed as "you".
1. You may copy and distribute verbatim copies of the Program's source
code as you receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice and
disclaimer of warranty; keep intact all the notices that refer to this
General Public License and to the absence of any warranty; and give any
other recipients of the Program a copy of this General Public License
along with the Program. You may charge a fee for the physical act of
transferring a copy.
2. You may modify your copy or copies of the Program or any portion of
it, and copy and distribute such modifications under the terms of Paragraph
1 above, provided that you also do the following:
a) cause the modified files to carry prominent notices stating that
you changed the files and the date of any change; and
b) cause the whole of any work that you distribute or publish, that
in whole or in part contains the Program or any part thereof, either
with or without modifications, to be licensed at no charge to all
third parties under the terms of this General Public License (except
that you may choose to grant warranty protection to some or all
third parties, at your option).
c) If the modified program normally reads commands interactively when
run, you must cause it, when started running for such interactive use
in the simplest and most usual way, to print or display an
announcement including an appropriate copyright notice and a notice
that there is no warranty (or else, saying that you provide a
warranty) and that users may redistribute the program under these
conditions, and telling the user how to view a copy of this General
Public License.
d) You may charge a fee for the physical act of transferring a
copy, and you may at your option offer warranty protection in
exchange for a fee.
Mere aggregation of another independent work with the Program (or its
derivative) on a volume of a storage or distribution medium does not bring
the other work under the scope of these terms.
3. You may copy and distribute the Program (or a portion or derivative of
it, under Paragraph 2) in object code or executable form under the terms of
Paragraphs 1 and 2 above provided that you also do one of the following:
a) accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of
Paragraphs 1 and 2 above; or,
b) accompany it with a written offer, valid for at least three
years, to give any third party free (except for a nominal charge
for the cost of distribution) a complete machine-readable copy of the
corresponding source code, to be distributed under the terms of
Paragraphs 1 and 2 above; or,
c) accompany it with the information you received as to where the
corresponding source code may be obtained. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form alone.)
Source code for a work means the preferred form of the work for making
modifications to it. For an executable file, complete source code means
all the source code for all modules it contains; but, as a special
exception, it need not include source code for modules which are standard
libraries that accompany the operating system on which the executable
file runs, or for standard header files or definitions files that
accompany that operating system.
4. You may not copy, modify, sublicense, distribute or transfer the
Program except as expressly provided under this General Public License.
Any attempt otherwise to copy, modify, sublicense, distribute or transfer
the Program is void, and will automatically terminate your rights to use
the Program under this License. However, parties who have received
copies, or rights to use copies, from you under this General Public
License will not have their licenses terminated so long as such parties
remain in full compliance.
5. By copying, distributing or modifying the Program (or any work based
on the Program) you indicate your acceptance of this license to do so,
and all its terms and conditions.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the original
licensor to copy, distribute or modify the Program subject to these
terms and conditions. You may not impose any further restrictions on the
recipients' exercise of the rights granted herein.
7. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of the license which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
the license, you may choose any version ever published by the Free Software
Foundation.
8. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
9. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
10. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
Appendix: How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to humanity, the best way to achieve this is to make it
free software which everyone can redistribute and change under these
terms.
To do so, attach the following notices to the program. It is safest to
attach them to the start of each source file to most effectively convey
the exclusion of warranty; and each file should have at least the
"copyright" line and a pointer to where the full notice is found.
Copyright (C) 19yy
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 1, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) 19xx name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the
appropriate parts of the General Public License. Of course, the
commands you use may be called something other than `show w' and `show
c'; they could even be mouse-clicks or menu items--whatever suits your
program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the
program `Gnomovision' (a program to direct compilers to make passes
at assemblers) written by James Hacker.
, 1 April 1989
Ty Coon, President of Vice
That's all there is to it!
--- The Artistic License 1.0 ---
This software is Copyright (c) 1994 by Gisle Aas.
This is free software, licensed under:
The Artistic License 1.0
The Artistic License
Preamble
The intent of this document is to state the conditions under which a Package
may be copied, such that the Copyright Holder maintains some semblance of
artistic control over the development of the package, while giving the users of
the package the right to use and distribute the Package in a more-or-less
customary fashion, plus the right to make reasonable modifications.
Definitions:
- "Package" refers to the collection of files distributed by the Copyright
Holder, and derivatives of that collection of files created through
textual modification.
- "Standard Version" refers to such a Package if it has not been modified,
or has been modified in accordance with the wishes of the Copyright
Holder.
- "Copyright Holder" is whoever is named in the copyright or copyrights for
the package.
- "You" is you, if you're thinking about copying or distributing this Package.
- "Reasonable copying fee" is whatever you can justify on the basis of media
cost, duplication charges, time of people involved, and so on. (You will
not be required to justify it to the Copyright Holder, but only to the
computing community at large as a market that must bear the fee.)
- "Freely Available" means that no fee is charged for the item itself, though
there may be fees involved in handling the item. It also means that
recipients of the item may redistribute it under the same conditions they
received it.
1. You may make and give away verbatim copies of the source form of the
Standard Version of this Package without restriction, provided that you
duplicate all of the original copyright notices and associated disclaimers.
2. You may apply bug fixes, portability fixes and other modifications derived
from the Public Domain or from the Copyright Holder. A Package modified in such
a way shall still be considered the Standard Version.
3. You may otherwise modify your copy of this Package in any way, provided that
you insert a prominent notice in each changed file stating how and when you
changed that file, and provided that you do at least ONE of the following:
a) place your modifications in the Public Domain or otherwise make them
Freely Available, such as by posting said modifications to Usenet or an
equivalent medium, or placing the modifications on a major archive site
such as ftp.uu.net, or by allowing the Copyright Holder to include your
modifications in the Standard Version of the Package.
b) use the modified Package only within your corporation or organization.
c) rename any non-standard executables so the names do not conflict with
standard executables, which must also be provided, and provide a separate
manual page for each non-standard executable that clearly documents how it
differs from the Standard Version.
d) make other distribution arrangements with the Copyright Holder.
4. You may distribute the programs of this Package in object code or executable
form, provided that you do at least ONE of the following:
a) distribute a Standard Version of the executables and library files,
together with instructions (in the manual page or equivalent) on where to
get the Standard Version.
b) accompany the distribution with the machine-readable source of the Package
with your modifications.
c) accompany any non-standard executables with their corresponding Standard
Version executables, giving the non-standard executables non-standard
names, and clearly documenting the differences in manual pages (or
equivalent), together with instructions on where to get the Standard
Version.
d) make other distribution arrangements with the Copyright Holder.
5. You may charge a reasonable copying fee for any distribution of this
Package. You may charge any fee you choose for support of this Package. You
may not charge a fee for this Package itself. However, you may distribute this
Package in aggregate with other (possibly commercial) programs as part of a
larger (possibly commercial) software distribution provided that you do not
advertise this Package as a product of your own.
6. The scripts and library files supplied as input to or produced as output
from the programs of this Package do not automatically fall under the copyright
of this Package, but belong to whomever generated them, and may be sold
commercially, and may be aggregated with this Package.
7. C or perl subroutines supplied by you and linked into this Package shall not
be considered part of this Package.
8. The name of the Copyright Holder may not be used to endorse or promote
products derived from this software without specific prior written permission.
9. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
The End
HTTP-Message-6.11/MANIFEST 000644 000766 000024 00000001352 12574114206 015211 0 ustar 00ether staff 000000 000000 Changes
lib/HTTP/Config.pm
lib/HTTP/Headers.pm
lib/HTTP/Headers/Auth.pm
lib/HTTP/Headers/ETag.pm
lib/HTTP/Headers/Util.pm
lib/HTTP/Message.pm
lib/HTTP/Request.pm
lib/HTTP/Request/Common.pm
lib/HTTP/Response.pm
lib/HTTP/Status.pm
LICENSE
Makefile.PL
MANIFEST This list of files
MANIFEST.SKIP
README
t/common-req.t
t/distmanifest.t
t/headers-auth.t
t/headers-etag.t
t/headers-util.t
t/headers.t
t/http-config.t
t/message-charset.t
t/message-decode-xml.t
t/message-old.t
t/message-parts.t
t/message.t
t/request.t
t/request_type_with_data.t
t/response.t
t/status-old.t
t/status.t
META.yml Module YAML meta-data (added by MakeMaker)
META.json Module JSON meta-data (added by MakeMaker)
HTTP-Message-6.11/MANIFEST.SKIP 000644 000766 000024 00000002335 12574114116 015760 0 ustar 00ether staff 000000 000000
#!start included /Volumes/amaretto/Users/ether/perl5/perlbrew/perls/23.2/lib/5.23.2/ExtUtils/MANIFEST.SKIP
# Avoid version control files.
\bRCS\b
\bCVS\b
\bSCCS\b
,v$
\B\.svn\b
\B\.git\b
\B\.gitignore\b
\b_darcs\b
\B\.cvsignore$
# Avoid VMS specific MakeMaker generated files
\bDescrip.MMS$
\bDESCRIP.MMS$
\bdescrip.mms$
# Avoid Makemaker generated and utility files.
\bMANIFEST\.bak
\bMakefile$
\bblib/
\bMakeMaker-\d
\bpm_to_blib\.ts$
\bpm_to_blib$
\bblibdirs\.ts$ # 6.18 through 6.25 generated this
\b_eumm/ # 7.05_05 and above
# Avoid Module::Build generated and utility files.
\bBuild$
\b_build/
\bBuild.bat$
\bBuild.COM$
\bBUILD.COM$
\bbuild.com$
# and Module::Build::Tiny generated files
\b_build_params$
# Avoid temp and backup files.
~$
\.old$
\#$
\b\.#
\.bak$
\.tmp$
\.#
\.rej$
\..*\.sw.?$
# Avoid OS-specific files/dirs
# Mac OSX metadata
\B\.DS_Store
# Mac OSX SMB mount metadata files
\B\._
# Avoid Devel::Cover and Devel::CoverX::Covered files.
\bcover_db\b
\bcovered\b
# Avoid prove files
\B\.prove$
# Avoid MYMETA files
^MYMETA\.
#!end included /Volumes/amaretto/Users/ether/perl5/perlbrew/perls/23.2/lib/5.23.2/ExtUtils/MANIFEST.SKIP
^HTTP-Message-.*/
^HTTP-Message-.*.tar.gz
^\.ackrc$
^test-
HTTP-Message-6.11/META.json 000644 000766 000024 00000004144 12574114206 015503 0 ustar 00ether staff 000000 000000 {
"abstract" : "HTTP style messages",
"author" : [
"Gisle Aas "
],
"dynamic_config" : 0,
"generated_by" : "ExtUtils::MakeMaker version 7.08, CPAN::Meta::Converter version 2.150005",
"license" : [
"perl_5"
],
"meta-spec" : {
"url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec",
"version" : "2"
},
"name" : "HTTP-Message",
"no_index" : {
"directory" : [
"t",
"inc"
]
},
"prereqs" : {
"build" : {
"requires" : {
"ExtUtils::MakeMaker" : "0"
}
},
"configure" : {
"requires" : {
"ExtUtils::MakeMaker" : "0"
}
},
"runtime" : {
"requires" : {
"Compress::Raw::Zlib" : "0",
"Encode" : "2.21",
"Encode::Locale" : "1",
"Exporter" : "5.57",
"HTTP::Date" : "6",
"IO::Compress::Bzip2" : "2.021",
"IO::Compress::Deflate" : "0",
"IO::Compress::Gzip" : "0",
"IO::HTML" : "0",
"IO::Uncompress::Bunzip2" : "2.021",
"IO::Uncompress::Gunzip" : "0",
"IO::Uncompress::Inflate" : "0",
"IO::Uncompress::RawInflate" : "0",
"LWP::MediaTypes" : "6",
"MIME::Base64" : "2.1",
"MIME::QuotedPrint" : "0",
"URI" : "1.10",
"perl" : "5.008001"
}
},
"test" : {
"requires" : {
"Test::More" : "0"
}
}
},
"release_status" : "stable",
"resources" : {
"bugtracker" : {
"mailto" : "bug-HTTP-Message@rt.cpan.org",
"web" : "https://rt.cpan.org/Public/Dist/Display.html?Name=HTTP-Message"
},
"repository" : {
"type" : "git",
"url" : "https://github.com/libwww-perl/HTTP-Message.git",
"web" : "https://github.com/libwww-perl/HTTP-Message"
},
"x_IRC" : "irc://irc.perl.org/#lwp",
"x_MailingList" : "mailto:libwww@perl.org"
},
"version" : "6.11",
"x_serialization_backend" : "JSON::PP version 2.27300"
}
HTTP-Message-6.11/META.yml 000644 000766 000024 00000002265 12574114205 015334 0 ustar 00ether staff 000000 000000 ---
abstract: 'HTTP style messages'
author:
- 'Gisle Aas '
build_requires:
ExtUtils::MakeMaker: '0'
Test::More: '0'
configure_requires:
ExtUtils::MakeMaker: '0'
dynamic_config: 0
generated_by: 'ExtUtils::MakeMaker version 7.08, CPAN::Meta::Converter version 2.150005'
license: perl
meta-spec:
url: http://module-build.sourceforge.net/META-spec-v1.4.html
version: '1.4'
name: HTTP-Message
no_index:
directory:
- t
- inc
requires:
Compress::Raw::Zlib: '0'
Encode: '2.21'
Encode::Locale: '1'
Exporter: '5.57'
HTTP::Date: '6'
IO::Compress::Bzip2: '2.021'
IO::Compress::Deflate: '0'
IO::Compress::Gzip: '0'
IO::HTML: '0'
IO::Uncompress::Bunzip2: '2.021'
IO::Uncompress::Gunzip: '0'
IO::Uncompress::Inflate: '0'
IO::Uncompress::RawInflate: '0'
LWP::MediaTypes: '6'
MIME::Base64: '2.1'
MIME::QuotedPrint: '0'
URI: '1.10'
perl: '5.008001'
resources:
IRC: irc://irc.perl.org/#lwp
MailingList: mailto:libwww@perl.org
bugtracker: https://rt.cpan.org/Public/Dist/Display.html?Name=HTTP-Message
repository: https://github.com/libwww-perl/HTTP-Message.git
version: '6.11'
x_serialization_backend: 'CPAN::Meta::YAML version 0.017'
HTTP-Message-6.11/Makefile.PL 000644 000766 000024 00000005217 12574113633 016041 0 ustar 00ether staff 000000 000000 require 5.008001;
use strict;
use warnings;
use ExtUtils::MakeMaker;
my %WriteMakefileArgs = (
NAME => 'HTTP::Message',
VERSION_FROM => 'lib/HTTP/Message.pm',
ABSTRACT => 'HTTP style messages',
AUTHOR => 'Gisle Aas ',
LICENSE => 'perl_5',
MIN_PERL_VERSION => 5.008001,
PREREQ_PM => {
'URI' => "1.10",
'HTTP::Date' => 6,
'MIME::Base64' => "2.1",
'MIME::QuotedPrint' => 0,
'IO::HTML' => 0,
'Encode' => "2.21", # need mime_name
'Encode::Locale' => 1,
'LWP::MediaTypes' => 6,
'Compress::Raw::Zlib' => 0,
'IO::Compress::Gzip' => 0,
'IO::Compress::Deflate' => 0,
'IO::Compress::Bzip2' => '2.021',
'IO::Uncompress::Gunzip' => 0,
'IO::Uncompress::Inflate' => 0,
'IO::Uncompress::RawInflate' => 0,
'IO::Uncompress::Bunzip2' => '2.021',
'Exporter' => '5.57',
},
TEST_REQUIRES => {
'Test::More' => '0',
},
META_MERGE => {
'meta-spec' => { version => 2 },
dynamic_config => 0,
resources => {
repository => {
url => 'https://github.com/libwww-perl/HTTP-Message.git',
web => 'https://github.com/libwww-perl/HTTP-Message',
type => 'git',
},
bugtracker => {
mailto => 'bug-HTTP-Message@rt.cpan.org',
web => 'https://rt.cpan.org/Public/Dist/Display.html?Name=HTTP-Message',
},
x_MailingList => 'mailto:libwww@perl.org',
x_IRC => 'irc://irc.perl.org/#lwp',
},
},
);
# compatibility with older versions of MakeMaker
my $developer = -f ".gitignore";
die 'need to do a merge with CPAN::Meta::Requirements!!'
if $developer && exists $WriteMakefileArgs{BUILD_REQUIRES};
if (!eval { ExtUtils::MakeMaker->VERSION('6.6303') }) {
$WriteMakefileArgs{BUILD_REQUIRES} = $WriteMakefileArgs{TEST_REQUIRES};
delete $WriteMakefileArgs{TEST_REQUIRES};
}
if (!eval { ExtUtils::MakeMaker->VERSION('6.5501') }) {
@{$WriteMakefileArgs{PREREQ_PM}}{ keys %{$WriteMakefileArgs{BUILD_REQUIRES}} } =
@{$WriteMakefileArgs{BUILD_REQUIRES}}{ keys %{$WriteMakefileArgs{BUILD_REQUIRES}} };
delete $WriteMakefileArgs{BUILD_REQUIRES};
}
my %mm_req = (
LICENCE => 6.31,
META_MERGE => 6.45,
META_ADD => 6.45,
MIN_PERL_VERSION => 6.48,
);
for (keys %mm_req) {
unless (eval { ExtUtils::MakeMaker->VERSION($mm_req{$_}) }) {
warn "$_ $@" if $developer;
delete $WriteMakefileArgs{$_};
}
}
WriteMakefile(%WriteMakefileArgs);
HTTP-Message-6.11/README 000644 000766 000024 00000001737 12547241745 014760 0 ustar 00ether staff 000000 000000 The HTTP-Message distribution contains classes useful for representing the
messages passed in HTTP style communication. These are classes representing
requests, responses and the headers contained within them.
The following classes are provided:
HTTP::Message base class (what's common between requests and responses)
- HTTP::Request request on a resource (subclass of message)
- HTTP::Response response from the resource (subclass of message)
HTTP::Headers headers embedded in messages
Other related modules:
HTTP::Config configuration of request/response handling
HTTP::Headers::Util helper functions for parsing of HTTP header values
HTTP::Request::Common helper functions for constructing requests
HTTP::Status symbolic names for the HTTP response status codes
This library is free software; you can redistribute it and/or modify it under
the same terms as Perl itself.
Copyright 1995-2008 Gisle Aas.
HTTP-Message-6.11/lib/ 000755 000766 000024 00000000000 12574114205 014624 5 ustar 00ether staff 000000 000000 HTTP-Message-6.11/t/ 000755 000766 000024 00000000000 12574114205 014321 5 ustar 00ether staff 000000 000000 HTTP-Message-6.11/t/common-req.t 000644 000766 000024 00000014061 12552761200 016564 0 ustar 00ether staff 000000 000000 use strict;
use warnings;
use Test::More;
plan tests => 59;
use HTTP::Request::Common;
my $r = GET 'http://www.sn.no/';
note $r->as_string;
is($r->method, "GET");
is($r->uri, "http://www.sn.no/");
$r = HEAD "http://www.sn.no/",
If_Match => 'abc',
From => 'aas@sn.no';
note $r->as_string;
is($r->method, "HEAD");
ok($r->uri->eq("http://www.sn.no"));
is($r->header('If-Match'), "abc");
is($r->header("from"), "aas\@sn.no");
$r = PUT "http://www.sn.no",
Content => 'foo';
note $r->as_string, "\n";
is($r->method, "PUT");
is($r->uri->host, "www.sn.no");
ok(!defined($r->header("Content")));
is(${$r->content_ref}, "foo");
is($r->content, "foo");
is($r->content_length, 3);
$r = PUT "http://www.sn.no",
{ foo => "bar" };
is($r->content, "foo=bar");
#--- Test POST requests ---
$r = POST "http://www.sn.no", [foo => 'bar;baz',
baz => [qw(a b c)],
foo => 'zoo=&',
"space " => " + ",
"nl" => "a\nb\r\nc\n",
],
bar => 'foo';
note $r->as_string, "\n";
is($r->method, "POST");
is($r->content_type, "application/x-www-form-urlencoded");
is($r->content_length, 83);
is($r->header("bar"), "foo");
is($r->content, "foo=bar%3Bbaz&baz=a&baz=b&baz=c&foo=zoo%3D%26&space+=+%2B+&nl=a%0D%0Ab%0D%0Ac%0D%0A");
$r = POST "http://example.com";
is($r->content_length, 0);
is($r->content, "");
$r = POST "http://example.com", [];
is($r->content_length, 0);
is($r->content, "");
$r = POST "mailto:gisle\@aas.no",
Subject => "Heisan",
Content_Type => "text/plain",
Content => "Howdy\n";
#note $r->as_string;
is($r->method, "POST");
is($r->header("Subject"), "Heisan");
is($r->content, "Howdy\n");
is($r->content_type, "text/plain");
{
my @warnings;
local $SIG{__WARN__} = sub { push @warnings, @_ };
$r = POST 'http://unf.ug/', [];
is( "@warnings", '', 'empty POST' );
}
#
# POST for File upload
#
my $file = "test-$$";
open(FILE, ">$file") or die "Can't create $file: $!";
print FILE "foo\nbar\nbaz\n";
close(FILE);
$r = POST 'http://www.perl.org/survey.cgi',
Content_Type => 'form-data',
Content => [ name => 'Gisle Aas',
email => 'gisle@aas.no',
gender => 'm',
born => '1964',
file => [$file],
];
#note $r->as_string;
unlink($file) or warn "Can't unlink $file: $!";
is($r->method, "POST");
is($r->uri->path, "/survey.cgi");
is($r->content_type, "multipart/form-data");
ok($r->header('Content_type') =~ /boundary="?([^"]+)"?/);
my $boundary = $1;
my $c = $r->content;
$c =~ s/\r//g;
my @c = split(/--\Q$boundary/, $c);
note "$c[5]\n";
is(@c, 7);
like($c[6], qr/^--\n/); # 5 parts + header & trailer
ok($c[2] =~ /^Content-Disposition:\s*form-data;\s*name="email"/m);
ok($c[2] =~ /^gisle\@aas.no$/m);
ok($c[5] =~ /^Content-Disposition:\s*form-data;\s*name="file";\s*filename="$file"/m);
ok($c[5] =~ /^Content-Type:\s*text\/plain$/m);
ok($c[5] =~ /^foo\nbar\nbaz/m);
$r = POST 'http://www.perl.org/survey.cgi',
[ file => [ undef, "xxy\"", Content_type => "text/html", Content => "Hello, world!
" ]],
Content_type => 'multipart/form-data';
#note $r->as_string;
ok($r->content =~ /^--\S+\015\012Content-Disposition:\s*form-data;\s*name="file";\s*filename="xxy\\"/m);
ok($r->content =~ /^Content-Type: text\/html/m);
ok($r->content =~ /^Hello, world/m);
$r = POST 'http://www.perl.org/survey.cgi',
Content_type => 'multipart/form-data',
Content => [ file => [ undef, undef, Content => "foo"]];
#note $r->as_string;
unlike($r->content, qr/filename=/);
# The POST routine can now also take a hash reference.
my %hash = (foo => 42, bar => 24);
$r = POST 'http://www.perl.org/survey.cgi', \%hash;
#note $r->as_string, "\n";
like($r->content, qr/foo=42/);
like($r->content, qr/bar=24/);
is($r->content_type, "application/x-www-form-urlencoded");
is($r->content_length, 13);
#
# POST for File upload
#
use HTTP::Request::Common qw($DYNAMIC_FILE_UPLOAD);
$file = "test-$$";
open(FILE, ">$file") or die "Can't create $file: $!";
for (1..1000) {
print FILE "a" .. "z";
}
close(FILE);
$DYNAMIC_FILE_UPLOAD++;
$r = POST 'http://www.perl.org/survey.cgi',
Content_Type => 'form-data',
Content => [ name => 'Gisle Aas',
email => 'gisle@aas.no',
gender => 'm',
born => '1964',
file => [$file],
];
#note $r->as_string, "\n";
is($r->method, "POST");
is($r->uri->path, "/survey.cgi");
is($r->content_type, "multipart/form-data");
ok($r->header('Content_type') =~ qr/boundary="?([^"]+)"?/);
$boundary = $1;
is(ref($r->content), "CODE");
cmp_ok(length($boundary), '>', 10);
my $code = $r->content;
my $chunk;
my @chunks;
while (defined($chunk = &$code) && length $chunk) {
push(@chunks, $chunk);
}
unlink($file) or warn "Can't unlink $file: $!";
$_ = join("", @chunks);
#note int(@chunks), " chunks, total size is ", length($_), " bytes\n";
# should be close to expected size and number of chunks
cmp_ok(abs(@chunks - 15), '<', 3);
cmp_ok(abs(length($_) - 26589), '<', 20);
$r = POST 'http://www.example.com';
is($r->as_string, < 'form-data', Content => [];
is($r->as_string, < 'form-data';
#note $r->as_string;
is($r->as_string, <method, "DELETE");
$r = HTTP::Request::Common::PUT 'http://www.example.com',
'Content-Type' => 'application/octet-steam',
'Content' => 'foobarbaz',
'Content-Length' => 12; # a slight lie
is($r->header('Content-Length'), 9);
HTTP-Message-6.11/t/distmanifest.t 000644 000766 000024 00000000310 12574114037 017175 0 ustar 00ether staff 000000 000000 use strict;
use warnings;
use Test::More;
BEGIN {
plan skip_all => 'these tests are for authors only!'
unless -d '.git' || $ENV{AUTHOR_TESTING};
}
use Test::DistManifest;
manifest_ok();
HTTP-Message-6.11/t/headers-auth.t 000644 000766 000024 00000002117 12552616231 017063 0 ustar 00ether staff 000000 000000 use strict;
use warnings;
use Test::More;
plan tests => 6;
use HTTP::Response;
use HTTP::Headers::Auth;
my $res = HTTP::Response->new(401);
$res->push_header(WWW_Authenticate => qq(Foo realm="WallyWorld", foo=bar, Bar realm="WallyWorld2"));
$res->push_header(WWW_Authenticate => qq(Basic Realm="WallyWorld", foo=bar, bar=baz));
note $res->as_string;
my %auth = $res->www_authenticate;
is(keys(%auth), 3);
is($auth{basic}{realm}, "WallyWorld");
is($auth{bar}{realm}, "WallyWorld2");
$a = $res->www_authenticate;
is($a, 'Foo realm="WallyWorld", foo=bar, Bar realm="WallyWorld2", Basic Realm="WallyWorld", foo=bar, bar=baz');
$res->www_authenticate("Basic realm=foo1");
note $res->as_string;
$res->www_authenticate(Basic => {realm => "foo2"});
print $res->as_string;
$res->www_authenticate(Basic => [realm => "foo3", foo=>33],
Digest => {nonce=>"bar", foo=>'foo'});
note $res->as_string;
my $string = $res->as_string;
like($string, qr/WWW-Authenticate: Basic realm="foo3", foo=33/);
like($string, qr/WWW-Authenticate: Digest (nonce=bar, foo=foo|foo=foo, nonce=bar)/);
HTTP-Message-6.11/t/headers-etag.t 000644 000766 000024 00000000635 12552616306 017050 0 ustar 00ether staff 000000 000000 use strict;
use warnings;
use Test::More;
plan tests => 4;
require HTTP::Headers::ETag;
my $h = HTTP::Headers->new;
$h->etag("tag1");
is($h->etag, qq("tag1"));
$h->etag("w/tag2");
is($h->etag, qq(W/"tag2"));
$h->if_match(qq(W/"foo", bar, baz), "bar");
$h->if_none_match(333);
$h->if_range("tag3");
is($h->if_range, qq("tag3"));
my $t = time;
$h->if_range($t);
is($h->if_range, $t);
note $h->as_string;
HTTP-Message-6.11/t/headers-util.t 000644 000766 000024 00000002300 12552616346 017100 0 ustar 00ether staff 000000 000000 use strict;
use warnings;
use Test::More;
use HTTP::Headers::Util qw(split_header_words join_header_words);
my @s_tests = (
["foo" => "foo"],
["foo=bar" => "foo=bar"],
[" foo " => "foo"],
["foo=" => 'foo=""'],
["foo=bar bar=baz" => "foo=bar; bar=baz"],
["foo=bar;bar=baz" => "foo=bar; bar=baz"],
['foo bar baz' => "foo; bar; baz"],
['foo="\"" bar="\\\\"' => 'foo="\""; bar="\\\\"'],
['foo,,,bar' => 'foo, bar'],
['foo=bar,bar=baz' => 'foo=bar, bar=baz'],
['TEXT/HTML; CHARSET=ISO-8859-1' =>
'text/html; charset=ISO-8859-1'],
['foo="bar"; port="80,81"; discard, bar=baz' =>
'foo=bar; port="80,81"; discard, bar=baz'],
['Basic realm="\"foo\\\\bar\""' =>
'basic; realm="\"foo\\\\bar\""'],
);
plan tests => @s_tests + 2;
for (@s_tests) {
my($arg, $expect) = @$_;
my @arg = ref($arg) ? @$arg : $arg;
my $res = join_header_words(split_header_words(@arg));
is($res, $expect);
}
note "# Extra tests\n";
# some extra tests
is(join_header_words("foo" => undef, "bar" => "baz"), "foo; bar=baz");
is(join_header_words(), "");
HTTP-Message-6.11/t/headers.t 000644 000766 000024 00000027364 12552617100 016133 0 ustar 00ether staff 000000 000000 use strict;
use warnings;
use Test::More;
plan tests => 168;
my($h, $h2);
sub j { join("|", @_) }
require HTTP::Headers;
$h = HTTP::Headers->new;
ok($h);
is(ref($h), "HTTP::Headers");
is($h->as_string, "");
$h = HTTP::Headers->new(foo => "bar", foo => "baaaaz", Foo => "baz");
is($h->as_string, "Foo: bar\nFoo: baaaaz\nFoo: baz\n");
$h = HTTP::Headers->new(foo => ["bar", "baz"]);
is($h->as_string, "Foo: bar\nFoo: baz\n");
$h = HTTP::Headers->new(foo => 1, bar => 2, foo_bar => 3);
is($h->as_string, "Bar: 2\nFoo: 1\nFoo-Bar: 3\n");
is($h->as_string(";"), "Bar: 2;Foo: 1;Foo-Bar: 3;");
is($h->header("Foo"), 1);
is($h->header("FOO"), 1);
is(j($h->header("foo")), 1);
is($h->header("foo-bar"), 3);
is($h->header("foo_bar"), 3);
is($h->header("Not-There"), undef);
is(j($h->header("Not-There")), "");
is(eval { $h->header }, undef);
ok($@);
is($h->header("Foo", 11), 1);
is($h->header("Foo", [1, 1]), 11);
is($h->header("Foo"), "1, 1");
is(j($h->header("Foo")), "1|1");
is($h->header(foo => 11, Foo => 12, bar => 22), 2);
is($h->header("Foo"), "11, 12");
is($h->header("Bar"), 22);
is($h->header("Bar", undef), 22);
is(j($h->header("bar", 22)), "");
$h->push_header(Bar => 22);
is($h->header("Bar"), "22, 22");
$h->push_header(Bar => [23 .. 25]);
is($h->header("Bar"), "22, 22, 23, 24, 25");
is(j($h->header("Bar")), "22|22|23|24|25");
$h->clear;
$h->header(Foo => 1);
is($h->as_string, "Foo: 1\n");
$h->init_header(Foo => 2);
$h->init_header(Bar => 2);
is($h->as_string, "Bar: 2\nFoo: 1\n");
$h->init_header(Foo => [2, 3]);
$h->init_header(Baz => [2, 3]);
is($h->as_string, "Bar: 2\nBaz: 2\nBaz: 3\nFoo: 1\n");
eval { $h->init_header(A => 1, B => 2, C => 3) };
ok($@);
is($h->as_string, "Bar: 2\nBaz: 2\nBaz: 3\nFoo: 1\n");
is($h->clone->remove_header("Foo"), 1);
is($h->clone->remove_header("Bar"), 1);
is($h->clone->remove_header("Baz"), 2);
is($h->clone->remove_header(qw(Foo Bar Baz Not-There)), 4);
is($h->clone->remove_header("Not-There"), 0);
is(j($h->clone->remove_header("Foo")), 1);
is(j($h->clone->remove_header("Bar")), 2);
is(j($h->clone->remove_header("Baz")), "2|3");
is(j($h->clone->remove_header(qw(Foo Bar Baz Not-There))), "1|2|2|3");
is(j($h->clone->remove_header("Not-There")), "");
$h = HTTP::Headers->new(
allow => "GET",
content => "none",
content_type => "text/html",
content_md5 => "dummy",
content_encoding => "gzip",
content_foo => "bar",
last_modified => "yesterday",
expires => "tomorrow",
etag => "abc",
date => "today",
user_agent => "libwww-perl",
zoo => "foo",
);
is($h->as_string, <clone;
is($h->as_string, $h2->as_string);
is($h->remove_content_headers->as_string, <as_string, <remove_content_headers;
is($h->as_string, $h2->as_string);
$h->clear;
is($h->as_string, "");
undef($h2);
$h = HTTP::Headers->new;
is($h->header_field_names, 0);
is(j($h->header_field_names), "");
$h = HTTP::Headers->new( etag => 1, foo => [2,3],
content_type => "text/plain");
is($h->header_field_names, 3);
is(j($h->header_field_names), "ETag|Content-Type|Foo");
{
my @tmp;
$h->scan(sub { push(@tmp, @_) });
is(j(@tmp), "ETag|1|Content-Type|text/plain|Foo|2|Foo|3");
@tmp = ();
eval { $h->scan(sub { push(@tmp, @_); die if $_[0] eq "Content-Type" }) };
ok($@);
is(j(@tmp), "ETag|1|Content-Type|text/plain");
@tmp = ();
$h->scan(sub { push(@tmp, @_) });
is(j(@tmp), "ETag|1|Content-Type|text/plain|Foo|2|Foo|3");
}
# CONVENIENCE METHODS
$h = HTTP::Headers->new;
is($h->date, undef);
is($h->date(time), undef);
is(j($h->header_field_names), "Date");
like($h->header("Date"), qr/^[A-Z][a-z][a-z], \d\d .* GMT$/);
{
my $off = time - $h->date;
ok($off == 0 || $off == 1);
}
if ($] < 5.006) {
Test::skip("Can't call variable method", 1) for 1..13;
}
else {
# other date fields
for my $field (qw(expires if_modified_since if_unmodified_since
last_modified))
{
eval <<'EOT'; die $@ if $@;
is($h->$field, undef);
is($h->$field(time), undef);
like((time - $h->$field), qr/^[01]$/);
EOT
}
is(j($h->header_field_names), "Date|If-Modified-Since|If-Unmodified-Since|Expires|Last-Modified");
}
$h->clear;
is($h->content_type, "");
is($h->content_type("text/html"), "");
is($h->content_type, "text/html");
is($h->content_type(" TEXT / HTML ") , "text/html");
is($h->content_type, "text/html");
is(j($h->content_type), "text/html");
is($h->content_type("text/html;\n charSet = \"ISO-8859-1\"; Foo=1 "), "text/html");
is($h->content_type, "text/html");
is(j($h->content_type), "text/html|charSet = \"ISO-8859-1\"; Foo=1 ");
is($h->header("content_type"), "text/html;\n charSet = \"ISO-8859-1\"; Foo=1 ");
ok($h->content_is_html);
ok(!$h->content_is_xhtml);
ok(!$h->content_is_xml);
$h->content_type("application/xhtml+xml");
ok($h->content_is_html);
ok($h->content_is_xhtml);
ok($h->content_is_xml);
is($h->content_type("text/html;\n charSet = \"ISO-8859-1\"; Foo=1 "), "application/xhtml+xml");
is($h->content_encoding, undef);
is($h->content_encoding("gzip"), undef);
is($h->content_encoding, "gzip");
is(j($h->header_field_names), "Content-Encoding|Content-Type");
is($h->content_language, undef);
is($h->content_language("no"), undef);
is($h->content_language, "no");
is($h->title, undef);
is($h->title("This is a test"), undef);
is($h->title, "This is a test");
is($h->user_agent, undef);
is($h->user_agent("Mozilla/1.2"), undef);
is($h->user_agent, "Mozilla/1.2");
is($h->server, undef);
is($h->server("Apache/2.1"), undef);
is($h->server, "Apache/2.1");
is($h->from("Gisle\@ActiveState.com"), undef);
ok($h->header("from", "Gisle\@ActiveState.com"));
is($h->referer("http://www.example.com"), undef);
is($h->referer, "http://www.example.com");
is($h->referrer, "http://www.example.com");
is($h->referer("http://www.example.com/#bar"), "http://www.example.com");
is($h->referer, "http://www.example.com/");
{
require URI;
my $u = URI->new("http://www.example.com#bar");
$h->referer($u);
is($u->as_string, "http://www.example.com#bar");
is($h->referer->fragment, undef);
is($h->referrer->as_string, "http://www.example.com");
}
is($h->as_string, <clear;
is($h->www_authenticate("foo"), undef);
is($h->www_authenticate("bar"), "foo");
is($h->www_authenticate, "bar");
is($h->proxy_authenticate("foo"), undef);
is($h->proxy_authenticate("bar"), "foo");
is($h->proxy_authenticate, "bar");
is($h->authorization_basic, undef);
is($h->authorization_basic("u"), undef);
is($h->authorization_basic("u", "p"), "u:");
is($h->authorization_basic, "u:p");
is(j($h->authorization_basic), "u|p");
is($h->authorization, "Basic dTpw");
is(eval { $h->authorization_basic("u2:p") }, undef);
ok($@);
is(j($h->authorization_basic), "u|p");
is($h->proxy_authorization_basic("u2", "p2"), undef);
is(j($h->proxy_authorization_basic), "u2|p2");
is($h->proxy_authorization, "Basic dTI6cDI=");
is($h->as_string, <new;
eval {
$line = __LINE__; $h->header('foo:', 1);
};
like($@, qr/^Illegal field name 'foo:' at \Q$file\E line $line/);
eval {
$line = __LINE__; $h->header('', 2);
};
like($@, qr/^Illegal field name '' at \Q$file\E line $line/);
#---- old tests below -----
$h = new HTTP::Headers
mime_version => "1.0",
content_type => "text/html";
$h->header(URI => "http://www.oslonett.no/");
is($h->header("MIME-Version"), "1.0");
is($h->header('Uri'), "http://www.oslonett.no/");
$h->header("MY-header" => "foo",
"Date" => "somedate",
"Accept" => ["text/plain", "image/*"],
);
$h->push_header("accept" => "audio/basic");
is($h->header("date"), "somedate");
my @accept = $h->header("accept");
is(@accept, 3);
$h->remove_header("uri", "date");
my $str = $h->as_string;
my $lines = ($str =~ tr/\n/\n/);
is($lines, 6);
$h2 = $h->clone;
$h->header("accept", "*/*");
$h->remove_header("my-header");
@accept = $h2->header("accept");
is(@accept, 3);
@accept = $h->header("accept");
is(@accept, 1);
# Check order of headers, but first remove this one
$h2->remove_header('mime_version');
# and add this general header
$h2->header(Connection => 'close');
my @x = ();
$h2->scan(sub {push(@x, shift);});
is(join(";", @x), "Connection;Accept;Accept;Accept;Content-Type;MY-Header");
# Check headers with embedded newlines:
$h = HTTP::Headers->new(
a => "foo\n\n",
b => "foo\nbar",
c => "foo\n\nbar\n\n",
d => "foo\n\tbar",
e => "foo\n bar ",
f => "foo\n bar\n baz\nbaz",
);
is($h->as_string("<<\n"), <new(
a => "foo\r\n\r\nevil body" ,
b => "foo\015\012\015\012evil body" ,
c => "foo\x0d\x0a\x0d\x0aevil body" ,
);
is (
$h->as_string(),
"A: foo\r\n evil body\n".
"B: foo\015\012 evil body\n" .
"C: foo\x0d\x0a evil body\n" ,
"embedded CRLF are stripped out");
# Check with FALSE $HTML::Headers::TRANSLATE_UNDERSCORE
{
local($HTTP::Headers::TRANSLATE_UNDERSCORE);
$HTTP::Headers::TRANSLATE_UNDERSCORE = undef; # avoid -w warning
$h = HTTP::Headers->new;
$h->header(abc_abc => "foo");
$h->header("abc-abc" => "bar");
is($h->header("ABC_ABC"), "foo");
is($h->header("ABC-ABC"),"bar");
ok($h->remove_header("Abc_Abc"));
ok(!defined($h->header("abc_abc")));
is($h->header("ABC-ABC"), "bar");
}
# Check if objects as header values works
require URI;
$h->header(URI => URI->new("http://www.perl.org"));
is($h->header("URI")->scheme, "http");
$h->clear;
is($h->as_string, "");
$h->content_type("text/plain");
$h->header(content_md5 => "dummy");
$h->header("Content-Foo" => "foo");
$h->header(Location => "http:", xyzzy => "plugh!");
is($h->as_string, <remove_content_headers;
is($h->as_string, <as_string, <new;
$h->content_type("text/plain");
$h->header(":foo_bar", 1);
$h->push_header(":content_type", "text/html");
is(j($h->header_field_names), "Content-Type|:content_type|:foo_bar");
is($h->header('Content-Type'), "text/plain");
is($h->header(':Content_Type'), undef);
is($h->header(':content_type'), "text/html");
is($h->as_string, <new(
if_modified_since => "Sat, 29 Oct 1994 19:43:31 GMT; length=34343"
);
is(gmtime($h->if_modified_since), "Sat Oct 29 19:43:31 1994");
$h = HTTP::Headers->new();
$h->content_type('text/plain');
$h->content_length(4);
$h->push_header('x-foo' => 'bar');
$h->push_header('x-foo' => 'baz');
is(0+$h->flatten, 8);
is_deeply(
[ $h->flatten ],
[
'Content-Length',
4,
'Content-Type',
'text/plain',
'X-Foo',
'bar',
'X-Foo',
'baz',
],
);
HTTP-Message-6.11/t/http-config.t 000644 000766 000024 00000005157 12552622373 016746 0 ustar 00ether staff 000000 000000 use strict;
use warnings;
use Test::More;
plan tests => 16;
use HTTP::Config;
sub j { join("|", @_) }
my $conf = HTTP::Config->new;
ok($conf->empty);
$conf->add_item(42);
ok(!$conf->empty);
is(j($conf->matching_items("http://www.example.com/foo")), 42);
is(j($conf->remove_items), 42);
is($conf->matching_items("http://www.example.com/foo"), 0);
$conf = HTTP::Config->new;
$conf->add_item("always");
$conf->add_item("GET", m_method => ["GET", "HEAD"]);
$conf->add_item("POST", m_method => "POST");
$conf->add_item(".com", m_domain => ".com");
$conf->add_item("secure", m_secure => 1);
$conf->add_item("not secure", m_secure => 0);
$conf->add_item("slash", m_host_port => "www.example.com:80", m_path_prefix => "/");
$conf->add_item("u:p", m_host_port => "www.example.com:80", m_path_prefix => "/foo");
$conf->add_item("success", m_code => "2xx");
use HTTP::Request;
my $request = HTTP::Request->new(HEAD => "http://www.example.com/foo/bar");
$request->header("User-Agent" => "Moz/1.0");
is(j($conf->matching_items($request)), "u:p|slash|.com|GET|not secure|always");
$request->method("HEAD");
$request->uri->scheme("https");
is(j($conf->matching_items($request)), ".com|GET|secure|always");
is(j($conf->matching_items("http://activestate.com")), ".com|not secure|always");
use HTTP::Response;
my $response = HTTP::Response->new(200 => "OK");
$response->content_type("text/plain");
$response->content("Hello, world!\n");
$response->request($request);
is(j($conf->matching_items($response)), ".com|success|GET|secure|always");
$conf->remove_items(m_secure => 1);
$conf->remove_items(m_domain => ".com");
is(j($conf->matching_items($response)), "success|GET|always");
$conf->remove_items; # start fresh
is(j($conf->matching_items($response)), "");
$conf->add_item("any", "m_media_type" => "*/*");
$conf->add_item("text", m_media_type => "text/*");
$conf->add_item("html", m_media_type => "html");
$conf->add_item("HTML", m_media_type => "text/html");
$conf->add_item("xhtml", m_media_type => "xhtml");
is(j($conf->matching_items($response)), "text|any");
$response->content_type("application/xhtml+xml");
is(j($conf->matching_items($response)), "xhtml|html|any");
$response->content_type("text/html");
is(j($conf->matching_items($response)), "HTML|html|text|any");
{
my @warnings;
local $SIG{__WARN__} = sub { push @warnings, grep { length } @_ };
my $conf = HTTP::Config->new;
$conf->add(owner => undef, callback => sub { 'bleah' });
$conf->remove(owner => undef);
ok(($conf->empty), 'found and removed the config entry');
is(scalar(@warnings), 0, 'no warnings')
or diag('got warnings: ', explain(\@warnings));
}
HTTP-Message-6.11/t/message-charset.t 000644 000766 000024 00000006153 12552617537 017602 0 ustar 00ether staff 000000 000000 use strict;
use warnings;
use Test::More;
plan tests => 43;
use HTTP::Response;
my $r = HTTP::Response->new(200, "OK");
is($r->content_charset, undef);
is($r->content_type_charset, undef);
$r->content_type("text/plain");
is($r->content_charset, undef);
$r->content("abc");
is($r->content_charset, "US-ASCII");
$r->content("f\xE5rep\xF8lse\n");
is($r->content_charset, "ISO-8859-1");
$r->content("f\xC3\xA5rep\xC3\xB8lse\n");
is($r->content_charset, "UTF-8");
$r->content_type("text/html");
$r->content(<<'EOT');
EOT
is($r->content_charset, "UTF-8");
$r->content(<<'EOT');
EOT
is($r->content_charset, "UTF-8");
$r->content(<<'EOT');