Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import attr
from aiohttp import ClientRequest, hdrs, helpers
from async_exit_stack import AsyncExitStack
from async_generator import async_generator, asynccontextmanager, yield_
from async_lru import alru_cache
from oauthlib.oauth1 import Client as OAuth1Client
from pyrsistent import freeze
from yarl import URL
from studip_fuse.studipfs.api.aiobase import BaseHTTPClient
from studip_fuse.studipfs.api.aiointerface import Download
log = logging.getLogger(__name__)
async_stat = aiofiles.os.stat
async_utime = aiofiles.os.wrap(os.utime)
class AuthenticatedClientRequest(ClientRequest):
def update_auth(self, auth):
if auth is None:
auth = self.auth
if auth is None:
return
if isinstance(auth, helpers.BasicAuth):
self.headers[hdrs.AUTHORIZATION] = auth.encode()
elif isinstance(auth, OAuth1Client):
url, headers, _ = auth.sign(
str(self.url), str(self.method), None, self.headers
)
self.url = URL(url)