[php-src] Issue #13390: Change in Behavior of PHP Built-in Web Server for DELETE Requests in PHP 8.3
| From: | Daredzik | Date: | Wed, 14 Feb 2024 13:48:04 +0000 |
| Subject: | [php-src] Issue #13390: Change in Behavior of PHP Built-in Web Server for DELETE Requests in PHP 8.3 | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-246458@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/13390
Author: Daredzik
### Description
I've encountered an issue with the built-in web server in PHP 8.3 that seems to represent a
change in behavior from PHP 8.1.
**Description**:
In PHP 8.1, when using a router script with the built-in web server started with
php
-S, if the script explicitly returns false for an HTTP DELETE request, the
server would return an HTTP status code of 404 (Not Found). This behavior was consistent across
other HTTP methods such as POST, GET, and OPTIONS, where a return false would also
result in a 404 status code.
However, after upgrading to PHP 8.3, I've noticed that for the DELETE method specifically,
returning false from the router script now results in the server returning an HTTP
status code of 405 (Method Not Allowed) instead of 404.
The following code:
```php
<?php
return false;
```
Resulted in this output:
```
php8.3 -S 0.0.0.0:8080 test_code.php
[Wed Feb 14 14:22:41 2024] PHP 8.3.2 Development Server (http://0.0.0.0:8080) started
[Wed Feb 14 14:23:20 2024] 127.0.0.1:40094 Accepted
[Wed Feb 14 14:23:20 2024] 127.0.0.1:40094 [404]: GET / - No such file or directory
[Wed Feb 14 14:23:20 2024] 127.0.0.1:40094 Closing
[Wed Feb 14 14:23:30 2024] 127.0.0.1:46888 Accepted
[Wed Feb 14 14:23:30 2024] 127.0.0.1:46888 [404]: POST / - No such file or directory
[Wed Feb 14 14:23:30 2024] 127.0.0.1:46888 Closing
[Wed Feb 14 14:23:37 2024] 127.0.0.1:46902 Accepted
[Wed Feb 14 14:23:37 2024] 127.0.0.1:46902 [404]: OPTIONS / - No such file or directory
[Wed Feb 14 14:23:37 2024] 127.0.0.1:46902 Closing
[Wed Feb 14 14:23:43 2024] 127.0.0.1:42802 Accepted
[Wed Feb 14 14:23:43 2024] 127.0.0.1:42802 [405]: DELETE / - No such file or directory
[Wed Feb 14 14:23:43 2024] 127.0.0.1:42802 Closing
php8.1 -S 0.0.0.0:8081 test_code.php
[Wed Feb 14 14:21:34 2024] PHP 8.1.2-1ubuntu2.9 Development Server (http://0.0.0.0:8081) started
[Wed Feb 14 14:21:40 2024] 127.0.0.1:60030 Accepted
[Wed Feb 14 14:21:40 2024] 127.0.0.1:60030 [404]: DELETE / - No such file or directory
[Wed Feb 14 14:21:40 2024] 127.0.0.1:60030 Closing
[Wed Feb 14 14:21:47 2024] 127.0.0.1:60036 Accepted
[Wed Feb 14 14:21:47 2024] 127.0.0.1:60036 [404]: OPTIONS / - No such file or directory
[Wed Feb 14 14:21:47 2024] 127.0.0.1:60036 Closing
[Wed Feb 14 14:22:12 2024] 127.0.0.1:60426 Accepted
[Wed Feb 14 14:22:12 2024] 127.0.0.1:60426 [404]: POST / - No such file or directory
[Wed Feb 14 14:22:12 2024] 127.0.0.1:60426 Closing
[Wed Feb 14 14:22:17 2024] 127.0.0.1:60442 Accepted
[Wed Feb 14 14:22:17 2024] 127.0.0.1:60442 [404]: GET / - No such file or directory
[Wed Feb 14 14:22:17 2024] 127.0.0.1:60442 Closing
```
But I expected this output instead:
```
404
```
Documentation says:
[...] Otherwise a **404** response code is returned.
### PHP Version
8.3
### Operating System
Windows 11 + WSL / Ubuntu