IoResponse constructor
IoResponse(
- HttpResponse _response,
- IoRequest _request
Represents an HTTP response within the JetLeaf I/O framework, providing
a bridge between the high-level ServerHttpResponse abstraction and the
underlying dart:io io.HttpResponse.
This class enables manipulation of response headers, status codes, body streaming, and other response-related metadata. It also maintains a reference to the originating IoRequest, which can be used for session management, context, and request-specific data.
Purpose
- Provides access to the underlying
io.HttpResponsefor low-level operations. - Supports header caching and manipulation via
_localHeaders. - Integrates with JetLeaf session handling for automatic session ID propagation.
- Facilitates connection introspection via getConnection.
Example
final ioResponse = IoResponse(ioResp, ioReq);
ioResponse.setStatus(HttpStatus.OK);
ioResponse.getHeaders().setContentType('application/json');
await ioResponse.getBody().write(jsonEncode({'message': 'success'}));
Parameters
_response: thedart:ioHttpResponse to wrap and manipulate._request: the corresponding IoRequest that originated this response.
Implementation
IoResponse(this._response, this._request);