---
title: "ServerRequest"
sidebar_label: "ServerRequest"
description: "Kotlin binding reference: ServerRequest."
---

<!-- Generated by tools/api_reference/generate_api_docs.py. Do not edit. -->

//[clika-runtime](../../../index.md)/[io.clika.runtime](../index.md)/[ServerRequest](index.md)

# ServerRequest

[common]\
class [ServerRequest](index.md)

A request as a handler sees it: a borrowed view, valid for the handler call alone; never keep it past the return. The observers are always present; the lookups answer null when the header, query field, cookie or form field is absent; the path captures of a pattern route are read by index or by name; [setAttr](setAttr.md) / [attr](attr.md) are the middleware-to-handler channel (read-only inside the failure and error pages and the logger).

## Properties

| Name | Summary |
|---|---|
| [body](body.md) | [common]<br>val [body](body.md): [ByteArray](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html)<br>The raw request body. |
| [clientIp](clientIp.md) | [common]<br>val [clientIp](clientIp.md): [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)<br>The peer's socket address (not what a header claims). |
| [method](method.md) | [common]<br>val [method](method.md): [Method](../Method/index.md)<br>The HTTP verb. |
| [paramCount](paramCount.md) | [common]<br>val [paramCount](paramCount.md): [Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)<br>The number of path captures on the matched pattern route. |
| [path](path.md) | [common]<br>val [path](path.md): [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)<br>The decoded path, without the query string. |
| [shouldStop](shouldStop.md) | [common]<br>val [shouldStop](shouldStop.md): [Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)<br>True when the connection closed or the server is stopping. |

## Functions

| Name | Summary |
|---|---|
| [attr](attr.md) | [common]<br>fun [attr](attr.md)(name: [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)): [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)?<br>A request attribute set by [setAttr](setAttr.md), or null. |
| [bodyText](bodyText.md) | [common]<br>fun [bodyText](bodyText.md)(): [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)<br>The body decoded as UTF-8 text. |
| [cookie](cookie.md) | [common]<br>fun [cookie](cookie.md)(name: [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)): [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)?<br>A cookie's value from the Cookie header, or null. |
| [formField](formField.md) | [common]<br>fun [formField](formField.md)(name: [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)): [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)?<br>A text field of a form body, or null. |
| [formFile](formFile.md) | [common]<br>fun [formFile](formFile.md)(name: [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)): [FormFile](../FormFile/index.md)?<br>A file part of a multipart body, or null. |
| [formParts](formParts.md) | [common]<br>fun [formParts](formParts.md)(): [List](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html)&lt;[FormPart](../FormPart/index.md)&gt;<br>Every part of a multipart body, repeated names kept; empty for another body kind. |
| [header](header.md) | [common]<br>fun [header](header.md)(name: [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)): [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)?<br>A header's value, matched without regard to case, or null. |
| [param](param.md) | [common]<br>fun [param](param.md)(index: [Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)): [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)<br>A path capture by 0-based index; fails with `NOT_FOUND` when there is none.<br>[common]<br>fun [param](param.md)(name: [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)): [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)<br>A path capture by its `(?P<name>...)` group name; fails with `NOT_FOUND` when there is none. |
| [query](query.md) | [common]<br>fun [query](query.md)(name: [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)): [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)?<br>A query field's first value, or null. |
| [queryAll](queryAll.md) | [common]<br>fun [queryAll](queryAll.md)(name: [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)): [List](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html)&lt;[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)&gt;<br>Every value of a query field. |
| [setAttr](setAttr.md) | [common]<br>fun [setAttr](setAttr.md)(name: [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html), value: [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html))<br>Attach a per-request attribute, the middleware-to-handler channel. |