Skip to content

Commit

Permalink
Update MadApkDownloadEndpoint.py
Browse files Browse the repository at this point in the history
  • Loading branch information
JabLuszko authored Sep 21, 2024
1 parent 8f8a356 commit 82d67a3
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

from aiohttp import web

from loguru import logger

from mapadroid.mad_apk.utils import stream_package
from mapadroid.mitm_receiver.endpoints.AbstractMitmReceiverRootEndpoint import AbstractMitmReceiverRootEndpoint

Expand All @@ -16,20 +18,18 @@ class MadApkDownloadEndpoint(AbstractMitmReceiverRootEndpoint):

# TODO: Auth/preprocessing for autoconfig?
async def head(self):
logger.info("Device {} checking package {} (arch: {}) content-type", self.request.headers["origin"],
self.request.match_info.get('apk_type'), self.request.match_info.get('apk_arch'))
data_generator, response = await self.__handle_download_request()
return response

async def get(self):
logger.info("Device {} downloading package {} (arch: {})", self.request.headers["origin"],
self.request.match_info.get('apk_type'), self.request.match_info.get('apk_arch'))
data_generator, response = await self.__handle_download_request()
async for data in data_generator:
await response.write(data)
return response

async def __handle_download_request(self):
logger.info("Device {} downloading package {} (arch: {}) content-type", self.request.headers["origin"],
self.request.match_info.get('apk_type'), self.request.match_info.get('apk_arch'))
parsed = self._parse_frontend()
apk_type, apk_arch = parsed
response = web.StreamResponse()
Expand Down

0 comments on commit 82d67a3

Please sign in to comment.