php / php/php-src

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

Aperta
#11,719 5 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Bug Status: Needs Triage
Lingua principale
C
Stelle
40.4k
Fork
8.1k
Merge medio
2g 13h
PR unite (30g)
96

Descrizione

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

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia con la riproduzione su Windows in bug/test.php e confronta file_get_contents('http://localhost/test.php?say=hello') con i casi documentati di curl_exec. Riproduci il problema usando PHP 8.2.8 e php -S localhost:80 su Windows, quindi verifica che la richiesta venga completata e restituisca hello senza causare regressioni nel comportamento di Linux/WSL.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
php
Ambito
backend, networking
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Tranquilla
Chiarezza
Abbastanza chiara
Idoneità per principianti
45/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.