473,387 Members | 1,572 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Perl, Oracle, LWP, and PDF's

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

Jul 19 '05 #1
1 4281
In comp.infosystems.www.authoring.cgi JD Vernon <jd**********@hotmail.com> wrote:
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

Jul 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Keith | last post by:
All: What is the difference between Perl (CGI) and PHP (Apache module)? I thought both used servers to direct the user to the appropiate Perl or PHP program in order to execute the program to...
25
by: rbt | last post by:
Are there any plans in the near future to support PDF files in Python as thoroughly and completely as Perl does? http://cpan.uwinnipeg.ca/search?query=pdf&mode=dist I love Python's clean...
1
by: Anju Patel | last post by:
We installed Oracle security patch CPUJan2006 on Feb 23. Today we cannot run our jobs. We are getting following error: install_driver(Oracle) failed: Can't load...
1
by: byrapaneni | last post by:
Hello all; I gathered information from this and several other groups to write a perl & cgi script to display a pdf document. My script works partially and found an issue when testing. Here is...
4
by: billb | last post by:
I installed a perl extension for PHP to use some perl inside my php primarily because I have perl working with oracle and not php and oracle. So I want to use my old perl scripts, and use the...
3
by: hakiran | last post by:
Hello all, I have been using Perl DBI the last 6months or so. I use it extensively with MySQL. But recently i tried to access Oracle DB with it and was having trouble. Any help would be...
3
by: andrewkl | last post by:
hi, I have the following Perl code that inserts a string to an Oracle DB via a stored procedure: #!/usr/local/bin/perl ## Perl v5.8.6 built for sun4-solaris use strict; BEGIN...
1
by: megaman1 | last post by:
I’m trying to connect with perl DBD::Oracle on Windows to Oracle DB (Linux). I compiled the Oracle.dll using the commands “perl Makefile.pl” “nmake” and “nmake install”, but when I try to connect...
3
by: Dick Sutton | last post by:
First of all, I am a rank amateur at Perl. Here is my problem: I have a hundred or more files in a directory on a web server (let's call it 'Library'). Each file is a pdf file and is named...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.