Controller
isHead()
Signature
Section titled “Signature”isHead() — returns boolean
Available in: controller
Category: Miscellaneous Functions
Description
Section titled “Description”Checks if the current HTTP request method is HEAD. HEAD requests are similar to GET requests but do not return a message body, only the headers. This is often used for checking metadata like content length or existence without transferring the actual content.
Examples
Section titled “Examples”component extends="Controller" {
public void function checkFile() {
if (isHead()) {
// Respond with headers only, no content
} else {
// Handle normal GET or other requests
fileData = model("File").findByKey(params.id);
renderWith(action="show", data=fileData);
}
}
}