Skip to content

Commit

Permalink
Merge pull request #127 from matt400m/master
Browse files Browse the repository at this point in the history
Fix http-response logs.
  • Loading branch information
Frezyx authored Jul 10, 2023
2 parents 2537a3f + 50a4a36 commit 49017bc
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/talker_dio_logger/lib/dio_logs.dart
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class DioResponseLog extends TalkerLog {

final responseMessage = response.statusMessage;
final data = response.data;
final headers = response.requestOptions.headers;
final headers = response.headers.map;

msg += '\nStatus: ${response.statusCode}';

Expand Down
17 changes: 17 additions & 0 deletions packages/talker_dio_logger/test/logger_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,22 @@ void main() {
logger.onResponse(response, ResponseInterceptorHandler());
expect(talker.history.last.message, logMessage);
});

test('onResponse method should log http response headers', () {
logger = TalkerDioLogger(talker: talker, settings: TalkerDioLoggerSettings(
printResponseHeaders: true
));
final options = RequestOptions(path: '/test');
final response = Response(requestOptions: options, statusCode: 200, headers: Headers()..add("HEADER",
"VALUE"));
logger.onResponse(response, ResponseInterceptorHandler());
expect(talker.history.last.generateTextMessage(), '[http-response] [GET] /test\n'
'Status: 200\n'
'Headers: {\n'
' "header": [\n'
' "VALUE"\n'
' ]\n'
'}');
});
});
}

0 comments on commit 49017bc

Please sign in to comment.