I can't find a way to do HEAD and OPTIONS requests...
# ktor
r
I can't find a way to do HEAD and OPTIONS requests via ktor-client - are these actually missing, or did I just look in the wrong place? I'd have expected them to look like
httpClient.head(url)
, just like
httpClient.get(url)
does
๐Ÿ“ 1
โœ… 1
d
You can use
call
, and `request`: https://ktor.io/clients/http-client/calls/requests.html#custom-requests and set the
method = HttpMethod.YourMethod
I think there are no shortcuts for other verbs other than get and post
But you can include them in your code if you want
just copy the get or post extension methods and adjust accordingly
r
There are also
.put
and
.delete
there, but no head and options shortlands. Was just printing the answer with this link ๐Ÿ™‚ https://github.com/ktorio/ktor/blob/a65667a6f0ca98128c38025f989bad7cb6da4576/ktor-client/ktor-client-core/src/io/ktor/client/request/builders.kt#L65
d
oh, right,then I have to update the documentation ๐Ÿ™‚
๐Ÿ˜„ 1
r
Thanks, that helped! So does anyone know if there's a specific reason for omitting just these two verbs from the shorthands? Should be simple enough to patch them in
d
probably no specific reason, I guess, just not done ๐Ÿ™‚ but @e5l can you confirm?
e
The
head
and
options
methods has specific semantic in http and I consider to hide them from the simple builders.
๐Ÿ‘Œ 1
You could always set the
HttpMethod
in
call
and
request
methods.
d
I have updated the documentation to reflect all the things we have talked about: https://ktor.io/clients/http-client/calls/requests.html#shortcut-methods
๐Ÿ™ 1