MCPcopy Index your code
hub / github.com/SourceCode-AI/aura / proxy

Method proxy

aura/cache.py:189–214  ·  view source on GitHub ↗
(cls, *, url: str, cache_id=None, tags=None, session=None, throw_exc=True)

Source from the content-addressed store, hash-verified

187
188 @classmethod
189 def proxy(cls, *, url: str, cache_id=None, tags=None, session=None, throw_exc=True) -> str:
190 if session is None:
191 session = requests
192
193 if cls.get_location() is None:
194 resp = session.get(url)
195 if throw_exc:
196 resp.raise_for_status()
197 return resp.text
198
199 cache_obj = cls(url=url, cache_id=cache_id, tags=tags)
200
201 if cache_obj.is_valid:
202 logger.info(f"Loading {cache_obj.cid} from cache")
203 return cache_obj.fetch()
204
205 try:
206 resp = session.get(url)
207 if throw_exc:
208 resp.raise_for_status()
209 cache_obj.cache_file_location.write_text(resp.text)
210 cache_obj.save_metadata()
211 return resp.text
212 except Exception:
213 cache_obj.delete()
214 raise
215
216 @property
217 def metadata(self) -> dict:

Callers

nothing calls this directly

Calls 5

get_locationMethod · 0.80
getMethod · 0.80
save_metadataMethod · 0.80
fetchMethod · 0.45
deleteMethod · 0.45

Tested by

no test coverage detected