Re: POST with no data

2002-09-17 Thread Doug MacEachern
i think lwp does the right thing, but TestRequest.pm does not.
patch below should fix (untested).

--- Apache-Test/lib/Apache/TestRequest.pm   4 Apr 2002 00:54:26 -  1.71
+++ Apache-Test/lib/Apache/TestRequest.pm   17 Sep 2002 20:22:38 -
@@ -251,7 +251,7 @@
 $credentials{$keep-{realm} || '__ALL__'} =
   [$keep-{username}, $keep-{password}];
 }
-if (my $content = $keep-{content}) {
+if (defined(my $content = $keep-{content})) {
 if ($content eq '-') {
 $content = join '', STDIN;
 }





Re: POST with no data

2002-09-11 Thread Gary Benson
On Tue, Sep 10, 2002 at 05:55:27PM +0100, Gary Benson wrote:

 I've been trying to write some tests and have been trying to send POST
 requests with no body.  It seems that Apache::TestRequest::POST only
 adds a Content-Length when the length of the content is nonzero, so
 attempts to 'POST /foo/bar, ' result in a 411 Length Required from
 httpd.
 
 I'm not nearly good enough with Perl to work out where POST is defined;
 can anyone point me in the direction of what I need to change to cause a
 content-length to be added to all POST requests?

So I eventually managed to make a workaround for this (attached).  I'm
still not sure if httpd-test is the correct place for the fix or whether
I should be fixing LWP so I won't commit it.

Cheers,
Gary

[ [EMAIL PROTECTED] ][ GnuPG 85A8F78B ][ http://inauspicious.org/ ]
Content-length headers don't seem to get added to POST requests with
empty bodies, causing httpd to return a 411 Length Required.

Index: perl-framework/Apache-Test/lib/Apache/TestRequest.pm
===
RCS file: 
/home/cvs/httpd-test/perl-framework/Apache-Test/lib/Apache/TestRequest.pm,v
retrieving revision 1.71
diff -u -r1.71 TestRequest.pm
--- perl-framework/Apache-Test/lib/Apache/TestRequest.pm4 Apr 2002 
00:54:26 -   1.71
+++ perl-framework/Apache-Test/lib/Apache/TestRequest.pm11 Sep 2002 
09:47:55 -
@@ -386,6 +386,9 @@
 
 unless ($shortcut) {
 #GET, HEAD, POST
+if ($r-method eq POST  !defined($r-header(Content-Length))) {
+$r-header('Content-Length' = length($r-content));
+}
 $r = $UA ? $UA-request($r) : $r;
 my $proto = $r-protocol;
 if (defined($proto)) {


POST with no data

2002-09-10 Thread Gary Benson
Hi all,

I've been trying to write some tests and have been trying to send POST
requests with no body.  It seems that Apache::TestRequest::POST only
adds a Content-Length when the length of the content is nonzero, so
attempts to 'POST /foo/bar, ' result in a 411 Length Required from
httpd.

I'm not nearly good enough with Perl to work out where POST is defined;
can anyone point me in the direction of what I need to change to cause a
content-length to be added to all POST requests?

Cheers,
Gary

[ [EMAIL PROTECTED] ][ GnuPG 85A8F78B ][ http://inauspicious.org/ ]