RE: Content-Disposition

2012-01-22 Thread cfaust-dougot
I'm all set, I had to use err_headers_out for some reason so,
 
$r-err_headers_out-add('Content-Disposition' = 'attachment; filename=' . 
$download_name . '');
 
Works.
 
-Chris



From: cfaust-dougot [mailto:cfa...@doyougot.com]
Sent: Sun 1/22/2012 6:20 AM
To: Earle Ake; modperl@perl.apache.org
Subject: RE: Content-Disposition


Thanks for the reply Earle, I actually did try both attachment and inline 
and neither worked (I should have said that in the org post).
 
-Chris



From: Earle Ake [mailto:e...@woh.rr.com]
Sent: Sat 1/21/2012 9:19 PM
To: cfaust-dougot; modperl@perl.apache.org
Subject: RE: Content-Disposition



I have done it before using something like:

 

print Content-Disposition:attachment;filename=$download_name\n;

 

So maybe try:

 

$r-header_out( 'Content-Disposition' = 'attachment; filename=' . 
$download_name . '');

 

 



From: cfaust-dougot [mailto:cfa...@doyougot.com] 
Sent: Saturday, January 21, 2012 7:02 PM
To: modperl@perl.apache.org
Subject: Content-Disposition

 

Hello,

 

I'm guessing there is a real simple answer to my question but as uasual, I 
can't find it :)

 

Simply put I'm trying to create a Zip file and push it to the user using a 
filename I've defined. Everything works except the name of the file that comes 
up in the browser dialog. It always defaults to the script/location name. I 
thought that all I needed was Content-Disposition but that doesn't seem to be 
working.

 

CentOS 5.5, mod_perl 2.0.4, apache 2.2.3 (both mod_perl and apache should be 
backported via yum update).

 

my $zip = Archive::Zip-new();

my $member = $zip-addString('yadda yadda yadda');

my $download_name = 'download.zip';

if ( $zip-writeToFileNamed('someothernamed.zip');

open(ZIP, 'someothernamed.zip') or die could not open sonz $!;

binmode ZIP;

my $output = do { local $/; ZIP };

close(ZIP);

$r-content_type('application/zip');

$r-header_out( 'Content-Disposition' = 'inline; filename=' . 
$download_name . '');

$r-send_http_header;

print $output;

return Apache2::Const::OK;

}

 

I tried setting the header before the content_type and with and without 
send_http_header. What am I doing wrong? How can I get the user to be 
prompted to save the file as download.zip??

 

TIA!

 

 



RE: Content-Disposition

2012-01-21 Thread Earle Ake
I have done it before using something like:

 

print Content-Disposition:attachment;filename=$download_name\n;

 

So maybe try:

 

$r-header_out( 'Content-Disposition' = 'attachment; filename=' .
$download_name . '');

 

 

  _  

From: cfaust-dougot [mailto:cfa...@doyougot.com] 
Sent: Saturday, January 21, 2012 7:02 PM
To: modperl@perl.apache.org
Subject: Content-Disposition

 

Hello,

 

I'm guessing there is a real simple answer to my question but as uasual, I
can't find it :)

 

Simply put I'm trying to create a Zip file and push it to the user using a
filename I've defined. Everything works except the name of the file that
comes up in the browser dialog. It always defaults to the script/location
name. I thought that all I needed was Content-Disposition but that doesn't
seem to be working.

 

CentOS 5.5, mod_perl 2.0.4, apache 2.2.3 (both mod_perl and apache should be
backported via yum update).

 

my $zip = Archive::Zip-new();

my $member = $zip-addString('yadda yadda yadda');

my $download_name = 'download.zip';

if ( $zip-writeToFileNamed('someothernamed.zip');

open(ZIP, 'someothernamed.zip') or die could not open sonz $!;

binmode ZIP;

my $output = do { local $/; ZIP };

close(ZIP);

$r-content_type('application/zip');

$r-header_out( 'Content-Disposition' = 'inline; filename=' .
$download_name . '');

$r-send_http_header;

print $output;

return Apache2::Const::OK;

}

 

