Enable Automatic HEAD Responses
Ktor can automatically provide responses to HEAD
requests for existing routes that have the GET
verb defined.
This feature is defined in the class io.ktor.features.AutoHeadResponse
and no additional artifacts are required.
Usage
To enable automatic HEAD
responses, install the AutoHeadResponse
feature
fun Application.main() {
// ...
install(AutoHeadResponse)
// ...
}
Configuration options
None.
Under the covers
This feature automatically responds to HEAD
requests by routing as if it were GET
response and discarding the body. Since any FinalContent
produced by the system has lazy content semantics, it does not incur in any performancecosts for processing a GET
request with a body.