Skip to content

Commit

Permalink
Merge pull request #14 from unckan/update-httpx
Browse files Browse the repository at this point in the history
update httpx 0.27.2 ==> 0.28.0
  • Loading branch information
avdata99 authored Dec 4, 2024
2 parents 59a762d + 5448239 commit 7459a0e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Next release

Features:
- Move to https 0.28.0 droping the proxies parameter [#14](https://github.com/unckan/ckanext-superset/pull/14)

# 0.1.7

Features:
Expand Down
14 changes: 6 additions & 8 deletions ckanext/superset/data/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import urllib.parse
import httpx
from ckanext.superset.data.chart import SupersetChart
from httpx import Proxy
from ckanext.superset.data.dataset import SupersetDataset
from ckanext.superset.exceptions import SupersetRequestException

Expand Down Expand Up @@ -38,7 +39,6 @@ def __init__(
self.proxy_pass = urllib.parse.quote(proxy_pass)
else:
self.proxy_pass = None

# Preserve a session for the client (httpx.Client)
self.client = None
# In case we need to login
Expand Down Expand Up @@ -129,7 +129,8 @@ def prepare_connection(self):
log.info(f"Connecting to {self.superset_url}")
if self.proxy_url:
log.info(f"Using proxy {self.proxy_url}:{self.proxy_port}")
self.client = httpx.Client(proxies=self.proxies, http2=False)
proxy = Proxy(self.proxy_full_url)
self.client = httpx.Client(transport=httpx.HTTPTransport(proxy=proxy))
else:
self.client = httpx.Client()

Expand Down Expand Up @@ -212,12 +213,9 @@ def get_headers(self, format_='json'):
return headers

@property
def proxies(self):
""" The httpx proxies dictionary """
return {
"http://": f"http://{self.proxy_user}:{self.proxy_pass}@{self.proxy_url}:{self.proxy_port}",
"https://": f"http://{self.proxy_user}:{self.proxy_pass}@{self.proxy_url}:{self.proxy_port}",
}
def proxy_full_url(self):
""" The httpx proxy full URL with user and password """
return f"http://{self.proxy_user}:{self.proxy_pass}@{self.proxy_url}:{self.proxy_port}"

@property
def login_payload(self):
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# httpx 0.28 drop the proxies param
# TODO read https://github.com/encode/httpx/pull/3419 and update the code
httpx[http2]==0.27.2
httpx[http2]==0.28.0

0 comments on commit 7459a0e

Please sign in to comment.