I tried setting the header before the content_type and with and without
send_http_header. What am I doing wrong? How can I get the user to be
prompted to save the file as download.zip??

 

TIA!

 

 



RE: Content Disposition header and file contents sequence...

2006-03-02 Thread John N. Brahy
Just as I give up and email the list 

I figured out that the database wasn't returning the filename so it
wasn't able to open the file for download so when I hard coded a
filename it started working. The thing I don't understand is why didn't
I get a server error when it wasn't able to open a file... 



 -Original Message-
 From: John N. Brahy [mailto:[EMAIL PROTECTED]
 Sent: Thursday, March 02, 2006 10:46 AM
 To: modperl@perl.apache.org
 Subject: Content Disposition header and file contents sequence...
 
 This is the relevant part of my handler for a link that I want to
force
 a download for. I know it's content-disposition but for some reason I
 can not get it to actually download the file. I get the download
dialog
 and I choose the location to save it but when I open the document it
is
 empty. I've tried changing the sequence of the items but it never
works.
 
 
 my $filename = /usr/local/app/media/videos/downloads/preview.mov;
 unless ($fileFH = Apache::File-new($filename)){
   $r-log_error(couldn't open $filename for reading: $!);
   return SERVER_ERROR;
 }
 $r-content_type('video/quicktime');
 $r-headers_out-set('Content-Disposition' =
 attachment;filename=$downloadFilename);
 $r-send_fd($fileFH);
 $r-send_http_header();
 return OK;
 
 
 
 
 
 : John Brahy
 : CIO
 : www.ad2.com
 
 : [EMAIL PROTECTED]
 : t: 310-356-7500
 : f: 310-356-7520
 
 : ad2, Inc.
 : 1990 East Grand Ave, Suite 200
 : El Segundo, CA 90245



Re: content-disposition not recognized

2004-11-19 Thread Stas Bekman
Micah Johnson wrote:
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:
Location /cgi-perl
   SetHandler perl-script
   PerlResponseHandler ModPerl::PerlRun
   PerlOptions +ParseHeaders
   Options ExecCGI
/Location
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].
Any suggestions on how to fix this?
Unrelated, better upgrade to the latest 1.99_17, to avoid problems that 
were already fixed.

--
__
Stas BekmanJAm_pH -- Just Another mod_perl Hacker
http://stason.org/ mod_perl Guide --- http://perl.apache.org
mailto:[EMAIL PROTECTED] 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: 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 Stas Bekman
Micah Johnson wrote:
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.
As soon as you send some content to the client, Apache sends the headers 
immediately (since there is no send_http_header() in Apache 2.0). So when 
you do:

print q[Content-type: text/plain\n];
Apache sends httpd headers right away, before it sees extra headers.
By making the output buffered $! (which is the case by default) you delay 
sending the data out, till the 8K buffer is filled (or the request is 
completed). But it's probably a better practice to send the header at once 
as I've suggested, rather than relying on the buffering feature.

--
__
Stas BekmanJAm_pH -- Just Another mod_perl Hacker
http://stason.org/ mod_perl Guide --- http://perl.apache.org
mailto:[EMAIL PROTECTED] 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: content-disposition not recognized

2004-11-19 Thread Stas Bekman
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='?

--
__
Stas BekmanJAm_pH -- Just Another mod_perl Hacker
http://stason.org/ mod_perl Guide --- http://perl.apache.org
mailto:[EMAIL PROTECTED] 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: 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



Re: content-disposition not recognized

2004-11-19 Thread Stas Bekman
Micah Johnson wrote:
--- 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.
My apologies, you can't use q[] with \n, it must be qq[]. So this should 
work:
print qq[Content-type: text/plain\n] .
qq[Content-Disposition: attachment;filename=results.xml\n\n].
or even more readable:
print END;
Content-type: text/plain
Content-Disposition: attachment;filename=results.xml
END
--
__
Stas BekmanJAm_pH -- Just Another mod_perl Hacker
http://stason.org/ mod_perl Guide --- http://perl.apache.org
mailto:[EMAIL PROTECTED] 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