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
MIME-Version: 1.0
X-Mailer: MIME-tools 5.418 (Entity 5.418)
Content-Type: text/plain
Charset: utf8
Content-Disposition: inline
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
Content-Length: 1185
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;
MIME-Version: 1.0
X-Spam-Status: No, hits=-2.6 required=8.0 tests=BAYES_00
In-Reply-To: <rt-3.6.HEAD-31182-1207756357-1720.34788-4-0 [...] rt.cpan.org>
Content-Disposition: inline
References: <RT-Ticket-34788 [...] rt.cpan.org> <rt-3.6.HEAD-31182-1207756357-1720.34788-4-0 [...] rt.cpan.org>
Content-Type: text/plain; charset="utf-8"
X-RT-Original-Encoding: us-ascii
Received: from x1.develooper.com (x1.develooper.com [63.251.223.170]) by diesel.bestpractical.com (Postfix) with SMTP id 226924D803F for <bug-XML-Compile-SOAP [...] rt.cpan.org>; Wed, 9 Apr 2008 14:02:38 -0400 (EDT)
Received: (qmail 32011 invoked from network); 9 Apr 2008 18:02:37 -0000
Received: from x16.dev (10.0.100.26) by x1.dev with QMQP; 9 Apr 2008 18:02:37 -0000
Received: from mail.overmeer.net (HELO earth.overmeer.net) (194.109.195.227) by 16.mx.develooper.com (qpsmtpd/0.43rc1) with ESMTP; Wed, 09 Apr 2008 11:02:32 -0700
Received: by earth.overmeer.net (Postfix, from userid 500) id 4E12FAA9B7; Wed, 9 Apr 2008 20:02:15 +0200 (CEST)
Delivered-To: cpan-bug+XML-Compile-SOAP [...] diesel.bestpractical.com
Subject: Re: [rt.cpan.org #34788] Patch to add Content-Length for POST requests
User-Agent: Mutt/1.5.9i
Return-Path: <markov [...] overmeer.net>
X-Spam-Check-BY: 16.mx.develooper.com
X-Original-To: bug-XML-Compile-SOAP [...] rt.cpan.org
Date: Wed, 9 Apr 2008 20:02:15 +0200
X-Spam-Level: *
Message-Id: <20080409180215.GB31372 [...] earth.overmeer.net>
To: Drew Taylor via RT <bug-XML-Compile-SOAP [...] rt.cpan.org>
From: Mark Overmeer <mark [...] overmeer.net>
X-RT-Original-Encoding: utf-8
RT-Message-ID: <rt-3.6.HEAD-31182-1207764166-281.34788-0-0 [...] rt.cpan.org>
Content-Length: 2174
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
MIME-Version: 1.0
X-Mailer: MIME-tools 5.418 (Entity 5.418)
Content-Disposition: inline
Charset: utf8
Message-Id: <rt-3.6.HEAD-10211-1207995912-974.34788-0-0 [...] rt.cpan.org>
Content-Type: text/plain
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
X-RT-Original-Encoding: utf-8
Content-Length: 24
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.