RequestContext

A request as a resource handler sees it: verified by message security, reassembled from Block1 transfers, and with who sent it. This is the server's application model, the counterpart of the client's CoapRequest: method, path, query, options and payload, without the messaging-layer fields (type, Message ID, token), which differ by transport and mean nothing to a handler.

Authorize on either identity (architecture rule 4): peerIdentity is what DTLS or TLS authenticated for the hop, securityIdentity what OSCORE authenticated end to end.

Properties

Link copied to clipboard

True when the handler runs to produce an Observe notification rather than to answer a request.

Link copied to clipboard

The request message: inner (decrypted) for OSCORE, with the whole body for Block1 transfers, and with the messaging-layer fields of the message it came in. Plumbing for kcoap's own modules; a handler reads the properties of this class instead.

Link copied to clipboard

The request method.

Link copied to clipboard

The request options (inner options for OSCORE).

Link copied to clipboard

The request's Uri-Path values joined with "/" and a leading "/", or "/" for the root: the path the request names, which is the resource's path or below it.

Link copied to clipboard

The whole request body; a copy.

Link copied to clipboard

The size of the request body in bytes.

Link copied to clipboard

Where the request came from; responses and notifications go back there.

Link copied to clipboard

What channel security authenticated for the hop: DTLS for Endpoint.Secure peers, TLS on connections.

Link copied to clipboard

Uri-Query values, decoded.

Link copied to clipboard

The resource the request is for.

Link copied to clipboard

The message-security identity, or null for an unprotected request.

Functions

Link copied to clipboard
suspend fun acknowledge()

Sends an Empty ACK now, so a slow handler's response goes separately (RFC 7252 §5.2.2). The server does this by itself after dev.kcoap.coap.stack.CoapEndpointConfig.separateResponseDelay; call it when the handler knows in advance that it will take long. No effect for Non-confirmable requests and notifications.

Link copied to clipboard

The request body as UTF-8 text.

Link copied to clipboard
fun preconditionsHold(currentETag: ByteArray?, exists: Boolean = currentETag != null): Boolean

Evaluates If-Match and If-None-Match (RFC 7252 §5.10.8) against the resource's current state. A handler that returns 4.12 Precondition Failed when this is false, and lists both options in CoapResource.recognizedOptions, implements conditional requests.

Link copied to clipboard
open override fun toString(): String