Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix http-response logs. #127

Merged
merged 1 commit into from
Jul 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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'
'}');
});
});
}