Skip to content

Commit 18544c6

Browse files
author
Cal Stroud
committed
Added support for logging API calls which return a GZIP archive in the response
1 parent b805a28 commit 18544c6

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

drf_api_logger/middleware/api_logger_middleware.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,11 @@ def __call__(self, request):
101101
if len(self.DRF_API_LOGGER_METHODS) > 0 and method not in self.DRF_API_LOGGER_METHODS:
102102
return response
103103

104-
if response.get('content-type') in ('application/json', 'application/vnd.api+json',):
105-
if getattr(response, 'streaming', False):
104+
if response.get('content-type') in ('application/json', 'application/vnd.api+json', 'application/gzip'):
105+
106+
if response.get('content-type') == 'application/gzip':
107+
response_body = '** GZIP Archive **'
108+
elif getattr(response, 'streaming', False):
106109
response_body = '** Streaming **'
107110
else:
108111
if type(response.content) == bytes:

0 commit comments

Comments
 (0)