AutoHeadResponse
The AutoHeadResponse plugin provides us with the ability to automatically respond to a HEAD
request for every route that has a GET
defined. You can use AutoHeadResponse
to avoid creating a separate head handler if you need to somehow process a response on the client before getting the actual content. For example, calling the respondFile function adds the Content-Length
and Content-Type
headers to a response automatically, and you can get this information on the client before downloading the file.
Add dependencies
To use AutoHeadResponse
, you need to include the ktor-server-auto-head-response
artifact in the build script:
Usage
In order to take advantage of this functionality, we need to install the AutoHeadResponse
plugin in our application.
In our case the /home
route will now respond to HEAD
request even though there is no explicit definition for this verb.
It's important to note that if we're using this plugin, custom HEAD
definitions for the same GET
route will be ignored.
Options
AutoHeadResponse
does not provide any additional configuration options.