added http auth and upload functions

This commit is contained in:
Luxferre
2025-12-25 15:51:04 +02:00
parent 1d3b5f99f5
commit c8e908d07b
3 changed files with 6 additions and 5 deletions
+4 -3
View File
@@ -54,10 +54,11 @@ def wget(url, filename='', useragent=None, hdrs={}):
else: filename = ''
return (r.status_code, filename)
def wput(url, file_path, field_name="file", method="POST", format="x-www-form-urlencoded", headers=None):
def wput(url, file_path, field_name="file", method="POST", format="x-www-form-urlencoded", headers={}, useragent=None):
"""Upload a file"""
if headers is None:
headers = {}
if useragent is None:
useragent = DEFAULT_UA
headers['User-Agent'] = useragent
method = method.upper()
try:
with open(file_path, "rb") as f: