php / php/php-src

SAPI should not add charset to each text subtype

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

Nessuno ha ancora preso questa issue.

Category: SAPI Feature
Lingua principale
C
Stelle
40.4k
Fork
8.1k
Merge medio
2g 13h
PR unite (30g)
96

Descrizione

Description

The built-in webserver will add ";charset=UTF-8" to the end of the Content-Type response header of the SSE response

The following code:

<?php
header('Content-Type: text/event-stream');
for ($i = 0; $i < 3; ++$i) {
    echo 'data: ' . $i . "\n\n";
}

Run server:

php -S 127.0.0.1:8080 test.php

Test:

curl http://127.0.0.1:8080/ -vvv

Resulted in this output:

# curl http://127.0.0.1:8080/ -vvv
*   Trying 127.0.0.1:8080...
* TCP_NODELAY set
* Connected to 127.0.0.1 (127.0.0.1) port 8080 (#0)
> GET / HTTP/1.1
> Host: 127.0.0.1:8080
> User-Agent: curl/7.68.0
> Accept: */*
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Host: 127.0.0.1:8080
< Date: Fri, 28 Apr 2023 02:51:28 GMT
< Connection: close
< X-Powered-By: PHP/8.1.18
< Content-type: text/event-stream;charset=UTF-8
<
data: 0

data: 1

data: 2

* Closing connection 0

But I expected this output instead:

# curl http://127.0.0.1:8080/ -vvv
*   Trying 127.0.0.1:8080...
* TCP_NODELAY set
* Connected to 127.0.0.1 (127.0.0.1) port 8080 (#0)
> GET / HTTP/1.1
> Host: 127.0.0.1:8080
> User-Agent: curl/7.68.0
> Accept: */*
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Host: 127.0.0.1:8080
< Date: Fri, 28 Apr 2023 02:51:28 GMT
< Connection: close
< X-Powered-By: PHP/8.1.18
< Content-type: text/event-stream
<
data: 0

data: 1

data: 2

* Closing connection 0
PHP Version

PHP 8.0.28, 8.1.18, 8.2.5

Operating System

No response

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 riproducendo la risposta del webserver integrato con lo script PHP e il comando curl mostrati nell’issue, quindi traccia la gestione degli header di risposta di SAPI per text/event-stream. Il lavoro è completato quando la risposta conserva Content-Type: text/event-stream senza il charset aggiunto automaticamente, e il body SSE esistente continua a essere restituito.

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

Valutazione

Stack tecnologico
c, php
Ambito
backend, web-dev
Tipo di issue
Bug
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
45/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.