buildActivityJson method
Future<String?>
buildActivityJson(
- HttpActivity httpActivity
)
Implementation
Future<String?> buildActivityJson(
HttpActivity httpActivity,
) async {
final request = httpActivity.request;
final response = httpActivity.response;
var jsonOutput = {
'base_url': request?.baseUrl,
'path': request?.path,
'total_transfer_size': _byteUtil.totalTransferSize(
request?.requestSize,
response?.responseSize,
true,
),
'total_transfer_time': _dateTimeUtil.milliSecondDifference(
request?.createdAt,
response?.createdAt,
),
'request_data': {
'query_params': tryDecodeRawJson(request?.params),
'request_headers': tryDecodeRawJson(request?.requestHeader),
'request_body': tryDecodeRawJson(request?.requestBody),
'request_size': request?.requestSize,
'created_at': request?.createdAt
},
'response_data': {
'response_headers': tryDecodeRawJson(response?.responseHeader),
'response_body': tryDecodeRawJson(response?.responseBody),
'response_status_code': response?.responseStatusCode,
'response_status_message': response?.responseStatusMessage,
'response_size': '${response?.responseSize ?? 0} kb',
'created_at': response?.createdAt,
},
};
return tryEncodeJson(jsonOutput);
}