codeigniter4 / CodeIgniter4

Open Source PHP Framework (originally from EllisLab)
https://codeigniter.com/
MIT License
5.3k stars 1.9k forks source link

Bug: return 404 if request only headers #9132

Closed ostap-mykhaylyak closed 3 weeks ago

ostap-mykhaylyak commented 3 weeks ago

PHP Version

8.3

CodeIgniter4 Version

4.5.4

CodeIgniter4 Installation Method

Composer (using codeigniter4/appstarter)

Which operating systems have you tested for this bug?

Linux

Which server did you use?

apache

Database

No response

What happened?

If try to get only headers, return 404:

curl -s -I https://xxxxxx.net/xx/xx/xxxxxxx
HTTP/1.1 404 Not Found
Content-Type: application/json; charset=UTF-8
$ curl -s -I https://codeigniter.com/
HTTP/2 404
content-type: application/json; charset=UTF-8

Steps to Reproduce

curl -s -I https://codeigniter.com/

Expected Output

return 200

Anything else?

No response

ostap-mykhaylyak commented 3 weeks ago

@all remember to set:

$routes->match(['get', 'head'], '/', 'Home::index');

kenjis commented 3 weeks ago

This is not a bug. If necessary, HEAD routes also need to be defined.

However, if there is a GET route, HEAD should also be accepted, so there is room for enhancement.