SigV4Request constructor

SigV4Request(
  1. AwsSigV4Client? awsSigV4Client, {
  2. String? method,
  3. String? path,
  4. String? datetime,
  5. Map<String, String>? queryParams,
  6. Map<String, String>? headers,
  7. dynamic body,
})

Implementation

SigV4Request(
  this.awsSigV4Client, {
  String? method,
  String? path,
  this.datetime,
  this.queryParams,
  this.headers,
  dynamic body,
}) {
  this.method = method?.toUpperCase();
  this.path = '${awsSigV4Client?.pathComponent}$path';
  headers ??= {};
  if (headers?['Content-Type'] == null) {
    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 ??= SigV4.generateDatetime();
  headers?[_x_amz_date] = datetime!;
  final endpointUri = Uri.parse(awsSigV4Client!.endpoint!);
  headers?[_host] = endpointUri.host;

  headers?[_authorization] = _generateAuthorization(datetime!);
  if (awsSigV4Client!.sessionToken != null) {
    headers?[_x_amz_security_token] = awsSigV4Client!.sessionToken!;
  }
  headers!.remove(_host);

  url = _generateUrl();

  if (headers?['Content-Type'] == null) {
    headers?['Content-Type'] = awsSigV4Client!.defaultContentType!;
  }
}