1
0
mirror of https://github.com/httpie/cli.git synced 2025-12-24 00:31:09 +02:00

Fix --offline --multipart, add more tests

This commit is contained in:
Jakub Roztocil
2020-09-28 16:22:34 +02:00
parent 75f1e02215
commit 32d8b481e9
6 changed files with 78 additions and 9 deletions

View File

@@ -144,10 +144,9 @@ class StrCLIResponse(str, BaseCLIResponse):
elif self.strip().startswith('{'):
# Looks like JSON body.
self._json = json.loads(self)
elif (self.count('Content-Type:') == 1
and 'application/json' in self):
# Looks like a whole JSON HTTP message,
# try to extract its body.
elif self.count('Content-Type:') == 1:
# Looks like a HTTP message,
# try to extract JSON from its body.
try:
j = self.strip()[self.strip().rindex('\r\n\r\n'):]
except ValueError: