Hello esteemed monks,

I'm writing my first CGI::Application web app and I'm having some growing pains for which I was hoping someone could help. It works great on my Apache test setup on my own work box. It blows chunks when I try to use it on the IIS5 box on which my boss wants me to put it.

The problem is similar to this: How can I remove HTTP Header . I have headers in a single line printing out along the top of my page... however, unlike the aforementioned node, this isn't happening all the time. From what I can see, it's only happening when I POST a form or attempt to redirect.

This webapp was developed on my WinXP box using Apache 2.0 as my test webserver and Perl 5.8.6. It uses CGI::Application (C::A) but I've overridden it to use CGI::Simple instead of CGI as per this tip in the C::A Wiki like so:

sub cgiapp_get_query { my $self = shift; require CGI::Simple; my $q = CGI::Simple->new(); return $q; }

Unfortunately, I've gotta move this bad-boy to a Win2k box running IIS5 (also Perl 5.8.6). It's not using the ISAPI plugin for Perl. (Is that a factor?)

I'm aware of the nph header setting and I'm setting the CGI::Simple query object to nph like so in the setup() method (even though the docs say that I need not do so because CGI::Simple auto-detects IIS):

$self->query()->nph(1);

I'm doing redirects in my run_modes just like the C::A documentation tells me like this:

$self->header_type('redirect'); $self->header_props( -url => $newurl ); return;

The redirects in Firefox and IE are both causing a download of the redirect headers as a text file instead of actually redirecting me. The form submission is also causing a download in FireFox but in IE I get a printout of the headers at the top of the page in one line like so:

HTTP/1.0 200 OK Server: Microsoft-IIS/5.0 Date: Fri, 19 Aug 2005 02:42 +:29 GMT Content-Type: text/html; charset=ISO-8859-1

Sorry if this seemed a little long winded but I'm trying to provide as much as possible. So, I understand the concept of NPH... what I don't get is how this beahviour seems to be busting me up only some times and not all the time. (Can't ANYTHING be black and white anymore? Hmmm... I must be growing up if everything is in shades of gray.)

Has anyone else had this selective behaviour? Do I need to explicitly set some more headers somewhere? Is this something to do with CGI::Simple's NPH support? All help is welcome and if anyone want's more detail, I'll give it. None of the other nodes I've come across here seem to cover this. All I'm looking for now is a direction to investigate in because I'm plain stumped. My apologies if this is isn't "perlish" enough but I'm not sure where else to turn.

Many Thanks,
Meraxes

Update: Okay, I've got redirects working. It seems that when I was using the header_props() to set the type to redirect I think I was wiping out the -nph setting. I've corrected this. However, I still have a problem when I process a POST request. The result page is still spitting out the headers. The output page is using no special headers at all. Any help appreciated.

Update the second: I'm an idiot. hakkr got me looking in the right direction. I'm not printing out headers ahead of CGI::Application... but I was printing some diagnositic info to STDERR. Apache throws that into it's erorr log, IIS just spews EVERYTHING out. Many thanks for the help.


In reply to Header problem with IIS, C::A and CGI::Simple by meraxes

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.