You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Jason Chinnes <Ja...@ITONCALL.NET> on 2003/12/08 21:38:32 UTC

[users@httpd] Local Request

Does anyone know how to get Apache 1.3 (Win32) to be able to request a
document that it hosts.  For example, say one has two pages,
http://localhost/data.txt and http://localhost/view.php, as shown below:

data.txt
--------
Hello world.

view.php
--------
<?php 
$fp = fsockopen ("localhost", 80, $errno, $errstr, 30); 
fputs ($fp, "GET /data.txt HTTP/1.1\r\nHost: localhost\r\n\r\n"); 
while (!feof($fp)) echo fgets ($fp,128); 
fclose ($fp); 
?>

When I try this example, apache's access.log file shows that 127.0.0.1
made a request for /data.txt and that it returned 200.  The client
(requesting view.php) however simply hangs untill it times out.  I get
the same behavoir no matter weither I use Mozilla, IE, or telnet in and
make the request by hand as in:

GET /view.php HTTP/1.1
Host: localhost

If I modify view.php as follows:

<?php 
$fp = fsockopen ("localhost", 80, $errno, $errstr, 30); 
fputs ($fp, "GET /data.txt HTTP/1.1\r\nHost: localhost\r\n\r\n"); 
echo "before"
while (!feof($fp)) echo fgets ($fp,128); 
echo "after"
fclose ($fp); 
?>

And repeat the request to view.php, I receive the "before", then the
client hangs untill timeout.  If I make the following change:

<?php 
$fp = fsockopen ("www.example.com", 80, $errno, $errstr, 30); 
fputs ($fp, "GET / HTTP/1.1\r\nHost: www.example.com\r\n\r\n"); 
while (!feof($fp)) echo fgets ($fp,128); 
fclose ($fp); 
?>

(or any url which is not on the same server as view.php) everything
works as expected.  I get the same behavior no matter what language I
use (I have tried PHP, PERL, and ColdFusion).  The only time I DON'T get
this behavior is when I set the MaxRequestsPerChild to 1 forceing all
requests to be served by a different clild process.  I know this is not
an acceptable solution because of the massive overhead involved
(especially in Win32), but it at clued me in that this as an issue with
Apache and not the code in the scripts.  

Bottem line, is there a way to configure Apache so that it can open a
connection back to itself within the same child process?

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org