Is there any way, perhaps another function, to change the HTTP headers that PHP sends to a website.

Example
here's a file on my server.
mypage.php
<?
phpinfo();
?>

here is my request.

$FID = fopen("http://myserver/mypage.php","r");
fpassthru($FID);

When I look at at HTTP_USER_AGENT it is PHP/4.0.6

Is there a way to send the User agent headers for say IE 5.5,Netscape,Mozilla,etc.

Thanks in advance,

Rodney

    Sure don't use fopen, open a socket, and do a raw get, then strip off the headers and add your own!

      Not sure I know what you mean?

        • [deleted]

        he means he clicked on the wrong thread :-)

          sumthing like this:
          function Get_data($server,$port,$MyFile)
          {

          $sp = fsockopen($server,$port,$errno,$errstr,10);
          if (!$sp)
          {
          die("Sorry our server is currently down =(");
          }
          set_socket_blocking($sp,false);
          $UrlStr = sprintf("GET /%s HTTP/1.0\n\n",$MyFile);
          fputs($sp,$UrlStr);
          for($i=0; $i<4; $i++)
          {
          if(feof($sp)) break; // exit if connection broken
          $sp_data.= fread($sp,31337);
          usleep(500000);
          }
          return $sp_data;
          }

            I understood what phil posted! I didn't understand what Griffin Posted! My solution was more like this.

            $fid = fsockopen("localhost",80,&$error_number, &$error_description,60);

            if($fid)
            {
            fputs($fid, "GET /info.php HTTP/1.0");
            fputs($fid, "\r\n");
            fputs($fid, "USER-AGENT: Browser Whatever v1.0");
            fputs($fid, "\r\n\r\n");

            while(!feof($fid))
            {
            	print(fgets($fid, 4096));
            }
            fclose($fid);

            }
            else
            {
            print("Failed to open socket errors are $error_number, $error_description");
            }

              Write a Reply...