kopia lustrzana https://gitlab.com/jaywink/federation
Add missing `response.raise_for_status()` call to the `fetch_document` network helper
when fetching with given URL. Error status was already being raised correctly when fetching by domain and path.merge-requests/159/merge
rodzic
f6b2bb6d05
commit
91dc3ca312
|
@ -6,6 +6,10 @@
|
||||||
|
|
||||||
* Don't crash loudly when fetching webfinger for Diaspora that does not contain XML.
|
* Don't crash loudly when fetching webfinger for Diaspora that does not contain XML.
|
||||||
|
|
||||||
|
* Add missing `response.raise_for_status()` call to the `fetch_document` network helper
|
||||||
|
when fetching with given URL. Error status was already being raised correctly when
|
||||||
|
fetching by domain and path.
|
||||||
|
|
||||||
## [0.19.0] - 2019-12-15
|
## [0.19.0] - 2019-12-15
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
|
@ -73,7 +73,7 @@ def fetch_nodeinfo_document(host):
|
||||||
return
|
return
|
||||||
|
|
||||||
doc, status_code, error = fetch_document(url=url)
|
doc, status_code, error = fetch_document(url=url)
|
||||||
if status_code >= 300 and not doc:
|
if not doc:
|
||||||
return
|
return
|
||||||
try:
|
try:
|
||||||
doc = json.loads(doc)
|
doc = json.loads(doc)
|
||||||
|
|
|
@ -63,6 +63,7 @@ def fetch_document(url=None, host=None, path="/", timeout=10, raise_ssl_errors=T
|
||||||
:arg path: Path without domain (defaults to "/")
|
:arg path: Path without domain (defaults to "/")
|
||||||
:arg timeout: Seconds to wait for response (defaults to 10)
|
:arg timeout: Seconds to wait for response (defaults to 10)
|
||||||
:arg raise_ssl_errors: Pass False if you want to try HTTP even for sites with SSL errors (default True)
|
:arg raise_ssl_errors: Pass False if you want to try HTTP even for sites with SSL errors (default True)
|
||||||
|
:arg extra_headers: Optional extra headers dictionary to add to requests
|
||||||
:returns: Tuple of document (str or None), status code (int or None) and error (an exception class instance or None)
|
:returns: Tuple of document (str or None), status code (int or None) and error (an exception class instance or None)
|
||||||
:raises ValueError: If neither url nor host are given as parameters
|
:raises ValueError: If neither url nor host are given as parameters
|
||||||
"""
|
"""
|
||||||
|
@ -80,6 +81,7 @@ def fetch_document(url=None, host=None, path="/", timeout=10, raise_ssl_errors=T
|
||||||
try:
|
try:
|
||||||
response = requests.get(url, timeout=timeout, headers=headers)
|
response = requests.get(url, timeout=timeout, headers=headers)
|
||||||
logger.debug("fetch_document: found document, code %s", response.status_code)
|
logger.debug("fetch_document: found document, code %s", response.status_code)
|
||||||
|
response.raise_for_status()
|
||||||
return response.text, response.status_code, None
|
return response.text, response.status_code, None
|
||||||
except RequestException as ex:
|
except RequestException as ex:
|
||||||
logger.debug("fetch_document: exception %s", ex)
|
logger.debug("fetch_document: exception %s", ex)
|
||||||
|
|
Ładowanie…
Reference in New Issue