[mp2] CONTENT_LENGTH & input filter

2004-05-03 Thread Micah Johnson
Hi,

I'm trying to use a pre-existing CGI script without
modification.  I'd like to use an input filter to tack
on something to the POST string.  My filter adds the
string, but the CGI sees a CONTENT_LENGTH
environmental variable that corresponds to its
original length.  How do I update the CONTENT_LENGTH?

Here's the filter code:

  package MyApache::AddConstraint;

  use strict;
  use warnings;

  use base qw(Apache::Filter);

  use Apache::Const -compile => 'OK';

  use constant BUFF_LEN => 1024;

  sub handler : FilterRequestHandler {
  my $f = shift;
 
  while ($f->read(my $buffer, BUFF_LEN)) {
  $f->print($buffer);
  }
  my $bparam = "&special=1";
  $f->print($bparam);
 
  Apache::OK;
  }
  1;

The relevant conf is:


  SetHandler perl-script
  PerlHandler ModPerl::PerlRun
  Options ExecCGI
  PerlSendHeader On


PerlModule MyApache::AddConstraint

 PerlInputFilterHandler MyApache::AddConstraint


I've tried setting %ENV in my filter, setting
CONTENT_LENGTH with $f->r->subprocess_env, and using
headers_out->set('Content-Length').  In the first two
cases, I see no effect, while the last applies to the
length of the entire request, not just the POST
string.
Any help is appreciated.

Thanks,
Micah







__
Do you Yahoo!?
Win a $20,000 Career Makeover at Yahoo! HotJobs  
http://hotjobs.sweepstakes.yahoo.com/careermakeover 

-- 
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



content-disposition not recognized

2004-11-19 Thread Micah Johnson
I am having difficulty sending an XML file to the
browser using the Content-Disposition: attachment
header.

I am running mod_perl/1.99_13 and trying to use an
existing cgi script which returns data in various
forms.  One is an XML file.  The script is found in a
directory setup like this:


   SetHandler perl-script
   PerlResponseHandler ModPerl::PerlRun
   PerlOptions +ParseHeaders
   Options ExecCGI


and the script prints headers like this:

print "Content-type: text/plain\n";
print "Content-Disposition: attachment;
filename=results.xml\n\n";

The resulting file reports a server error 500,
premature end of script headers and the
content-disposition line is displayed, so it looks
like it is not being treated as a header.

Any suggestions on how to fix this?

Thanks,
Micah Johnson




__ 
Do you Yahoo!? 
Meet the all-new My Yahoo! - Try it today! 
http://my.yahoo.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: content-disposition not recognized

2004-11-19 Thread Micah Johnson

> > and the script prints headers like this:
> > 
> > print "Content-type: text/plain\n";
> > print "Content-Disposition: attachment;
> > filename=results.xml\n\n";
> > 
> > The resulting file reports a server error 500,
> > premature end of script headers and the
> > content-disposition line is displayed, so it looks
> > like it is not being treated as a header.
> 
> Try to add:
> 
>local $| = 0;
> 
> before sending headers, or send the header at once:
> 
> print q[Content-type: text/plain\n] .
> q[Content-Disposition:
> attachment;filename=results.xml\n\n].

Thanks!
The local $| = 0 trick works.  Would you mind
explaining what is happening?  FYI, putting the
headers on one print doesn't seem to fix it.

--Micah



__ 
Do you Yahoo!? 
The all-new My Yahoo! - Get yours free! 
http://my.yahoo.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: content-disposition not recognized

2004-11-19 Thread Micah Johnson

--- Stas Bekman <[EMAIL PROTECTED]> wrote:

> Micah Johnson wrote:
> [...]
> >>print q[Content-type: text/plain\n] .
> >>q[Content-Disposition:
> >>attachment;filename=results.xml\n\n].
> > 
> > 
> > Thanks!
> > The local $| = 0 trick works.  Would you mind
> > explaining what is happening?  FYI, putting the
> > headers on one print doesn't seem to fix it.
> 
> Micah, please describe the outcome with the second
> approach. Do you still 
> get 500 or just the headers are wrong? should there
> be a white space 
> before 'filename='?

I inherited this CGI and just tried to make it work
as-is.  If I put it all in one line and remove all the
whitespace, it works without the buffering trick.

Thanks again, you da man,
Micah



__ 
Do you Yahoo!? 
Meet the all-new My Yahoo! - Try it today! 
http://my.yahoo.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