Solved

Perl outputs html instead of xml on new server  (Cache-Control: no-store, no-cache, must-revalidate)

Posted on 2009-05-07
14
331 Views
Last Modified: 2012-05-06
I have attached output of test.pl on both servers, script causing problems and the correct output on old server and also the html output on new server.


 This is only differerence I can see on new server  is this line beside the OS and 64bit and LWP : v5.803  on old and  LWP : v5.805 on new

is this line of perl test
"& /etc/httpd"

What is the remedy???
see attached perl scripts, output generated on both servers and the output of test.pl on both servers

 this is the extra code that is produced in perl output on new server

"

Cache-Control: no-store, no-cache, must-revalidate

Pragma: no-cache

Content-Type: text/xml; charset=ISO-8859-1 "

Open in new window

experts.zip
0
Comment
Question by:webguy62
  • 7
  • 7
14 Comments
 
LVL 39

Expert Comment

by:Adam314
Comment Utility
What version of the CGI module are you using on both servers?  What webserver are you using on both servers?

The extra text isn't part of the XML, it's part of the HTTP protocol.
0
 

Author Comment

by:webguy62
Comment Utility
NEW:

Operating system Centos 5  

Perl : v5.008008
httpd 2.2.3-11.el5_2.centos.4  
mod_perl 2.0.2-6.3.el5  
mysql 5.0.45-7.el5  
CGI::Carp



 OLD

OS Fedora
httpd 2.0.54-10.4  
mod_perl 2.0.1-1.fc4  
mysql 4.1.20-1.FC4.1  
Perl : v5.008006
0
 
LVL 39

Expert Comment

by:Adam314
Comment Utility
Check the CGI module version with this (notice the use of single and double qoutes... you should cut/paste to get it exactly):
    perl -MCGI -e 'print "$CGI::VERSION\n"'
0
 

Author Comment

by:webguy62
Comment Utility
new 3.15
old 3.10

I have fuidn some changes in apache 2.2 vs 2.0  but none that wil affect this script?
0
 
LVL 39

Expert Comment

by:Adam314
Comment Utility
How did you generate the files in the zip file?  The gsur_pl.txt script does not appear to have generated any of the attached files.
0
 
LVL 39

Expert Comment

by:Adam314
Comment Utility
It appears that you are using $USERID to manage a session.  If this is the case, you should consider using the CGI::Session module, which makes session management very easy.

Also, you might want to consider using one of the template modules designed for HTML.
0
 

Author Comment

by:webguy62
Comment Utility
thje gsur_pl.txt generates  this xml which is good - <markers>
  <results count="3" longitude="-75.953813333333" latitude="39.800456333333" />
  <marker i="0" lat="39.803396" lng="-75.955323" id="5486136" price="1,200.0" city="OXFORD" property_type="Commercial" beds="" baths="OneBath" address="247 REEDVILLE" ph="1" />
  <marker i="1" lat="39.800474" lng="-75.954889" id="5483128" price="375,000.0" city="OXFORD" property_type="Commercial" beds="" baths="" address="1895 BALTIMORE" ph="0" />
  <marker i="2" lat="39.797499" lng="-75.951228" id="5332915" price="1,900,000.0" city="OXFORD" property_type="Commercial" beds="" baths="" address="355 REEDVILLE" ph="10" />
  </markers>


but on new server with newer verions of apache it adds this text at the top of output  


Cache-Control: no-store, no-cache, must-revalidate
Pragma: no-cache
Content-Type: text/xml; charset=ISO-8859-1
0
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
LVL 39

Expert Comment

by:Adam314
Comment Utility
The gsur_pl.txt from your zip file doesn't generate that XML, it generates an html page.
0
 

Author Comment

by:webguy62
Comment Utility
exacty and this is the problem. but on our old server it did genrate an xml page.     What do we need to do to change ti so it generates an xml on new server?

 see example links of 2 different servers exectuing same script.    We found that when "RewriteEngine on" is on in htaccess the perl script gives error of access denied. when rewrite rule is set to off we dont get  access denied error. but the output of the perl file is not proper, the file headers are not correct.
like in the link below. This file gives html output instead of xml.
 
http://www.simplechoicerealty.com/gdata.pl?siteid=chris&userid=680&search=yes&surid=5486136&radius=2&ptype=Commercial
 
The same code on old server gives the out put as XML file, like in the link below.whiich is what we need
 
