php / php/php-src

SAPI should not add charset to each text subtype

オープン
#11,146 コメント 5 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

Category: SAPI Feature
主要言語
C
スター
40.4k
フォーク
8.2k
平均マージ
2日 13時間
マージ済み PR(30日)
96

説明

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

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

まず、issue に示されている PHP スクリプトと curl コマンドを使って組み込み webserver のレスポンスを再現し、次に text/event-stream に対する SAPI のレスポンスヘッダー処理を追跡します。完了の条件は、レスポンスが自動的に付加される charset なしで Content-Type: text/event-stream を保持し、既存の SSE body も引き続き返されることです。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
c, php
領域
backend, web-dev
issue の種類
バグ
難易度
3/5
見積もり時間
1〜2日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
45/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。