ktorio / ktorio/ktor

Request for head-route does not work if AutoHeadResponse is installed

Open
#1,835 2 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Kotlin
Stars
14.5k
Forks
1.3k
Avg merge
2d 13h
Merged PRs (30d)
49

Description

**Ktor Version and Engine Used (client or server and name)**
1.3.2

**Describe the bug**
head route does not resolve as expected

**To Reproduce**
`install(AutoHeadResponse)`
```
route("/api") {
head("/v1") {
call.respond(HttpStatusCode.NoContent)
}
}
```
`curl -I http://0.0.0.0:8080/api/v1` fails with 404

**Expected behavior**
curl should see a 204

I found out that this happens only if AutoHeadResponse is installed - I'm not sure if this is expected behaviour or not but at least it should be documented

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the issue with install(AutoHeadResponse), the nested /api/v1 head route, and curl -I, then compare behavior with the installation removed. Trace how AutoHeadResponse handles HEAD requests and how the explicit head route is resolved. Done means the request returns HTTP 204 as expected, or the behavior is clearly documented if it is intentional.

Written by the indexing model from the issue text.

Assessment

Tech stack
kotlin
Domain
api, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.