LCOV - code coverage report
Current view: top level - lib/src - agattp_config.dart (source / functions) Coverage Total Hit
Test: agattp Lines: 33.3 % 3 1
Test Date: 2025-01-28 00:11:13 Functions: - 0 0

            Line data    Source code
       1              : import 'dart:convert';
       2              : import 'dart:io';
       3              : 
       4              : import 'package:agattp/src/agattp_utils.dart';
       5              : import 'package:agattp/src/auth/agattp_abstract_auth.dart';
       6              : 
       7              : /// A collection of parameters for HTTP requests, including:
       8              : ///
       9              : /// - A bad certificate callback to bypass TLS handshake errors
      10              : /// - An authentication strategy
      11              : /// - The request timeout
      12              : /// - How to encode the body
      13              : /// - Whether redirects will be followed or returned immediately
      14              : /// - Whether to force a connection close after the request
      15              : /// - Which algorithm to use when capitalizing headers
      16              : class AgattpConfig {
      17              :   /// The callback to use when a TLS handshake fails - defaults to error
      18              :   final BadCertificateCallback? badCertificateCallback;
      19              : 
      20              :   /// The authentication strategy to use
      21              :   final AgattpAuthInterface? auth;
      22              : 
      23              :   /// The request timeout - defaults to 1 minute
      24              :   final Duration timeout;
      25              : 
      26              :   /// The body encoding - defaults to UTF-8
      27              :   final Encoding encoding;
      28              : 
      29              :   /// Whether redirect responses will be followed or returned as-is - defaults
      30              :   /// to TRUE
      31              :   final bool followRedirects;
      32              : 
      33              :   /// Whether the connection should be closed after the request is sent -
      34              :   /// defaults to FALSE
      35              :   final bool forceClose;
      36              : 
      37              :   /// How to capitalize the headers - defaults to CAPITALIZE
      38              :   final HeaderKeyCase headerKeyCase;
      39              : 
      40            6 :   const AgattpConfig({
      41              :     this.auth,
      42              :     this.badCertificateCallback = blockAllCertificates,
      43              :     this.timeout = const Duration(minutes: 1),
      44              :     this.encoding = utf8,
      45              :     this.followRedirects = true,
      46              :     this.forceClose = false,
      47              :     this.headerKeyCase = HeaderKeyCase.capitalize,
      48              :   });
      49              : 
      50              :   /// Shorthand function to block all invalid certificates
      51            0 :   static bool blockAllCertificates(_, __, ___) => false;
      52              : 
      53              :   /// Shorthand function to allow all invalid certificates
      54            0 :   static bool allowAllCertificates(_, __, ___) => true;
      55              : }
        

Generated by: LCOV version 2.0-1