ktorio / ktorio/ktor

Add support for ports in withTestApplication

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

Description

Currently there is no parameter for which port to use in sending a test request, I propose to add this function:
```kotlin
fun TestApplicationEngine.handleRequest(
method: HttpMethod,
port: Int = 80,
uri: String,
setup: TestApplicationRequest.() -> Unit = {}
): TestApplicationCall = handleRequest {
this.uri = uri
this.method = method
this.addHeader(HttpHeaders.Host, "localhost:$port")
setup()
}
```

Contributor guide

Open the contributing guide

Research direction

Start by locating TestApplicationEngine.handleRequest and the withTestApplication test helpers, then inspect existing request-handling tests. Add port support to the test request API as described and verify that the generated Host header uses the requested port.

Written by the indexing model from the issue text.

Assessment

Tech stack
kotlin
Domain
testing
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.