All,

I recently sent the following message to Lincoln Stein, author of
CGI.pm. Lincoln offered to change his documentation to reflect the
problem that I uncovered.

But before I recommend that he do this, I thought I'd run this by you
folks. In a nutshell, has anyone been able to to achieve NPH-like
behavior with IIS *without* prepending `nph-' to the name of the file
containing the script?

At the very least, I have uncovered two articles in the MS Knowledge
base that relate to this problem. Thought it might be nice to mention
them in this list for archival purposes. --David

                             # # #

Lincoln,

Over the past couple of days, I have stumbled onto some difficulties
with IIS and NPH, redirects and cookies, and I want to share them with
you. From the CGI.pm documentation:

    http://stein.cshl.org/WWW/software/CGI/#nph  (Version 2.752)

    ``The Macintosh WebSTAR server and Microsoft's Internet Information
    Server, in contrast, try to decide whether a program is an NPH script
    by examining the first line of script output.''

For CGI scripts on IIS 3/4/5, this does *not* appear to be true. It
appears that you *must* use an `nph-' prefix on the name of your
script to accomplish NPH behavior. This seems to be supported by the
following Microsoft Knowledge Base article:

    BUG: Set-Cookie Is Ignored in CGI When Combined With Location
    (applies to IIS 3.0, 4.0, 5.0)

      http://support.microsoft.com/support/kb/articles/Q176/1/13.ASP

    Excerpt:
    
    ``To allow a cookie to be set in a 302 response, use code similar
    to the following, and prefix "nph-" to the name of the executable
    file:

      <code example omitted>

    The output is similar to the following. Note that the cookie is
    now sent, and no headers are added by the server.''

Unfortunately, there is *another* IIS bug on Windows NT that breaks
NPH scripts after service pack 6 has been applied:

    Non-Parsed Headers Stripped From CGI Applications That Have
    nph- Prefix in Name (applies to IIS 4.0)

      http://support.microsoft.com/support/kb/articles/Q280/3/41.ASP

So, without applying the patch mentioned in the above article, CGI NPH
scripts *do not work at all*. (The patch is not available for public
download; one must call Microsoft to get it.)

Now, my original problem: setting a cookie and immediately
redirecting. (I found a large number of posts at groups.google.com
regarding this problem with IIS, but no satisfactory answers.)

Without applying the IIS 4 patch and appending a `nph-' prefix to the
script, this does not work:

    print
      $query->redirect(
        -nph => 1,
        -cookie => $cookie,
        -url => 'target.pl',
       );

Here's what I came up with as an alternative:

    print
      $query->header(
        -expires => 'now',
        -cookie => $cookie,
        -refresh=>'0; URL=target.pl',
      ),
      $query->start_html('Redirect'),  # Netscape 4.7x wants a document
      $query->end_html;

One final note. As an alternative to CGI, I *have* been able to
demonstrate proper NPH-like behavior on IIS using ActiveState's ISAPI
Perl interface.

Thanks for writing such a fantastic module, and bearing with this
lengthy message!

--David Rosinger

_______________________________________________
Perl-Win32-Web mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-web

Reply via email to