I'm trying to figure out how to make readfile() or include() work more like a server-side #include, in terms of HTTP headers.

I'm taking some web pages that used server-side includes, that in turn invoked CGI scripts, and replacing these pages with PHP pages. For the most part, I don't need a lot of the old CGI code anymore, but I'd still like to be able to invoke a CGI from a PHP page with similar results as when I did the same thing with SSI.

The problem that I'm seeing is with HTTP headers. When I use the readfile() or include() functions in PHP, PHP seems to creating its own new headers, rather than passing along the headers from its own environment.

As an example of what I'm talking about, here's a CGI that displays, among other things, the HTTP headers that your web browser provides:

http://www.shetline.com/cgi-bin/serverinfo.cgi

When I directly invoke the above from my browser, to no surprise at all I get this result:

HTTP_USER_AGENT: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)

When I try to use readfile() or include(), however, what I get back
is:

HTTP_USER_AGENT: PHP/4.2.3

PHP is supplying its own user agent, rather than the user agent that invoked the PHP page in the first place. Here's what the test page source looks like (from http://www.shetline.com/testphp.php):

   <html>
   <head>
   <title>PHP Test</title>
   </head>
   <body bgcolor=white>
   <br>
   <%
      readfile("http://www.shetline.com/cgi-bin/serverinfo.cgi";);
   %>
   <br>
   </body>
   </html>

Below is an example of a page using SSI, that produces the desired
result:

   <html>
   <head>
   <title>SSI Test</title>
   </head>
   <body bgcolor=white>
   <br>
      <!--#include virtual="cgi-bin/serverinfo.cgi"-->
   <br>
   </body>
   </html>

Is there any way, short of getting down to sockets and hard-coding the whole transaction, to get readfile(), include(), or something else that's relatively painless, to pass on the same HTTP environment that my PHP page operates within to a page that my PHP page invokes?


-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to