You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Jeff Finn <js...@yahoo.com> on 2004/03/15 22:13:39 UTC
[mp2] Trouble with Apache::Filter input and mod_dav
Hi,
I'm trying to write an input filter that will read the request body data, do
some transformation, and then write the output to a file using mod_dav:
<Location /davtest/>
DAV on
PerlInputFilterHandler FileDataLog::input
</Location>
The problem I'm having is that whenever I try to PUT a file that contains
null characters (\0), the data that's written to the file is not the data
that is printed from the filter. I've set up a basic filter to simply send
the data it reads on to the next stage in order to troubleshoot:
while($f->read(my $buffer, 16)) {
print STDERR unpack('H*', $buffer), "\n";
$f->print($buffer)
}
but I can't seem to get it to work. Here is an example via a telnet
session:
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
PUT /members/jeff/test HTTP/1.1
Host: 127.0.0.1:9080
Content-Length: 11
123^A456^@7890
HTTP/1.1 204 No Content
Date: Mon, 15 Mar 2004 20:51:26 GMT
Server: Apache/2.0.48 (Unix)
Content-Length: 0
Connection: close
Content-Type: text/plain; charset=ISO-8859-1
The filter seems to be sending the correct data along:
[root@localhost jeff]# tail /usr/local/apache2/logs/error_log
3132330134353600373839
1 2 3 \1 4 5 6 \0 7 8 9
but the file does not have the correct data:
[root@localhost jeff]# od -x test
0000000 3231 0133 3534 0036 0001 0000
0000013
Any help would be greatly appreciated.
--
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html
RE: [mp2] Trouble with Apache::Filter input and mod_dav
Posted by Jeff Finn <js...@yahoo.com>.
Thanks. This fixes the problem I was having.
Jeff
-----Original Message-----
From: Stas Bekman [mailto:stas@stason.org]
Sent: Monday, March 15, 2004 7:52 PM
To: Stas Bekman
Cc: Jeff Finn; modperl@perl.apache.org
Subject: Re: [mp2] Trouble with Apache::Filter input and mod_dav
Stas Bekman wrote:
> Jeff Finn wrote:
>
>> Hi,
>>
>> I'm trying to write an input filter that will read the request body
>> data, do
>> some transformation, and then write the output to a file using mod_dav:
>>
>> <Location /davtest/>
>> DAV on
>> PerlInputFilterHandler FileDataLog::input
>> </Location>
>>
>> The problem I'm having is that whenever I try to PUT a file that contains
>> null characters (\0), the data that's written to the file is not the
>> data
>> that is printed from the filter.
[...]
Jeff,
The patch below should fix the problem. It'll be in cvs shortly. Please
confirm that it worked for you.
Index: src/modules/perl/modperl_filter.c
===================================================================
RCS file: /home/cvs/modperl-2.0/src/modules/perl/modperl_filter.c,v
retrieving revision 1.86
diff -u -r1.86 modperl_filter.c
--- src/modules/perl/modperl_filter.c 4 Mar 2004 06:01:07 -0000 1.86
+++ src/modules/perl/modperl_filter.c 16 Mar 2004 00:50:30 -0000
@@ -783,7 +783,7 @@
apr_size_t *len)
{
apr_bucket_alloc_t *ba = filter->f->c->bucket_alloc;
- char *copy = apr_pstrndup(filter->pool, buf, *len);
+ char *copy = apr_pmemdup(filter->pool, buf, *len);
apr_bucket *bucket = apr_bucket_transient_create(copy, *len, ba);
/* MP_TRACE_f(MP_FUNC, "writing %d bytes: %s\n", *len, copy); */
MP_TRACE_f(MP_FUNC, MP_FILTER_NAME_FORMAT
--
__________________________________________________________________
Stas Bekman JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/ mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org http://ticketmaster.com
--
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html
Re: [mp2] Trouble with Apache::Filter input and mod_dav
Posted by Stas Bekman <st...@stason.org>.
Stas Bekman wrote:
> Jeff Finn wrote:
>
>> Hi,
>>
>> I'm trying to write an input filter that will read the request body
>> data, do
>> some transformation, and then write the output to a file using mod_dav:
>>
>> <Location /davtest/>
>> DAV on
>> PerlInputFilterHandler FileDataLog::input
>> </Location>
>>
>> The problem I'm having is that whenever I try to PUT a file that contains
>> null characters (\0), the data that's written to the file is not the
>> data
>> that is printed from the filter.
[...]
Jeff,
The patch below should fix the problem. It'll be in cvs shortly. Please
confirm that it worked for you.
Index: src/modules/perl/modperl_filter.c
===================================================================
RCS file: /home/cvs/modperl-2.0/src/modules/perl/modperl_filter.c,v
retrieving revision 1.86
diff -u -r1.86 modperl_filter.c
--- src/modules/perl/modperl_filter.c 4 Mar 2004 06:01:07 -0000 1.86
+++ src/modules/perl/modperl_filter.c 16 Mar 2004 00:50:30 -0000
@@ -783,7 +783,7 @@
apr_size_t *len)
{
apr_bucket_alloc_t *ba = filter->f->c->bucket_alloc;
- char *copy = apr_pstrndup(filter->pool, buf, *len);
+ char *copy = apr_pmemdup(filter->pool, buf, *len);
apr_bucket *bucket = apr_bucket_transient_create(copy, *len, ba);
/* MP_TRACE_f(MP_FUNC, "writing %d bytes: %s\n", *len, copy); */
MP_TRACE_f(MP_FUNC, MP_FILTER_NAME_FORMAT
--
__________________________________________________________________
Stas Bekman JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/ mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org http://ticketmaster.com
--
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html
Re: [mp2] Trouble with Apache::Filter input and mod_dav
Posted by Stas Bekman <st...@stason.org>.
Jeff Finn wrote:
> Hi,
>
> I'm trying to write an input filter that will read the request body data, do
> some transformation, and then write the output to a file using mod_dav:
>
> <Location /davtest/>
> DAV on
> PerlInputFilterHandler FileDataLog::input
> </Location>
>
> The problem I'm having is that whenever I try to PUT a file that contains
> null characters (\0), the data that's written to the file is not the data
> that is printed from the filter. I've set up a basic filter to simply send
> the data it reads on to the next stage in order to troubleshoot:
>
> while($f->read(my $buffer, 16)) {
> print STDERR unpack('H*', $buffer), "\n";
> $f->print($buffer)
> }
>
> but I can't seem to get it to work. Here is an example via a telnet
> session:
>
> Trying 127.0.0.1...
> Connected to localhost.
> Escape character is '^]'.
> PUT /members/jeff/test HTTP/1.1
> Host: 127.0.0.1:9080
> Content-Length: 11
shouldn't this be 12 ;)
> 123^A456^@7890
> HTTP/1.1 204 No Content
> Date: Mon, 15 Mar 2004 20:51:26 GMT
> Server: Apache/2.0.48 (Unix)
> Content-Length: 0
> Connection: close
> Content-Type: text/plain; charset=ISO-8859-1
>
>
> The filter seems to be sending the correct data along:
> [root@localhost jeff]# tail /usr/local/apache2/logs/error_log
> 3132330134353600373839
>
> 1 2 3 \1 4 5 6 \0 7 8 9
> but the file does not have the correct data:
>
> [root@localhost jeff]# od -x test
> 0000000 3231 0133 3534 0036 0001 0000
> 0000013
>
> Any help would be greatly appreciated.
I've reproduced the problem, please stay tuned for the fix.
__________________________________________________________________
Stas Bekman JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/ mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org http://ticketmaster.com
--
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html