Fix http library (mostly)
parent
a31d48749e
commit
ce22a9f176
|
@ -4,7 +4,6 @@ Somewhat inspired by "request".
|
||||||
|
|
||||||
Current known issues:
|
Current known issues:
|
||||||
* HTTPS is not supported
|
* HTTPS is not supported
|
||||||
*
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
___license___ = "MIT"
|
___license___ = "MIT"
|
||||||
|
@ -76,7 +75,11 @@ class Response(object):
|
||||||
self.socket = None
|
self.socket = None
|
||||||
|
|
||||||
def json(self):
|
def json(self):
|
||||||
return ujson.loads(self.text)
|
try:
|
||||||
|
return ujson.loads(self.text)
|
||||||
|
except ValueError as e:
|
||||||
|
print("Invalid JSON: %s" % self.text)
|
||||||
|
raise(e)
|
||||||
|
|
||||||
# Writes content into a file. This function will write while receiving, which avoids
|
# Writes content into a file. This function will write while receiving, which avoids
|
||||||
# having to load all content into memory
|
# having to load all content into memory
|
||||||
|
@ -166,7 +169,7 @@ def open_http_socket(method, url, json=None, timeout=None, headers=None, data=No
|
||||||
content = None
|
content = None
|
||||||
|
|
||||||
# ToDo: Handle IPv6 addresses
|
# ToDo: Handle IPv6 addresses
|
||||||
addr = c(host, port)
|
addr = get_address_info(host, port)
|
||||||
|
|
||||||
sock = usocket.socket(usocket.AF_INET, usocket.SOCK_STREAM)
|
sock = usocket.socket(usocket.AF_INET, usocket.SOCK_STREAM)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue