1616 from collections .abc import Sequence
1717
1818import numpy as np
19+ import requests
1920
2021import blosc2
2122
22- if not blosc2 .IS_WASM :
23- import httpx
24-
2523_subscriber_data = {
2624 "urlbase" : os .environ .get ("BLOSC_C2URLBASE" ),
2725 "auth_token" : "" ,
@@ -110,15 +108,15 @@ def _xget(url, params=None, headers=None, auth_token=None, timeout=TIMEOUT):
110108 if auth_token :
111109 headers = headers .copy () if headers else {}
112110 headers ["Cookie" ] = auth_token
113- response = httpx .get (url , params = params , headers = headers , timeout = timeout )
111+ response = requests .get (url , params = params , headers = headers , timeout = timeout )
114112 response .raise_for_status ()
115113 return response
116114
117115
118116def _xpost (url , json = None , auth_token = None , timeout = TIMEOUT ):
119117 auth_token = auth_token or _subscriber_data ["auth_token" ]
120118 headers = {"Cookie" : auth_token } if auth_token else None
121- response = httpx .post (url , json = json , headers = headers , timeout = timeout )
119+ response = requests .post (url , json = json , headers = headers , timeout = timeout )
122120 response .raise_for_status ()
123121 return response .json ()
124122
@@ -133,7 +131,7 @@ def _sub_url(urlbase, path):
133131def login (username , password , urlbase ):
134132 url = _sub_url (urlbase , "auth/jwt/login" )
135133 creds = {"username" : username , "password" : password }
136- resp = httpx .post (url , data = creds , timeout = TIMEOUT )
134+ resp = requests .post (url , data = creds , timeout = TIMEOUT )
137135 resp .raise_for_status ()
138136 return "=" .join (list (resp .cookies .items ())[0 ])
139137
@@ -229,14 +227,14 @@ def __init__(self, path: str, /, urlbase: str | None = None, auth_token: str | N
229227 # Try to 'open' the remote path
230228 try :
231229 self .meta = info (self .path , self .urlbase , auth_token = self .auth_token )
232- except httpx . HTTPStatusError :
230+ except requests . HTTPError :
233231 # Subscribe to root and try again. It is less latency to subscribe directly
234232 # than to check for the subscription.
235233 root , _ = self .path .split ("/" , 1 )
236234 subscribe (root , self .urlbase , self .auth_token )
237235 try :
238236 self .meta = info (self .path , self .urlbase , auth_token = self .auth_token )
239- except httpx . HTTPStatusError as err :
237+ except requests . HTTPError as err :
240238 raise FileNotFoundError (f"Remote path not found: { path } .\n Error was: { err } " ) from err
241239 cparams = self .meta ["schunk" ]["cparams" ]
242240 # Remove "filters, meta" from cparams; this is an artifact from the server
0 commit comments