Skip to content

Commit 7cdea5f

Browse files
download_url: add headers argument
1 parent c80fa05 commit 7cdea5f

File tree

1 file changed

+3
-2
lines changed
  • internal_filesystem/builtin/apps/com.micropythonos.appstore/assets

1 file changed

+3
-2
lines changed

internal_filesystem/builtin/apps/com.micropythonos.appstore/assets/appstore.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,18 +186,19 @@ def show_app_detail(self, app):
186186
Optionally:
187187
- progress_callback is called with the % (0-100) progress
188188
- if total_size is not provided, it will be taken from the response headers (if present) or default to 100KB
189+
- a dict of headers can be passed, for example: headers['Range'] = f'bytes={self.bytes_written_so_far}-'
189190
190191
Can return either:
191192
- the actual content
192193
- None: if the content failed to download
193194
- True: if the URL was successfully downloaded (and written to outfile, if provided)
194195
- False: if the URL was not successfully download and written to outfile
195196
'''
196-
async def download_url(self, url, outfile=None, total_size=None, progress_callback=None, chunk_callback=None):
197+
async def download_url(self, url, outfile=None, total_size=None, progress_callback=None, chunk_callback=None, headers=None):
197198
print(f"Downloading {url}")
198199
#await TaskManager.sleep(4) # test slowness
199200
try:
200-
async with self.aiohttp_session.get(url) as response:
201+
async with self.aiohttp_session.get(url, headers=headers) as response:
201202
if response.status < 200 or response.status >= 400:
202203
return False if outfile else None
203204

0 commit comments

Comments
 (0)