MockHttpRequest constructor
MockHttpRequest({})
Creates a mock HTTP request.
method: HTTP method (GET, POST, etc.)uri: Request URI with path and query parametersbody: Request body as string (will be UTF-8 encoded)bodyBytes: Request body as bytes (alternative tobody)headers: Map of header name to valueremoteIp: Client IP address for testing IP-based logiccontentLength: Override Content-Length (for testing body limit checks)
Implementation
MockHttpRequest({
this.method = 'GET',
Uri? uri,
String? body,
List<int>? bodyBytes,
Map<String, String>? headers,
String remoteIp = '127.0.0.1',
int? contentLength,
}) : uri = uri ?? Uri.parse('/'),
requestedUri = uri ?? Uri.parse('http://localhost/'),
_bodyBytes = bodyBytes ?? (body != null ? utf8.encode(body) : const []),
connectionInfo = MockHttpConnectionInfo(remoteIp: remoteIp),
_contentLengthOverride = contentLength {
headers?.forEach((key, value) {
this.headers.set(key, value);
});
}