r59497 - in /trunk/libhttp-parser-perl: Changes META.yml Makefile.PL Parser.pm README debian/changelog debian/control debian/copyright debian/source/ debian/source/format
ansgar-guest at users.alioth.debian.org
ansgar-guest at users.alioth.debian.org
Fri Jun 18 06:47:38 UTC 2010
Author: ansgar-guest
Date: Fri Jun 18 06:47:24 2010
New Revision: 59497
URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=59497
Log:
* New upstream release.
* Use source format 3.0 (quilt).
* debian/copyright: Formatting changes for current DEP-5 proposal.
* Bump Standards-Version to 3.8.4 (no changes).
* Add myself to Uploaders.
Added:
trunk/libhttp-parser-perl/debian/source/
trunk/libhttp-parser-perl/debian/source/format
Modified:
trunk/libhttp-parser-perl/Changes
trunk/libhttp-parser-perl/META.yml
trunk/libhttp-parser-perl/Makefile.PL
trunk/libhttp-parser-perl/Parser.pm
trunk/libhttp-parser-perl/README
trunk/libhttp-parser-perl/debian/changelog
trunk/libhttp-parser-perl/debian/control
trunk/libhttp-parser-perl/debian/copyright
Modified: trunk/libhttp-parser-perl/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libhttp-parser-perl/Changes?rev=59497&op=diff
==============================================================================
--- trunk/libhttp-parser-perl/Changes (original)
+++ trunk/libhttp-parser-perl/Changes Fri Jun 18 06:47:24 2010
@@ -1,4 +1,12 @@
Revision history for Perl extension HTTP::Parser.
+
+0.05 2009-11-13
+ - two fixes by David Cannings <david at edeca.net>
+ - when parsing responses with no Content-Length header, return a different
+ code to the caller so it can decide whether to keep adding data or not
+ (a slightly more elegant fix to rt.cpan.org #34021)
+ - parse the HTTP response message correctly, it can contain multiple words
+ (rt.cpan.org #34019)
0.04 2007-11-10
- when parsing chunks, only remove current chunk from data buffer; don't
Modified: trunk/libhttp-parser-perl/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libhttp-parser-perl/META.yml?rev=59497&op=diff
==============================================================================
--- trunk/libhttp-parser-perl/META.yml (original)
+++ trunk/libhttp-parser-perl/META.yml Fri Jun 18 06:47:24 2010
@@ -1,13 +1,25 @@
-# http://module-build.sourceforge.net/META-spec.html
-#XXXXXXX This is a prototype!!! It will change in the future!!! XXXXX#
-name: HTTP-Parser
-version: 0.04
-version_from: Parser.pm
-installdirs: site
+--- #YAML:1.0
+name: HTTP-Parser
+version: 0.05
+abstract: parse HTTP/1.1 request into HTTP::Request/Response object
+author:
+ - David. B. Robins <dbrobins at davidrobins.net>
+license: perl
+distribution_type: module
+configure_requires:
+ ExtUtils::MakeMaker: 0
+build_requires:
+ ExtUtils::MakeMaker: 0
requires:
- HTTP::Request: 0
- HTTP::Response: 0
- URI: 0
-
-distribution_type: module
-generated_by: ExtUtils::MakeMaker version 6.30
+ HTTP::Request: 0
+ HTTP::Response: 0
+ Test::More: 0
+ URI: 0
+no_index:
+ directory:
+ - t
+ - inc
+generated_by: ExtUtils::MakeMaker version 6.54
+meta-spec:
+ url: http://module-build.sourceforge.net/META-spec-v1.4.html
+ version: 1.4
Modified: trunk/libhttp-parser-perl/Makefile.PL
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libhttp-parser-perl/Makefile.PL?rev=59497&op=diff
==============================================================================
--- trunk/libhttp-parser-perl/Makefile.PL (original)
+++ trunk/libhttp-parser-perl/Makefile.PL Fri Jun 18 06:47:24 2010
@@ -9,7 +9,9 @@
'URI' => 0,
'HTTP::Request' => 0,
'HTTP::Response' => 0,
+ 'Test::More' => 0,
},
+ 'LICENSE' => 'perl',
($] >= 5.005 ? ## Add these new keywords supported since 5.005
(ABSTRACT_FROM => 'Parser.pm', # retrieve abstract from module
AUTHOR => 'David. B. Robins <dbrobins at davidrobins.net>') : ()),
Modified: trunk/libhttp-parser-perl/Parser.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libhttp-parser-perl/Parser.pm?rev=59497&op=diff
==============================================================================
--- trunk/libhttp-parser-perl/Parser.pm (original)
+++ trunk/libhttp-parser-perl/Parser.pm Fri Jun 18 06:47:24 2010
@@ -12,6 +12,8 @@
if(0 == $status) {
print "request: ".$parser->request()->as_string(); # HTTP::Request
+ } elsif(-3 == $status) {
+ print "no content length header!\n";
} elsif(-2 == $status) {
print "need a line of data\n";
} elsif(-1 == $status) {
@@ -33,7 +35,7 @@
package HTTP::Parser;
-our $VERSION = '0.04';
+our $VERSION = '0.05';
use HTTP::Request;
use HTTP::Response;
@@ -98,6 +100,21 @@
if waiting for a line (like 0 with a hint)
+=item -3
+
+if there was no content-length header, so we can't tell whether we are
+waiting for more data or not.
+
+If you are reading from a TCP stream, you can keep adding data until
+the connection closes gracefully (the HTTP RFC allows this).
+
+If you are reading from a file, you should keep adding until you have
+all the data.
+
+Once you have added all data, you may call C<object>. if you are not
+sure whether you have all the data, the HTTP::Response object might be
+incomplete.
+
=item count
if waiting for that many bytes
@@ -231,7 +248,9 @@
if ($request =~ /^HTTP\/(\d+)\.(\d+)/i) {
die 'HTTP responses not allowed' unless $self->{response};
($major,$minor) = ($1,$2);
- my (undef, $state, $msg) = split / /,$request;
+ $request =~ /^HTTP\/\d+\.\d+ (\d+) (.+)$/;
+ my $state = $1;
+ my $msg = $2;
$obj = $self->{obj} = HTTP::Response->new($state, $msg);
# perhaps a request?
@@ -277,6 +296,32 @@
}
}
+ # section 14.13 of the spec says an HTTP response "SHOULD" return a
+ # content-length header unless there are reasons not to
+ # however, the same RFC does allow "end of connection" as a valid marker
+ # of the end of data and means the server does not need to set a content
+ # length header. the only status codes that "MAY NOT" return data are
+ # 1xx, 204 and 304.
+ # therefore if there is no content length header, return -3 to the caller
+ # so they can decide whether to keep feeding data. if using HTTP::Parser
+ # with data from tcp, you could assume that the end of a connection is
+ # the end of the response data
+ if($self->{response}) {
+ if (!defined $obj->header('content_length') &&
+ $self->object->code ne '204' &&
+ $self->object->code ne '304' &&
+ $self->object->code !~ /1\d\d/) {
+
+ # Assume headers are finished and we are moving into body mode
+ $self->{state} = 'body';
+ $self->{no_content_length} = 1;
+
+ # Parse any data that might be left
+ return $self->_parse_body() if length $self->data;
+ return -3;
+ }
+ }
+
# else we have no content so return success
return 0;
}
@@ -290,6 +335,16 @@
sub _parse_body {
my $self = shift;
my $length = $self->{obj}->header('content_length');
+
+ # if the server didn't include a content length header, inform the
+ # caller. they may choose to ignore this response or wait for
+ # the end of connection (which is a valid reason to assume that
+ # the response is finished)
+ if($self->{no_content_length}) {
+ $self->{obj}->content($self->{data});
+ return -3;
+ }
+
if(length $self->{data} >= $length) {
$self->{obj}->content(substr($self->{data},0,$length,''));
return 0;
@@ -323,7 +378,7 @@
}
} else {
- die "expected chunked enoding, got '".substr($self->{data},0,40)."...'"
+ die "expected chunked encoding, got '".substr($self->{data},0,40)."...'"
if $self->{data} =~ /\x0d?\x0a/;
return -2; # waiting for a line with chunk information
}
@@ -354,6 +409,7 @@
=head1 AUTHOR
David Robins E<lt>dbrobins at davidrobins.netE<gt>
+Fixes for 0.05 by David Cannings E<lt>david at edeca.netE<gt>
=head1 SEE ALSO
Modified: trunk/libhttp-parser-perl/README
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libhttp-parser-perl/README?rev=59497&op=diff
==============================================================================
--- trunk/libhttp-parser-perl/README (original)
+++ trunk/libhttp-parser-perl/README Fri Jun 18 06:47:24 2010
@@ -9,15 +9,18 @@
e.g.
+ use HTTP::Parser;
+
my $parser = HTTP::Parser->new();
my @lines = ('GET / HTTP/1.1','Host: localhost','Connection: close','','');
my $result;
- while my $line(@lines) {
+ foreach my $line (@lines) {
$result = $parser->add("$line\x0d\x0a");
print "passing '$line' got '$result'\n";
}
- print $result->as_string();
+ print $parser->object->as_string();
+
gives:
@@ -48,6 +51,7 @@
COPYRIGHT AND LICENCE
Copyright (C) 2004-2007 David B. Robins
+Some fixes for 0.05 supplied by David Cannings
This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.
Modified: trunk/libhttp-parser-perl/debian/changelog
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libhttp-parser-perl/debian/changelog?rev=59497&op=diff
==============================================================================
--- trunk/libhttp-parser-perl/debian/changelog (original)
+++ trunk/libhttp-parser-perl/debian/changelog Fri Jun 18 06:47:24 2010
@@ -1,3 +1,13 @@
+libhttp-parser-perl (0.05-1) unstable; urgency=low
+
+ * New upstream release.
+ * Use source format 3.0 (quilt).
+ * debian/copyright: Formatting changes for current DEP-5 proposal.
+ * Bump Standards-Version to 3.8.4 (no changes).
+ * Add myself to Uploaders.
+
+ -- Ansgar Burchardt <ansgar at 43-1.org> Fri, 18 Jun 2010 15:46:51 +0900
+
libhttp-parser-perl (0.04-1) unstable; urgency=low
* Initial Release (Closes: #552283)
Modified: trunk/libhttp-parser-perl/debian/control
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libhttp-parser-perl/debian/control?rev=59497&op=diff
==============================================================================
--- trunk/libhttp-parser-perl/debian/control (original)
+++ trunk/libhttp-parser-perl/debian/control Fri Jun 18 06:47:24 2010
@@ -4,8 +4,8 @@
Build-Depends: debhelper (>= 7)
Build-Depends-Indep: perl, liburi-perl, libwww-perl
Maintainer: Debian Perl Group <pkg-perl-maintainers at lists.alioth.debian.org>
-Uploaders: Jonathan Yu <jawnsy at cpan.org>
-Standards-Version: 3.8.3
+Uploaders: Jonathan Yu <jawnsy at cpan.org>, Ansgar Burchardt <ansgar at 43-1.org>
+Standards-Version: 3.8.4
Homepage: http://search.cpan.org/dist/HTTP-Parser/
Vcs-Svn: svn://svn.debian.org/pkg-perl/trunk/libhttp-parser-perl/
Vcs-Browser: http://svn.debian.org/viewsvn/pkg-perl/trunk/libhttp-parser-perl/
Modified: trunk/libhttp-parser-perl/debian/copyright
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libhttp-parser-perl/debian/copyright?rev=59497&op=diff
==============================================================================
--- trunk/libhttp-parser-perl/debian/copyright (original)
+++ trunk/libhttp-parser-perl/debian/copyright Fri Jun 18 06:47:24 2010
@@ -1,17 +1,14 @@
-Format-Specification:
- http://wiki.debian.org/Proposals/CopyrightFormat?action=recall&rev=196
-Upstream-Maintainer: David Robins <dbrobins at davidrobins.net>
-Upstream-Source: http://search.cpan.org/dist/HTTP-Parser/
-Upstream-Name: HTTP-Parser
+Format-Specification: http://svn.debian.org/wsvn/dep/web/deps/dep5.mdwn?op=file&rev=135
+Maintainer: David Robins <dbrobins at davidrobins.net>
+Source: http://search.cpan.org/dist/HTTP-Parser/
+Name: HTTP-Parser
-Files: *
Copyright: 2004-2007, David B. Robins <dbrobins at davidrobins.net>
-License-Alias: Perl
-License: Artistic | GPL-1+
+License: Artistic or GPL-1+
Files: debian/*
Copyright: 2009, Jonathan Yu <jawnsy at cpan.org>
-License: Artistic | GPL-1+
+License: Artistic or GPL-1+
License: Artistic
This program is free software; you can redistribute it and/or modify
Added: trunk/libhttp-parser-perl/debian/source/format
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libhttp-parser-perl/debian/source/format?rev=59497&op=file
==============================================================================
--- trunk/libhttp-parser-perl/debian/source/format (added)
+++ trunk/libhttp-parser-perl/debian/source/format Fri Jun 18 06:47:24 2010
@@ -1,0 +1,1 @@
+3.0 (quilt)
More information about the Pkg-perl-cvs-commits
mailing list