Skip to content

Controller

isHead()

isHead() — returns boolean

Available in: controller Category: Miscellaneous Functions

Returns whether the request was a HEAD request or not.

// 1. Respond to a HEAD request by rendering nothing
if (isHead()) {
    renderNothing();
}

// 2. Restrict an action to HEAD requests only
if (!isHead()) {
    renderText("Method not allowed");
}

// 3. Store the result to use in a conditional
requestIsHead = isHead();
// requestIsHead -> true when the HTTP method is HEAD, false otherwise