php / php/php-src

HTTP requests (file_get_contents, curl) times out when calling same server listener

Offen
#11,719 5 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Bug Status: Needs Triage
Vorherrschende Sprache
C
Sterne
40.4k
Forks
8.1k
Ø Merge
2 T. 13 Std.
Gemergte PRs (30 T.)
96

Beschreibung

Description
Issue

When a script makes a HTTP call on Windows to the same host/server listener - it will time out.

Steps to reproduce:
  1. Install PHP 8.2.8 for Windows
  2. Create bug/test.php file with following code:
<?php
echo $_GET['say'] ?? file_get_contents('http://localhost/test.php?say=hello');
  1. cd bug and start a php server in that folder: php -S localhost:80
  2. Try to run the script, it will time out: php test.php

The script will time out, as the file_get_contents never responds.

Expected result

It should echo hello to the console

Further testing

This issue extends further than file_get_contents and php web server - it also affects:

  • curl functions curl_exec etc not just file_get_contents
  • Using php-cgi.exe and nginx on Windows with fastcgi_pass
  • Also tested with Caddy web server, using proxy pass, same issue
Linux/Unix

This doesn't affect linux. Trying the above reproduction steps in Linux will echo hello. It also works as expected when using WSL/Windows Sub System for Linux.

PHP Version

PHP 8.2.8

Operating System

Windows 10

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginne mit der Windows-Reproduktion in bug/test.php und vergleiche file_get_contents('http://localhost/test.php?say=hello') mit den dokumentierten curl_exec-Fällen. Reproduziere das Verhalten mit PHP 8.2.8 und php -S localhost:80 unter Windows und verifiziere anschließend, dass die Anfrage abgeschlossen wird und hello ausgibt, ohne das Verhalten unter Linux/WSL zu beeinträchtigen.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
php
Bereich
backend, networking
Issue-Typ
Bug
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Ruhig
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
45/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.