CurlUtils class
A utility class for generating, logging, and caching cURL commands from Dio requests and responses.
This class provides static methods to interact with cURL generation, handle request/response/error logging, and manage the cURL cache. The handleOn* methods are specifically designed to be used directly in custom interceptors, allowing full customization of logging behavior.
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
addXClientTime(
RequestOptions requestOptions) → void -
Adds an 'X-Client-Time' header to the
RequestOptions. -
cacheError(
DioException err, {Stopwatch? stopwatch}) → void -
Caches an error response with its curl command
This can be used directly in custom interceptors
Caches a
DioException(error) along with its generated cURL command. -
cacheResponse(
Response response, {Stopwatch? stopwatch}) → void -
Caches a successful
Responsealong with its generated cURL command. This can be used directly in custom interceptors -
handleOnError(
DioException err, {CurlOptions curlOptions = const CurlOptions(), Stopwatch? stopwatch}) → void - Handles the cURL logging for an error response.
-
handleOnRequest(
RequestOptions options, {CurlOptions curlOptions = const CurlOptions(), String chronologicalPrefix = '[CurlTime]'}) → void - Handles the cURL logging for a request before it is sent.
-
handleOnResponse(
Response response, {CurlOptions curlOptions = const CurlOptions(), Stopwatch? stopwatch}) → void - Handles the cURL logging for a successful response.
-
logCurl(
RequestOptions requestOptions, {String prefix = kPrefix, Ansi? ansi, Printer? printer}) → void -
Generates and logs a cURL command for a given
RequestOptions.