nathggns / Scaffold

Lightweight PHP API Framework
Other
8 stars 2 forks source link

Are HEAD requests supported? #121

Open nathggns opened 11 years ago

ClaudioAlbertin commented 11 years ago

Yes. (See https://github.com/Scaffold/Scaffold/blob/development/system/classes/router.php)

nathggns commented 11 years ago

Okay, this needs to change because HEAD requests are equivalent (logic wise) to GET requests, you just don't send back the body.

Controller::head should implement this, so it's possible for the child controller to do custom things in the HEAD request.

ClaudioAlbertin commented 11 years ago

This is obviously a routing issue, thus should and can be solved with a simple route. A new route shall be assigned to the default router service object, that simply accepts all HEAD requests, executes the corresponding GET method in the controller, uses it's return value, the response object, and prevents the response from sending automatically (see the associated hook in the default router service) and instead sends just the headers with Response::send_headers(). This way, no class has to be changed, custom HEAD routes can easily override the default one or this behaviour can be disabled completely by removing the default HEAD route, respectively by using a custom router service.

nathggns commented 11 years ago

It wouldn't be as easy as just implementing the method in the sub controller though  — Nathaniel Higgins http://nath.is

On Wed, May 29, 2013 at 7:52 PM, Claudio Albertin notifications@github.com wrote:

This is obviously a routing issue, thus should and can be solved with a simple route. A new route shall be assigned to the default router service object, that simply accepts all HEAD requests, executes the corresponding GET method in the controller, uses it's return value, the response object, and prevents the response from sending automatically (see the associated hook in the default router service) and instead sends just the headers with Response::send_headers().

This way, no class has to be changed, custom HEAD routes can easily override the default one or this behaviour can be removed completely by removing the default HEAD route respectively use a custom router service.

Reply to this email directly or view it on GitHub: https://github.com/Scaffold/Scaffold/issues/121#issuecomment-18638012

ClaudioAlbertin commented 11 years ago

It would be even easier.

ClaudioAlbertin commented 11 years ago

Will be implemented and ready on the 8th of June.