Perl, Oracle, LWP, and PDF's

J

JD Vernon

I'm working on a Perl gatekeeper for report requests on an Oracle web
app

Essentially, the code is:

if (invalid request)
{ burp; }
else
{ print report; }

print report is the last thing not quite working - everything else is
great

here's the problem - if the user requests a PDF version of the report,
if I print "Content-type: application/pdf" before printing the URL,
they get a popup that says "This page contains both secure and
non-secure objects...blahblahblah" and it doesn't matter if they
select Yes or No, the report comes up just fine

if I don't include the headers, a 500 Internal Server Error results,
because it tries to grab the content-type headers from the PDF and it
doesn't know what to do with "%PDF-1.1"

include the headers or not, if the user selects the HTML version of
the report, no errors and the report comes up fine

i don't know if it's *what* I'm printing or *that* I'm printing, but
any direction/insight anyone can provide is greatly appreciated

i've included the "print report;" code below

Thanks
JDV

use LWP::UserAgent;
use HTTP::Headers;

$good_url = "https:".$server."ows-bin/rwcgi60.exe?".$in;
my $req = HTTP::Request->new(GET => $good_url);

if ($rep_format eq 'HTML')
{ $req->header('Content-type' => 'text/html');}
if ($rep_format eq 'PDF')
{ $req->header('Content-type' => 'application/pdf');}
if ($rep_format eq 'DELIMITED')
{ $req->header('Content-type' => 'text/plain');}

my $res = $ua->request($req);
$res->header('Content-type' => $req->header('Content-type'));

if ($res->is_success)
{
print 'Content-type: '.$res->header('Content-type');
print "\n\n";
print $res->content;
}
else
{ print "Error: " . $res->status_line . "\n"; }


--
PLEASE NOTE: comp.infosystems.www.authoring.cgi is a
SELF-MODERATED newsgroup. aa.net and boutell.com are
NOT the originators of the articles and are NOT responsible
for their content.

HOW TO POST to comp.infosystems.www.authoring.cgi:
http://www.thinkspot.net/ciwac/howtopost.html
 
T

thumb_42

In comp.infosystems.www.authoring.cgi JD Vernon said:
I'm working on a Perl gatekeeper for report requests on an Oracle web
app

Essentially, the code is:

if (invalid request)
{ burp; }
else
{ print report; }

print report is the last thing not quite working - everything else is
great

here's the problem - if the user requests a PDF version of the report,
if I print "Content-type: application/pdf" before printing the URL,
they get a popup that says "This page contains both secure and
non-secure objects...blahblahblah" and it doesn't matter if they
select Yes or No, the report comes up just fine

For an experiment, try saving the PDF to a file on the server, then in your
request, forget the whole UserAgent stuff. (Comment out the 'use
LWP::UserAgent' and 'use HTTP::Headers;' lines to prove those libraries
aren't used.

Then open the PDF file and send it out. (this would guarantee it has
nothing to do with any "magic" perl is doing in the
"$res->header('Content-type');" bit. You might also just telnet to the
server on port 80 to see if you're given an errant 'Location' header or
something weird like that. (as crazy and unlikey as this sounds, it'd be
nice to rule it out)

If it still gives errors after directly sending out the file, try locating
another PDF some place that doesn't give you the error, or try another
browser.

It could be that the helper application for PDF's triggers the error, could
try setting it to "application/octet-stream" to see if the browser still
chokes on it. (Browser might percieve any type of data that it can't handle
as potentially accessing insecure data, in which case there is very little
you can do about it) I suspect this is the case.

It's probably unlikely, but the browser could be looking at the PDF version
to see if it's capable of using external resources? in that case, you'd
probably have to know about PDF details, perhaps there is an older PDF
standard that doesn't support external linking but still supports your
needs. When you're testing with the "open via file and raw dump to browser"
you could try sending an older PDF to see if that works. (then cross your
fingers you can retrieve the PDF in this older format...)

Are you using a plugin for the PDF or a helper application? If it's a
plugin, try switching to "helper application".

Those are the areas I'd look in, though perhaps not in that order.

Jamie
Thanks
JDV

use LWP::UserAgent;
use HTTP::Headers;

$good_url = "https:".$server."ows-bin/rwcgi60.exe?".$in;
my $req = HTTP::Request->new(GET => $good_url);

if ($rep_format eq 'HTML')
{ $req->header('Content-type' => 'text/html');}
if ($rep_format eq 'PDF')
{ $req->header('Content-type' => 'application/pdf');}
if ($rep_format eq 'DELIMITED')
{ $req->header('Content-type' => 'text/plain');}

my $res = $ua->request($req);
$res->header('Content-type' => $req->header('Content-type'));

if ($res->is_success)
{
print 'Content-type: '.$res->header('Content-type');
print "\n\n";
print $res->content;
}
else
{ print "Error: " . $res->status_line . "\n"; }


--
PLEASE NOTE: comp.infosystems.www.authoring.cgi is a
SELF-MODERATED newsgroup. aa.net and boutell.com are
NOT the originators of the articles and are NOT responsible
for their content.

HOW TO POST to comp.infosystems.www.authoring.cgi:
http://www.thinkspot.net/ciwac/howtopost.html
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,733
Messages
2,569,439
Members
44,829
Latest member
PIXThurman

Latest Threads

Top