Skip Menu |
 

This queue is for tickets about the XML-Compile-SOAP CPAN distribution.

Report information
The Basics
Id: 34788
Status: resolved
Priority: 0/
Queue: XML-Compile-SOAP

People
Owner: Nobody in particular
Requestors: drew [...] drewtaylor.com
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: (no value)
Fixed in: (no value)



Subject: Patch to add Content-Length for POST requests
Download (untitled) / with headers
text/plain 1.1k
I'm using the transport_hook option of $wsdl->compileClient() to use the Catalyst test server. However, the HTTP::Request sent does not have a Content-Length header which makes Catalyst think there is no body. The patch below adds that header. Note: I'm not sure how this handles unicode. I may be doing that part right, but I'm still a newbie with Unicode. Drew drew@skidoo ../XML/Compile/Transport$ diff -u SOAPHTTP.pm.orig SOAPHTTP.pm --- SOAPHTTP.pm.orig 2008-04-09 16:44:06.000000000 +0100 +++ SOAPHTTP.pm 2008-04-09 16:47:22.000000000 +0100 @@ -121,11 +121,16 @@ $hook ? sub # hooked code { my $trace = $_[1]; + my $length; if(utf8::is_utf8($_[0])) { my $u = encode($charset, $_[0]); + $length = length $u; $request->content($u); } - else { $request->content($_[0]) } + else { $length = length $_[0]; $request->content($_[0]) } + # Content-Length header is needed only for POSTs + $request->header("Content-Length", $length) + if uc $request->method eq 'POST'; $trace->{http_request} = $request; $trace->{action} = $action;
Subject: Re: [rt.cpan.org #34788] Patch to add Content-Length for POST requests
Date: Wed, 9 Apr 2008 20:02:15 +0200
To: Drew Taylor via RT <bug-XML-Compile-SOAP [...] rt.cpan.org>
From: Mark Overmeer <mark [...] overmeer.net>
Download (untitled) / with headers
text/plain 2.1k
* Drew Taylor via RT (bug-XML-Compile-SOAP@rt.cpan.org) [080409 15:52]: Show quoted text
> Wed Apr 09 11:52:36 2008: Request 34788 was acted upon. > Transaction: Ticket created by drew@drewtaylor.com > Queue: XML-Compile-SOAP > > I'm using the transport_hook option of $wsdl->compileClient() to use > the Catalyst test server. However, the HTTP::Request sent does not > have a Content-Length header which makes Catalyst think there is no > body. The patch below adds that header.
I had expected that setting the content of the message would automatically set the content-length field (at least, that would be my design) Show quoted text
> > Note: I'm not sure how this handles unicode. I may be doing that part > right, but I'm still a newbie with Unicode.
Simply { use bytes; $l = length $string} Show quoted text
> + my $length; > if(utf8::is_utf8($_[0])) > { my $u = encode($charset, $_[0]); > + $length = length $u; > $request->content($u); > } > - else { $request->content($_[0]) } > + else { $length = length $_[0]; $request->content($_[0]) } > + # Content-Length header is needed only for POSTs > + $request->header("Content-Length", $length) > + if uc $request->method eq 'POST';
From some other report I know that the encode must always be called. Besides, also non-POST methods may also benefit from the Content-Length field. So, probably this will be it (needs some testing) $hook ? sub # hooked code { my $trace = $_[1]; my $u = encode($charset, $_[0]); $request->content($u); { use bytes; $request->header('Content-Length' => length $u); } and the same in the next block, and in the server implementation. Will be released in 0.71 -- Thanks for the contribution, MarkOv ------------------------------------------------------------------------ Mark Overmeer MSc MARKOV Solutions drs Mark A.C.J. Overmeer MARKOV Solutions Mark@Overmeer.net solutions@overmeer.net http://Mark.Overmeer.net http://solutions.overmeer.net
fix was released in 0.71


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.