flightphp / core

An extensible micro-framework for PHP
https://docs.flightphp.com
MIT License
2.6k stars 407 forks source link

Also register the HEAD method alongside GET #555

Closed BelleNottelling closed 3 months ago

BelleNottelling commented 3 months ago

Hi all!

First off, thanks for Flight it's honestly a great little framework and It's been a treat to work with.

This is a very small patch that causes Flight to automatically register the HEAD method alongside GET if the user didn't do so manually. Per the RFC, a server should respond identically to a HEAD request as a GET request except with only the headers.

The web-server in-front of PHP should ensure only the headers are sent back to the client, meaning the only aspect Flight needs to handle is just ensuring a HEAD request is handled the same as a GET request.

In terms of real-world use-case, I know that some uptime monitors (specifically updown.io) will try to use HEAD requests to save a little bit of bandwidth which would then fallback to GET requests when used with Flight.

BelleNottelling commented 3 months ago

Cheers and thanks!