Skip to content

HTTP::Response as_string and parse not commutative [rt.cpan.org #62959] #48

@oalders

Description

@oalders

Migrated from rt.cpan.org#62959 (status was 'new')

Requestors:

From [email protected] on 2010-11-12 23:23:29:

We have found that calling as_string on an HTTP::Response object which
is later restored via HTTP::Response->parse introduces changes in the
content of the response.

HTTP::Response v 5.813

Perl 5.10.0

OS   Debian 2.6.26-25lenny1  Linux 2.6.26 modules on AMD64

=============

Reproducing this problem is very simple. The following snippet of code
will demonstrate the problem; its output is below the next break.

use HTTP::Response; 

my $r = HTTP::Response->new; 
$r->content("This is a sample of content"); 
print "---\n",$r->content,"---\n"; 

my $s = $r->as_string; 
print "---\n", $s, "---\n"; 

my $t = HTTP::Response->parse($s); 
print "---\n", $t->content, "---\n";

=============

---
This is a sample of content---
---
000 Unknown code

This is a sample of content
---
---
This is a sample of content
---

=============

It is the opinion of myself and my colleagues that the last output
should be identical to the first.  Introducing new data into the content
stream during this operation is troublesome from the context of using
as_string as a means to serialize an HTTP::Message (specifically an
HTTP::Response, but I suspect this also applies to HTTP::Requests; but
that is not confirmed).

Without knowing why a newline is appended to the as_string results, I
cannot suggest methods of fixing this. We have a work-around in place,
but I would rather see a solution within libwww-perl than leave a
work-around in place for an extended period of time.

James Zwiers
Riverstyx Internet

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions