1414from urllib .parse import quote , urlencode
1515
1616from fastapi import Request
17- from httpx import Client , Limits , ReadTimeout , Response
17+ from httpx import Client
18+ from httpx import Headers as HttpxHeaders
19+ from httpx import Limits , ReadTimeout , Response
1820
1921try :
2022 from xxhash import xxh64
@@ -137,6 +139,7 @@ class NcSessionBasic(ABC):
137139 user : str
138140 custom_headers : dict
139141 _capabilities : dict
142+ response_headers : HttpxHeaders
140143
141144 @abstractmethod
142145 def __init__ (self , ** kwargs ):
@@ -145,6 +148,7 @@ def __init__(self, **kwargs):
145148 self .custom_headers = kwargs .get ("headers" , {})
146149 self .limits = Limits (max_keepalive_connections = 20 , max_connections = 20 , keepalive_expiry = 60.0 )
147150 self .init_adapter ()
151+ self .response_headers = HttpxHeaders ()
148152
149153 def __del__ (self ):
150154 if hasattr (self , "adapter" ) and self .adapter :
@@ -200,6 +204,7 @@ def _ocs(self, method: str, path_params: str, headers: dict, data: Optional[byte
200204 except ReadTimeout :
201205 raise NextcloudException (408 , info = info ) from None
202206
207+ self .response_headers = response .headers
203208 check_error (response .status_code , info )
204209 response_data = loads (response .text )
205210 ocs_meta = response_data ["ocs" ]["meta" ]
@@ -235,11 +240,12 @@ def dav_stream(
235240
236241 def _dav (self , method : str , path : str , headers : dict , data : Optional [bytes ], ** kwargs ) -> Response :
237242 self .init_adapter ()
238- # self.cfg.
239243 timeout = kwargs .pop ("timeout" , self .cfg .options .timeout_dav )
240- return self .adapter .request (
244+ result = self .adapter .request (
241245 method , self .cfg .endpoint + path , headers = headers , content = data , timeout = timeout , ** kwargs
242246 )
247+ self .response_headers = result .headers
248+ return result
243249
244250 def _dav_stream (self , method : str , path : str , headers : dict , data : Optional [bytes ], ** kwargs ) -> Iterator [Response ]:
245251 self .init_adapter ()
0 commit comments