MCPcopy Create free account
hub / github.com/ambianic/peerfetch / _fetch

Function _fetch

python/src/peerfetch/proxy.py:190–208  ·  view source on GitHub ↗
(url: str = None, method: str = 'GET', json: str = None, data = None)

Source from the content-addressed store, hash-verified

188
189
190async def _fetch(url: str = None, method: str = 'GET', json: str = None, data = None) -> Any:
191 logger.debug(f'_fetch( url="${url}" , method="${method}", data="${data}"')
192 global http_session
193 if method == 'GET':
194 async with http_session.get(url) as response:
195 content = await response.read()
196 return response, content
197 elif method == 'PUT':
198 async with http_session.put(url) as response:
199 content = await response.read()
200 return response, content
201 elif method == 'POST':
202 async with http_session.post(url, json=json, data=data ) as response:
203 content = await response.read()
204 return response, content
205 else:
206 raise NotImplementedError(
207 f'HTTP method ${method} not implemented.'
208 ' Contributions welcome!')
209
210
211async def _pong(peer_connection=None):

Callers 1

pc_dataFunction · 0.85

Calls 3

getMethod · 0.80
putMethod · 0.80
postMethod · 0.80

Tested by

no test coverage detected