Laravel - Routes GET|HEAD

前端 未结 2 964
南方客
南方客 2021-01-16 11:39

When I do php artisan routes, the GET request of my app has a |HEAD. What is the purpose of having |HEAD?

2条回答
  •  再見小時候
    2021-01-16 12:00

    Following function is taken from the Laravel's Illuminate\Routing\Router.php class, when you use Route::get() method to add a route for your site/application, Laravel adds both methods for the url, it means that, these urls registered using getmethod could be accessed using both GET and HEAD HTTP method, and HEAD is just another HTTP verb/method, used for making a HEAD request.

    /**
     * Register a new GET route with the router.
     *
     * @param  string  $uri
     * @param  \Closure|array|string  $action
     * @return \Illuminate\Routing\Route
     */
    public function get($uri, $action)
    {
        return $this->addRoute(array('GET', 'HEAD'), $uri, $action);
    }
    

提交回复
热议问题