http://carr.re-data.org/gdata.pl?siteid=chris&userid=680&search=yes&surid=5486136&radius=2&ptype=Commercial
 
We tried to make the rewrite rule and perl script work together but still the output is not proper.

below is rewrite rule for new server
RewriteCond %{REQUEST_URI} !^\/?(js|scripts|wysiwyg|design_demo|midas|map|api).*$

RewriteCond %{REQUEST_URI} !^\/?(map|api|admin).*$
RewriteRule   ^([0-9A-Za-z\_-]*)/([0-9A-Za-z\ \_-]*)/?$ index.php?pageid=$1&value=$2 [NS,QSA,L,PT] [E=UID:$1]
RewriteCond %{REQUEST_URI} !^\/?(map|api|admin).*$
RewriteRule   ^([0-9A-Za-z\_\/-]*)(/|\.html|/index\.html|/index\.htm)?$ index.php?pageid=$1 [NS,QSA,L,PT] [E=UID:$1]
0
 

Author Comment

by:webguy62
Comment Utility
In other words this same gsur_pl.txt gives us different out put on 2 different servers. WE need it to give us  xml resutls on new server :)  the new server has newer version of apache and cgi as noted in past remarks.  I could not find anything in apache changes that would cause this
0
 
LVL 39

Expert Comment

by:Adam314
Comment Utility
attach your index.php file.
0
 

Author Comment

by:webguy62
Comment Utility
below is index.php and I think I know where you are going with this so I inclulded the config file as an upload

<?PHP
####################################    
# File Name: includes/index.php    
# Index file for the user site, this will render full view of the site
####################################

ini_set("memory_limit","64M");

//ini_set("display_errors","2");
//ERROR_REPORTING(E_ALL);

//print_r($_REQUEST);

include("includes/config.inc.php");
include(DIR_CLASSES."/global.class.php");

include(DIR_CLASSES."/clsMasterData.class.php");

include(DIR_CLASSES."/clsCurrentPage.class.php");
include(DIR_CLASSES."/clsBuildPanels.class.php");
include(DIR_CLASSES."/clsBuildHeader.class.php");
//include(DIR_CLASSES."/clsBuildFooter.class.php");
include(DIR_CLASSES."/clsDisplaySite.class.php");


if($_REQUEST['pageid'])
      $pageId = $_REQUEST['pageid'];
else
      $pageId = '2';


/*---------------------------Load master data------------------------------*/

$hdlMasterData = new clsMasterData($hdlDb,$pageId);
$pageType = $hdlMasterData->arrSiteMasterData['pageType'];

/*---------------------------Built current page------------------------------*/
$hdlCurrentPage = new clsCurrentPage($hdlDb, $pageId, $hdlMasterData->arrSiteMasterData);

/*---------------------------Built panels ------------------------------*/
$hdlBuildPanels = new clsBuildPanels($hdlDb, $pageId);

/*---------------------------Built header ------------------------------*/
$hdlBuildHeader = new clsBuildHeader($hdlDb,$pageId);

/*---------------------------Built Footer ------------------------------*/

/*---------------------------Built Template ------------------------------*/
#$hdlSitePanels['left'] = $hdlBuildPanels->fnGeneratePanels("left");
#$hdlSitePanels['right'] = $hdlBuildPanels->fnGeneratePanels("right");  

$hdlDisplaySite = new clsDisplaySite($hdlDb,$hdlCurrentPage->strPageContent,
                                                      $hdlSitePanels,
                                                      $hdlMasterData->arrSiteMasterData,
                                                      $hdlBuildHeader->headerImage,
                                                      $hdlBuildHeader->strMenu,
                                                      $hdlBuildHeader->strFooterMenu,
                                                      $hdlBuildHeader->pageFlashHeader,
                                                      $pageType,
                                                      $hdlBuildHeader->strVillaMenu,
                                                      $hdlCurrentPage->strVillaContent,
                                                      $hdlBuildHeader->strMultiLang,
                                                      $hdlBuildHeader->strDisplayTime
                                                      );

/*---------------------------Display Template ------------------------------*/

print $hdlDisplaySite->showHTML;

?>
config-inc-php.txt
0
 
LVL 39

Accepted Solution

by:
Adam314 earned 500 total points
Comment Utility

header('Content-type: text/xml');   #New line

print $hdlDisplaySite->showHTML;    #existing line

Open in new window

0
 

Author Closing Comment

by:webguy62
Comment Utility
it works  thanks big time...
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (http://dilbert.com/strips/comic/2007-08…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now