diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 19366ec9..71513a62 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -1,4 +1,4 @@ -name: django CMS linters.yml +name: json2xml linters.yml on: [push, pull_request] diff --git a/json2xml/utils.py b/json2xml/utils.py index 0859fe27..d5109bdf 100644 --- a/json2xml/utils.py +++ b/json2xml/utils.py @@ -3,7 +3,7 @@ """Utils methods to convert XML data to dict from various sources""" import json -import requests +import urllib3 class JSONReadError(Exception): @@ -43,11 +43,12 @@ def readfromurl(url: str, params: dict[str, str] | None = None) -> dict[str, str """ Loads json from an URL over the internets """ - # TODO: See if we can remove requests too from the deps too. Then, we will become - # zero deps. refernce link here: https://bit.ly/3gzICjU - response = requests.get(url, params=params) - if response.status_code == 200: - data = response.json() + # we need a PoolManager for connection pooling with urllib3. Also, params + # needs to be encoded too + http = urllib3.PoolManager() + response = http.request("GET", url, fields=params) + if response.status == 200: + data = json.loads(response.data.decode('utf-8')) return data raise URLReadError("URL is not returning correct response") diff --git a/requirements.in b/requirements.in index 27964c51..89b27cee 100644 --- a/requirements.in +++ b/requirements.in @@ -1,3 +1,3 @@ -requests>=2.20.0 defusedxml==0.7.1 +urllib3==1.26.13 diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 00000000..83c88aca --- /dev/null +++ b/requirements.txt @@ -0,0 +1,10 @@ +# +# This file is autogenerated by pip-compile with Python 3.11 +# by the following command: +# +# pip-compile +# +defusedxml==0.7.1 + # via -r requirements.in +urllib3==1.26.13 + # via -r requirements.in