SigV4Request constructor
SigV4Request(})
Implementation
SigV4Request(
this.awsSigV4Client, {
required String method,
String? path,
this.datetime,
this.queryParams,
this.headers,
this.authorizationHeader,
dynamic body,
}) {
this.method = method.toUpperCase();
this.path = '${awsSigV4Client.pathComponent}$path';
headers =
headers?.map((key, value) => MapEntry(key.toLowerCase(), value)) ?? {};
if (headers!['content-type'] == null && this.method != 'GET') {
headers!['content-type'] = awsSigV4Client.defaultContentType;
}
if (headers!['accept'] == null) {
headers!['accept'] = awsSigV4Client.defaultAcceptType;
}
if (body == null || this.method == 'GET') {
this.body = '';
} else {
this.body = json.encode(body);
}
if (body == '') {
headers!.remove('content-type');
}
datetime = datetime ?? SigV4.generateDatetime();
headers![_xAmzDate] = datetime;
final endpointUri = Uri.parse(awsSigV4Client.endpoint);
headers![_host] = endpointUri.host;
headers![_authorization] =
authorizationHeader ?? _generateAuthorization(datetime!);
if (awsSigV4Client.sessionToken != null) {
headers![_xAmzSecurityToken] = awsSigV4Client.sessionToken;
}
headers!.remove(_host);
url = _generateUrl();
}