[php-src] Issue #11146: Bug in using SSE with the built-in webserver
| From: | Yurunsoft | Date: | Fri, 28 Apr 2023 03:08:03 +0000 |
| Subject: | [php-src] Issue #11146: Bug in using SSE with the built-in webserver | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-244292@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/11146
Author: Yurunsoft
### 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
<?php
header('Content-Type: text/event-stream');
for ($i = 0; $i < 3; ++$i) {
echo 'data: ' . $i . "\n\n";
}
```
Run server:
```shell
php -S 127.0.0.1:8080 test.php
```
Test:
```shell
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_