473,385 Members | 1,470 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,385 software developers and data experts.

CGI header problem

rajiv07
141 100+
Hi to all

I have a script to get geo IP which is successfully running on Linux server.but when i run this script on windows server it gives some header error

Expand|Select|Wrap|Line Numbers
  1. #!C:/Perl/bin/perl.exe
  2. use CGI qw/:standard/;
  3. use LWP::UserAgent;
  4. use HTTP::Request qw(GET POST);
  5. use HTTP::Headers;
  6.  
  7. use CGI::Cookie;
  8. use CGI::Session;
  9.  
  10. use CGI::Carp qw(fatalsToBrowser);
  11.  
  12. my $q=new CGI;
  13.  
  14. my $c=new CGI::Cookie;
  15.  
  16. my $cIP = $ENV{'REMOTE_ADDR'} ;
  17.  
  18. # replace this value with license key
  19. my $license_key ="key";
  20.  
  21.  
  22. my $ua = LWP::UserAgent->new(timeout =>10);
  23.  
  24. my $h = HTTP::Headers->new;
  25.  
  26. $h->content_type('application/x-www-form-urlencoded');
  27.  
  28. my $request = HTTP::Request->new('POST','http://maxmind.com:8010/a',
  29.                                  $h,"l=$license_key&i=$cIP");
  30. my $res = $ua->request($request);
  31.  
  32. my $content = $res->content;
  33. #print "Content-type: text/html\n\n" ;
  34. ############ again send request    #######
  35. if($content eq "")
  36. {
  37.  sleep(1);
  38.  
  39.  $request = HTTP::Request->new('POST','http://maxmind.com:8010/a', 
  40.                                $h,"l=$license_key&i=$cIP");        
  41.  $res = $ua->request($request);                                    
  42.  
  43.  $content = $res->content;                                         
  44. }
  45. if($content eq "")
  46. {
  47.  sleep(1);
  48.  
  49.  $request = HTTP::Request->new('POST','http://maxmind.com:8010/a', 
  50.                                $h,"l=$license_key&i=$cIP");        
  51.  $res = $ua->request($request);                                    
  52.  
  53.  $content = $res->content;                                         
  54. }
  55. if($content eq "")
  56. {
  57.     $content="Server-Error";
  58. }
  59.  
  60. my $session = "" ;
  61.  
  62. my $sid = "" ;
  63.  
  64. $sid = _Checkcookie();
  65.  
  66. if($sid eq "")
  67. {
  68.  $session = new CGI::Session("driver:File", $q, {Directory=>'/tmp'});
  69.  
  70.  my $server = $ENV{'HTTP_HOST'};
  71.  
  72.  my $path = "/";
  73.  
  74.  $sid = $session->id();
  75.  
  76.  print "Set-Cookie: CGISESSID\=$sid; path\=$path;domain\=$server\n" ;
  77. }
  78. else
  79. {
  80.  $session = new CGI::Session(undef, $sid, {Directory=>'/tmp'});
  81. }
  82.  
  83. my $cFlag = 0 ;
  84.  
  85. my $referer=$q->param('referer');
  86.  
  87. my $albumid=$q->param('albumid');
  88.  
  89. my $action=$q->param('action');
  90.  
  91. my $shopping_info=$session->param('shopping_info');
  92.  
  93. my %shopping_info=%{$shopping_info};
  94.  
  95. $shopping_info{geo}=$content; 
  96.  
  97.  
  98. $session->param("shopping_info",\%shopping_info);
  99.  
  100. $session->expire('+12h');
  101.  
  102. if($action eq "direct"){
  103. #print "location: /cgi-bin/elearning/query/el_alb_details.pl?albumid=$albumid&action=geo\n\n" ;
  104. print "Status: 302 Moved", "\r\n","Location: http://www.mysitename.com/cgi-bin/elearning/query/el_alb_details.pl?albumid=$albumid&action=geo", "\r\n\r\n";
  105. exit;
  106. }
  107.  
  108. print 'Status: 302 Moved', "\r\n",'Location:/cgi-bin/elearning/query/el_show_cat.pl', "\r\n\r\n"; 
  109.  
  110. exit;
  111.  
  112. sub _Checkcookie{
  113.  
  114. my %cookies=fetch CGI::Cookie;
  115.  
  116. my $name=$cookies{CGISESSID};
  117.  
  118. my @temp=split(/CGISESSID\=/,$name);
  119.  
  120. my @temp1=split(/;/,$temp[1]);
  121.  
  122. return $temp1[0];
  123. }
My error

The specified CGI application misbehaved by not returning a complete set of HTTP headers.

Please help on this

Thanks in advance
Rajiv
Jun 18 '08 #1
2 1958
KevinADC
4,059 Expert 2GB
for now do this, change these lines:

Expand|Select|Wrap|Line Numbers
  1. print 'Status: 302 Moved', "\r\n",'Location:/cgi-bin/elearning/query/el_show_cat.pl', "\r\n\r\n";
to:

Expand|Select|Wrap|Line Numbers
  1. print 'Location: http://www.yoursite.com/cgi-bin/elearning/query/el_show_cat.pl', "\r\n\r\n";
and see if that gets the script running. If it does, the problem is in the header your script is printing. If not, I don't know what the problem is.
Jun 18 '08 #2
rajiv07
141 100+
Thanks Kevin,

Actually i am trying to move all script from Linux Server to windows server.No program is work.All script gives the same error.i could not find any problem.But when i run a simple test script its working fine.

My testing script

Expand|Select|Wrap|Line Numbers
  1. #!C:/perl/bin/perl.exe
  2. use CGI qw/:standard/;
  3.  
  4. use CGI::Carp qw(fatalsToBrowser);
  5.  
  6. my $q=new CGI;
  7.  
  8. my $cFlag = 0 ;
  9.  
  10. my $referer=$q->param('referer');
  11.  
  12. my $albumid=$q->param('albumid');
  13.  
  14. my $action=$q->param('action');
  15.  
  16. print $q->header;
  17.  
  18. print "Hello world";
  19.  
  20. exit;
  21.  
  22.  
Is any server configuration fault has involved in this problem.

Plesae suggest me any idea or solution please.

Thanks in advance

Rajiv
Jun 19 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Massimiliano Alberti | last post by:
My program is heavily template based, and I use the VC++, so I have to keep the templates in the header file. My .cpp files are quite empty (they are more a connection between header files). Now,...
11
by: Steven T. Hatton | last post by:
In the past there have been lengthy discussiions regarding the role of header files in C++. People have been very adamat about header files serving as in interface to the implementation. I do...
60
by: Derrick Coetzee | last post by:
It seems like, in every C source file I've ever seen, there has been a very definite include order, as follows: - include system headers - include application headers - include the header...
4
by: Andrew Ward | last post by:
Hi All, I was wondering if it is possible to use precompiled headers without having to include a <stdafx.h> or whatever in every source file. My problem is that I have a project that makes heavy...
0
by: Lokkju | last post by:
I am pretty much lost here - I am trying to create a managed c++ wrapper for this dll, so that I can use it from c#/vb.net, however, it does not conform to any standard style of coding I have seen....
6
by: Peter van der veen | last post by:
Hi I have the following problem. I'm calling a webservice from within a VB.net 2005 Windows program. For this i got a WSDL file and loaded that in VB. Until now i just call the webservice and...
4
by: Joseph Geretz | last post by:
We use a Soap Header to pass a token class (m_Token) back and forth with authenticated session information. Given the following implementation for our Logout method, I vastly prefer to simply code...
3
by: jszczepankiewicz | last post by:
Witam, mam nastepujacy problem: XSLT 2.0, Hi, i've got following problem with xslt 2: my xml doc looks something linke: <manual>
16
by: wdh3rd | last post by:
Hi everyone. I'm new to C and I have a few questions: I am making files for permutations and combinations. Files to be made are perm.c, perm.h, combo.c, and combo.h. Since both combinations...
1
by: Proogeren | last post by:
I have a problem with a httpwebrequest that I am creating. The request in itself looks correct but using fiddler I see that a www-authentication header is sent along as well. The code is pasted...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.