Coverage Summary for Class: HttpRequestInfo (kweb.client)
Class |
Method, %
|
Branch, %
|
Line, %
|
Instruction, %
|
HttpRequestInfo |
100%
(1/1)
|
|
100%
(5/5)
|
100%
(45/45)
|
HttpRequestInfo$requestedUrl$2 |
100%
(1/1)
|
|
100%
(2/2)
|
100%
(17/17)
|
Total |
100%
(2/2)
|
|
100%
(7/7)
|
100%
(62/62)
|
package kweb.client
import io.ktor.server.plugins.origin
import io.ktor.server.request.ApplicationRequest
/**
* @param request This is the raw [ApplicationRequest](https://api.ktor.io/1.3.2/io.ktor.request/-application-request/index.html)
* provided by [Ktor](https://github.com/Kotlin/ktor), the HTTP transport library used by Kweb. It can be used
* to read various information about the inbound HTTP request, however you should use properties of
* [HttpRequestInfo] directly instead if possible.
*
* Note that values in `ApplicationRequest` can change during a connection, see [issue #154])(https://github.com/kwebio/kweb-core/issues/154).
*
*/
data class HttpRequestInfo(val request: ApplicationRequest) {
val requestedUrl: String by lazy {
with(request.origin) {
"$scheme://$host:$port$uri"
}
}
val cookies = request.cookies
val remoteHost = request.origin.remoteHost
val userAgent = request.headers["User-Agent"]
}