APIRequest class

Represents an API request.

Inheritance
Mixed-in types

Constructors

APIRequest(APIRequestMethod method, String path, {String? protocol, Map<String, dynamic>? parameters, Map<String, dynamic>? headers, dynamic payload, Object? payloadMimeType, String? payloadFileExtension, String? sessionID, bool newSession = false, APICredential? credential, String? scheme, APIRequesterSource? requesterSource, String? requesterAddress, bool keepAlive = false, DateTime? time, Duration? parsingDuration, Uri? requestedUri, Object? originalRequest, Map<String, APIMetric>? metrics})
APIRequest.delete(String path, {Map<String, dynamic>? parameters, Map<String, dynamic>? headers, dynamic payload, Object? payloadMimeType, APICredential? credential})
Creates a request of DELETE method.
factory
APIRequest.fromArgs(List<String> args)
Constructs an APIRequest parsing args.
factory
APIRequest.fromArgsLine(String argsLine)
Constructs an APIRequest parsing argsLine.
factory
APIRequest.get(String path, {Map<String, dynamic>? parameters, Map<String, dynamic>? headers, dynamic payload, APICredential? credential})
Creates a request of GET method.
factory
APIRequest.head(String path, {Map<String, dynamic>? parameters, Map<String, dynamic>? headers, dynamic payload, APICredential? credential})
Creates a request of HEAD method.
factory
APIRequest.patch(String path, {Map<String, dynamic>? parameters, Map<String, dynamic>? headers, dynamic payload, Object? payloadMimeType, APICredential? credential})
Creates a request of PATCH method.
factory
APIRequest.post(String path, {Map<String, dynamic>? parameters, Map<String, dynamic>? headers, dynamic payload, Object? payloadMimeType, APICredential? credential})
Creates a request of POST method.
factory
APIRequest.put(String path, {Map<String, dynamic>? parameters, Map<String, dynamic>? headers, dynamic payload, Object? payloadMimeType, APICredential? credential})
Creates a request of PUT method.
factory

Properties

authentication APIAuthentication?
The authentication of this request, processed by APISecurity.
getter/setter pair
credential APICredential?
The request credential. After the authentication process this credential maybe updated/resolved. See originalCredential
getter/setter pair
elapsedTime Duration
The elapsed time of this request.
no setter
hashCode int
The hash code for this object.
no setterinherited
hasMetrics bool
Returns true if any metric is set. See metrics.
no setterinherited
hasPayload bool
Returns true if payload is not null.
no setterinherited
headers Map<String, dynamic>
The headers of the request.
final
hostname String
no setter
hostnameAndPort String
no setter
id int
The request ID (to help debugging and loggign).
final
isAuthenticated bool
Returns true if this request is authenticated and the token is not expired.
no setter
keepAlive bool
If true the client accepts Keep-Alive connections.
final
lastPathPart String
Returns the last pathParts. Sames as pathPartReversed for index 0.
no setter
method APIRequestMethod
The request method.
final
metrics Map<String, APIMetric>
Returns the current metrics.
no setterinherited
newSession bool
If true indicates that sessionID is new (was created in this request).
final
origin String
no setter
originalCredential APICredential?
The request original credential, before the authentication process. See credential
getter/setter pair
originalRequest Object?
final
parameters Map<String, dynamic>
The parameters of the request.
final
parsingDuration Duration?
The Duration to parse this request (optional).
final
path String
The request path.
final
pathPartFirst String
First of pathParts.
no setter
pathPartLast String
Last of pathParts.
no setter
pathParts List<String>
Returns the parts of the path.
no setter
payload → dynamic
The payload/body of the request.
final
payloadAsBytes Uint8List?
Returns payload as bytes (Uint8List).
no setter
payloadFileExtension String?
The payload usual file name extension.
getter/setter pairoverride-getter
payloadLength int
Returns the payload length.
no setterinherited
payloadMimeType MimeType?
The payload/body MIME Type.
getter/setter pairoverride-getter
port int
no setter
protocol String?
The request protocol.
final
requestedUri Uri
final
requesterAddress String?
no setter
requesterSource APIRequesterSource
final
routeHandler APIRouteHandler?
The APIRouteHandler used to call the route for this APIRequest.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
scheme String?
final
sessionID String?
The session ID (usually from a session cookie).
final
time DateTime
The DateTime of this request.
final
transactions List<Transaction>
Returns the transactions associated with this request.
no setter

Methods

addTransaction(Transaction t) → void
Associate a Transaction to this request.
dispose() → void
Disposes the internals of this APIResponse.
override
disposeAsync() Future<void>
Asynchronous call to dispose.
inherited
getHeader(String key, {String? def}) String?
getHeaderFirstOf(String key1, [String? key2, String? key3, String? key4, String? key5, String? key6]) String?
getMetric(String name) APIMetric?
Returns a metric.
inherited
getParameter<V>(String name1, [V? def]) → V?
Returns from parameters a value for name1 or name1 .. name9.
getParameterFirstOf<V>(String name1, [String? name2, String? name3, String? name4, String? name5, String? name6]) → V?
getParameterIgnoreCase<V>(String name, [V? def]) → V?
Returns from parameters a value for name or name1 .. name9 ignoring case. See getParameter.
getParameterIgnoreCaseFirstOf<V>(String name1, [String? name2, String? name3, String? name4, String? name5, String? name6]) → V?
matchesHostname(Pattern pattern) bool
Returns true if patterns matches hostname.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
pathPart(int index, {bool reversed = false}) String
Returns a path part at index.
pathPartAt(int index) String?
Returns the path part at index in pathParts.
pathPartReversed(int index) String
Sames as pathPart but with a reversed index.
removeTransaction(Transaction t) bool
Disassociate a Transaction from this request.
setMetric(String name, {Duration? duration, String? description, int? n}) APIMetric
Set a metric.
inherited
startMetric(String name, {String? description}) DateTime
Starts a metric chronometer.
inherited
stopAllMetrics({DateTime? now}) → void
inherited
stopMetric(String name, {DateTime? now}) Duration?
Stops a metric previously started and adds it to metrics. See startMetric.
inherited
toString({bool withHeaders = true, bool withPayload = true}) String
A string representation of this object.
override

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Properties

typeInfo TypeInfo
final