From 8420258ff78830f58e6804d9c4a147d3950f7def Mon Sep 17 00:00:00 2001 From: shmilylty Date: Tue, 6 Aug 2019 00:00:55 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=88=A4=E6=96=AD=E5=93=8D?= =?UTF-8?q?=E5=BA=94=E4=BD=93=E4=B8=8D=E4=B8=BA=E7=A9=BA=E6=89=8D=E6=89=A7?= =?UTF-8?q?=E8=A1=8Cresp.json()?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- oneforall/common/module.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/oneforall/common/module.py b/oneforall/common/module.py index 336dcbd..93bec29 100644 --- a/oneforall/common/module.py +++ b/oneforall/common/module.py @@ -82,9 +82,8 @@ class Module(object): if resp.status_code != 200 or not resp.content: # 状态码非200或者响应体为空 logger.log('ALERT', f'GET {resp.url} {resp.status_code} - {resp.reason} {len(resp.content)}') content_type = resp.headers.get('Content-Type') - if content_type: - if 'json' in content_type: - logger.log('ALERT', resp.json()) + if content_type and 'json' in content_type and not resp.content: + logger.log('ALERT', resp.json()) return None logger.log('DEBUG', f'GET {resp.url} {resp.status_code} - {resp.reason} {len(resp.content)}') return resp @@ -106,9 +105,8 @@ class Module(object): return None if resp.status_code != 200 or not resp.content: # 状态码非200或者响应体为空 content_type = resp.headers.get('Content-Type') - if content_type: - if 'json' in content_type: - logger.log('ALERT', resp.json()) + if content_type and 'json' in content_type and not resp.content: + logger.log('ALERT', resp.json()) return None logger.log('DEBUG', f'POST {resp.url} {resp.status_code} - {resp.reason} {len(resp.content)}') return resp