Skip to content

Commit 5fdf4ad

Browse files
authored
Add files via upload
1 parent 81b3f8d commit 5fdf4ad

4 files changed

Lines changed: 84 additions & 84 deletions

File tree

pywwwget_chatgpt.py

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2480,21 +2480,21 @@ def download_file_from_http_file(url, headers=None, usehttp=__use_http_lib__, re
24802480
headers.update({'Content-Length': str(putfile.tell())})
24812481
putfile.seek(0, 0)
24822482
extendargs.update({'content': putfile})
2483-
extendargs.update({'headers': headers})
2484-
try:
2485-
with client.stream(**extendargs, ) as r:
2486-
decoded_headers = decode_headers_any(r.headers)
2487-
if(resumefile is not None and hasattr(resumefile, "write")):
2488-
if r.status == 206 and "Content-Range" in decoded_headers:
2489-
pass
2490-
else:
2491-
httpfile.truncate(0)
2492-
httpfile.seek(0, 0)
2493-
for chunk in r.iter_stream():
2494-
if chunk:
2495-
httpfile.write(chunk)
2496-
except (socket.timeout, socket.gaierror, httpcore.ConnectError):
2497-
return False
2483+
extendargs.update({'headers': headers})
2484+
try:
2485+
with client.stream(**extendargs, ) as r:
2486+
decoded_headers = decode_headers_any(r.headers)
2487+
if(resumefile is not None and hasattr(resumefile, "write")):
2488+
if r.status == 206 and "Content-Range" in decoded_headers:
2489+
pass
2490+
else:
2491+
httpfile.truncate(0)
2492+
httpfile.seek(0, 0)
2493+
for chunk in r.iter_stream():
2494+
if chunk:
2495+
httpfile.write(chunk)
2496+
except (socket.timeout, socket.gaierror, httpcore.ConnectError):
2497+
return False
24982498
httpcookie.save(cookiefile, ignore_discard=True, ignore_expires=True)
24992499
httpcodeout = r.status
25002500
httpcodereason = http_status_to_reason(r.status)
@@ -2547,7 +2547,7 @@ def download_file_from_http_file(url, headers=None, usehttp=__use_http_lib__, re
25472547
except (socket.timeout, socket.gaierror, URLError):
25482548
return False
25492549
if(resumefile is not None and hasattr(resumefile, "write")):
2550-
if resp.code == 206 and "Content-Range" in resp.info():
2550+
if resp.code == 206 and "Content-Range" in dict(resp.info()):
25512551
pass
25522552
else:
25532553
httpfile.truncate(0)
@@ -2566,7 +2566,7 @@ def download_file_from_http_file(url, headers=None, usehttp=__use_http_lib__, re
25662566
httpversionout = "HTTP/1.1"
25672567
httpmethodout = httpmethod
25682568
httpurlout = resp.geturl()
2569-
httpheaderout = resp.info()
2569+
httpheaderout = dict(resp.info())
25702570
reqhead = br.request
25712571
httpheadersentout = reqhead.header_items()
25722572
httpsession = br
@@ -2632,7 +2632,7 @@ def download_file_from_http_file(url, headers=None, usehttp=__use_http_lib__, re
26322632
except (socket.timeout, socket.gaierror, urllib3.exceptions.MaxRetryError):
26332633
return False
26342634
if(resumefile is not None and hasattr(resumefile, "write")):
2635-
if resp.status == 206 and "Content-Range" in resp.info():
2635+
if resp.status == 206 and "Content-Range" in dict(resp.info()):
26362636
pass
26372637
else:
26382638
httpfile.truncate(0)
@@ -2651,7 +2651,7 @@ def download_file_from_http_file(url, headers=None, usehttp=__use_http_lib__, re
26512651
httpversionout = "HTTP/1.1"
26522652
httpmethodout = httpmethod
26532653
httpurlout = resp.geturl()
2654-
httpheaderout = resp.info()
2654+
httpheaderout = dict(resp.info())
26552655
httpheadersentout = headers
26562656
resp.release_conn()
26572657
httpsession = http
@@ -2824,7 +2824,7 @@ def download_file_from_http_file(url, headers=None, usehttp=__use_http_lib__, re
28242824
return False
28252825
resp2 = decoded_stream(resp)
28262826
if(resumefile is not None and hasattr(resumefile, "write")):
2827-
if resp.getcode() == 206 and "Content-Range" in resp.info():
2827+
if resp.getcode() == 206 and "Content-Range" in dict(resp.info()):
28282828
pass
28292829
else:
28302830
httpfile.truncate(0)
@@ -2849,7 +2849,7 @@ def download_file_from_http_file(url, headers=None, usehttp=__use_http_lib__, re
28492849
except AttributeError:
28502850
httpmethodout = resp._method
28512851
httpurlout = resp.geturl()
2852-
httpheaderout = resp.info()
2852+
httpheaderout = dict(resp.info())
28532853
try:
28542854
httpheadersentout = req.unredirected_hdrs | req.headers
28552855
except AttributeError:

pywwwget_deepseek.py

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2595,21 +2595,21 @@ def download_file_from_http_file(url, headers=None, usehttp=__use_http_lib__, re
25952595
headers.update({'Content-Length': str(putfile.tell())})
25962596
putfile.seek(0, 0)
25972597
extendargs.update({'content': putfile})
2598-
extendargs.update({'headers': headers})
2599-
try:
2600-
with client.stream(**extendargs, ) as r:
2601-
decoded_headers = decode_headers_any(r.headers)
2602-
if(resumefile is not None and hasattr(resumefile, "write")):
2603-
if r.status == 206 and "Content-Range" in decoded_headers:
2604-
pass
2605-
else:
2606-
httpfile.truncate(0)
2607-
httpfile.seek(0, 0)
2608-
for chunk in r.iter_stream():
2609-
if chunk:
2610-
httpfile.write(chunk)
2611-
except (socket.timeout, socket.gaierror, httpcore.ConnectError):
2612-
return False
2598+
extendargs.update({'headers': headers})
2599+
try:
2600+
with client.stream(**extendargs, ) as r:
2601+
decoded_headers = decode_headers_any(r.headers)
2602+
if(resumefile is not None and hasattr(resumefile, "write")):
2603+
if r.status == 206 and "Content-Range" in decoded_headers:
2604+
pass
2605+
else:
2606+
httpfile.truncate(0)
2607+
httpfile.seek(0, 0)
2608+
for chunk in r.iter_stream():
2609+
if chunk:
2610+
httpfile.write(chunk)
2611+
except (socket.timeout, socket.gaierror, httpcore.ConnectError):
2612+
return False
26132613
httpcookie.save(cookiefile, ignore_discard=True, ignore_expires=True)
26142614
httpcodeout = r.status
26152615
httpcodereason = http_status_to_reason(r.status)
@@ -2662,7 +2662,7 @@ def download_file_from_http_file(url, headers=None, usehttp=__use_http_lib__, re
26622662
except (socket.timeout, socket.gaierror, URLError):
26632663
return False
26642664
if(resumefile is not None and hasattr(resumefile, "write")):
2665-
if resp.code == 206 and "Content-Range" in resp.info():
2665+
if resp.code == 206 and "Content-Range" in dict(resp.info()):
26662666
pass
26672667
else:
26682668
httpfile.truncate(0)
@@ -2681,7 +2681,7 @@ def download_file_from_http_file(url, headers=None, usehttp=__use_http_lib__, re
26812681
httpversionout = "HTTP/1.1"
26822682
httpmethodout = httpmethod
26832683
httpurlout = resp.geturl()
2684-
httpheaderout = resp.info()
2684+
httpheaderout = dict(resp.info())
26852685
reqhead = br.request
26862686
httpheadersentout = reqhead.header_items()
26872687
httpsession = br
@@ -2747,7 +2747,7 @@ def download_file_from_http_file(url, headers=None, usehttp=__use_http_lib__, re
27472747
except (socket.timeout, socket.gaierror, urllib3.exceptions.MaxRetryError):
27482748
return False
27492749
if(resumefile is not None and hasattr(resumefile, "write")):
2750-
if resp.status == 206 and "Content-Range" in resp.info():
2750+
if resp.status == 206 and "Content-Range" in dict(resp.info()):
27512751
pass
27522752
else:
27532753
httpfile.truncate(0)
@@ -2766,7 +2766,7 @@ def download_file_from_http_file(url, headers=None, usehttp=__use_http_lib__, re
27662766
httpversionout = "HTTP/1.1"
27672767
httpmethodout = httpmethod
27682768
httpurlout = resp.geturl()
2769-
httpheaderout = resp.info()
2769+
httpheaderout = dict(resp.info())
27702770
httpheadersentout = headers
27712771
resp.release_conn()
27722772
httpsession = http
@@ -2939,7 +2939,7 @@ def download_file_from_http_file(url, headers=None, usehttp=__use_http_lib__, re
29392939
return False
29402940
resp2 = decoded_stream(resp)
29412941
if(resumefile is not None and hasattr(resumefile, "write")):
2942-
if resp.getcode() == 206 and "Content-Range" in resp.info():
2942+
if resp.getcode() == 206 and "Content-Range" in dict(resp.info()):
29432943
pass
29442944
else:
29452945
httpfile.truncate(0)
@@ -2964,7 +2964,7 @@ def download_file_from_http_file(url, headers=None, usehttp=__use_http_lib__, re
29642964
except AttributeError:
29652965
httpmethodout = resp._method
29662966
httpurlout = resp.geturl()
2967-
httpheaderout = resp.info()
2967+
httpheaderout = dict(resp.info())
29682968
try:
29692969
httpheadersentout = req.unredirected_hdrs | req.headers
29702970
except AttributeError:

pywwwget_merged.py

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2515,21 +2515,21 @@ def download_file_from_http_file(url, headers=None, usehttp=__use_http_lib__, re
25152515
headers.update({'Content-Length': str(putfile.tell())})
25162516
putfile.seek(0, 0)
25172517
extendargs.update({'content': putfile})
2518-
extendargs.update({'headers': headers})
2519-
try:
2520-
with client.stream(**extendargs, ) as r:
2521-
decoded_headers = decode_headers_any(r.headers)
2522-
if(resumefile is not None and hasattr(resumefile, "write")):
2523-
if r.status == 206 and "Content-Range" in decoded_headers:
2524-
pass
2525-
else:
2526-
httpfile.truncate(0)
2527-
httpfile.seek(0, 0)
2528-
for chunk in r.iter_stream():
2529-
if chunk:
2530-
httpfile.write(chunk)
2531-
except (socket.timeout, socket.gaierror, httpcore.ConnectError):
2532-
return False
2518+
extendargs.update({'headers': headers})
2519+
try:
2520+
with client.stream(**extendargs, ) as r:
2521+
decoded_headers = decode_headers_any(r.headers)
2522+
if(resumefile is not None and hasattr(resumefile, "write")):
2523+
if r.status == 206 and "Content-Range" in decoded_headers:
2524+
pass
2525+
else:
2526+
httpfile.truncate(0)
2527+
httpfile.seek(0, 0)
2528+
for chunk in r.iter_stream():
2529+
if chunk:
2530+
httpfile.write(chunk)
2531+
except (socket.timeout, socket.gaierror, httpcore.ConnectError):
2532+
return False
25332533
httpcookie.save(cookiefile, ignore_discard=True, ignore_expires=True)
25342534
httpcodeout = r.status
25352535
httpcodereason = http_status_to_reason(r.status)
@@ -2582,7 +2582,7 @@ def download_file_from_http_file(url, headers=None, usehttp=__use_http_lib__, re
25822582
except (socket.timeout, socket.gaierror, URLError):
25832583
return False
25842584
if(resumefile is not None and hasattr(resumefile, "write")):
2585-
if resp.code == 206 and "Content-Range" in resp.info():
2585+
if resp.code == 206 and "Content-Range" in dict(resp.info()):
25862586
pass
25872587
else:
25882588
httpfile.truncate(0)
@@ -2601,7 +2601,7 @@ def download_file_from_http_file(url, headers=None, usehttp=__use_http_lib__, re
26012601
httpversionout = "HTTP/1.1"
26022602
httpmethodout = httpmethod
26032603
httpurlout = resp.geturl()
2604-
httpheaderout = resp.info()
2604+
httpheaderout = dict(resp.info())
26052605
reqhead = br.request
26062606
httpheadersentout = reqhead.header_items()
26072607
httpsession = br
@@ -2667,7 +2667,7 @@ def download_file_from_http_file(url, headers=None, usehttp=__use_http_lib__, re
26672667
except (socket.timeout, socket.gaierror, urllib3.exceptions.MaxRetryError):
26682668
return False
26692669
if(resumefile is not None and hasattr(resumefile, "write")):
2670-
if resp.status == 206 and "Content-Range" in resp.info():
2670+
if resp.status == 206 and "Content-Range" in dict(resp.info()):
26712671
pass
26722672
else:
26732673
httpfile.truncate(0)
@@ -2686,7 +2686,7 @@ def download_file_from_http_file(url, headers=None, usehttp=__use_http_lib__, re
26862686
httpversionout = "HTTP/1.1"
26872687
httpmethodout = httpmethod
26882688
httpurlout = resp.geturl()
2689-
httpheaderout = resp.info()
2689+
httpheaderout = dict(resp.info())
26902690
httpheadersentout = headers
26912691
resp.release_conn()
26922692
httpsession = http
@@ -2859,7 +2859,7 @@ def download_file_from_http_file(url, headers=None, usehttp=__use_http_lib__, re
28592859
return False
28602860
resp2 = decoded_stream(resp)
28612861
if(resumefile is not None and hasattr(resumefile, "write")):
2862-
if resp.getcode() == 206 and "Content-Range" in resp.info():
2862+
if resp.getcode() == 206 and "Content-Range" in dict(resp.info()):
28632863
pass
28642864
else:
28652865
httpfile.truncate(0)
@@ -2884,7 +2884,7 @@ def download_file_from_http_file(url, headers=None, usehttp=__use_http_lib__, re
28842884
except AttributeError:
28852885
httpmethodout = resp._method
28862886
httpurlout = resp.geturl()
2887-
httpheaderout = resp.info()
2887+
httpheaderout = dict(resp.info())
28882888
try:
28892889
httpheadersentout = req.unredirected_hdrs | req.headers
28902890
except AttributeError:

pywwwget_nextver.py

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2496,21 +2496,21 @@ def download_file_from_http_file(url, headers=None, usehttp=__use_http_lib__, re
24962496
headers.update({'Content-Length': str(putfile.tell())})
24972497
putfile.seek(0, 0)
24982498
extendargs.update({'content': putfile})
2499-
extendargs.update({'headers': headers})
2500-
try:
2501-
with client.stream(**extendargs, ) as r:
2502-
decoded_headers = decode_headers_any(r.headers)
2503-
if(resumefile is not None and hasattr(resumefile, "write")):
2504-
if r.status == 206 and "Content-Range" in decoded_headers:
2505-
pass
2506-
else:
2507-
httpfile.truncate(0)
2508-
httpfile.seek(0, 0)
2509-
for chunk in r.iter_stream():
2510-
if chunk:
2511-
httpfile.write(chunk)
2512-
except (socket.timeout, socket.gaierror, httpcore.ConnectError):
2513-
return False
2499+
extendargs.update({'headers': headers})
2500+
try:
2501+
with client.stream(**extendargs, ) as r:
2502+
decoded_headers = decode_headers_any(r.headers)
2503+
if(resumefile is not None and hasattr(resumefile, "write")):
2504+
if r.status == 206 and "Content-Range" in decoded_headers:
2505+
pass
2506+
else:
2507+
httpfile.truncate(0)
2508+
httpfile.seek(0, 0)
2509+
for chunk in r.iter_stream():
2510+
if chunk:
2511+
httpfile.write(chunk)
2512+
except (socket.timeout, socket.gaierror, httpcore.ConnectError):
2513+
return False
25142514
httpcookie.save(cookiefile, ignore_discard=True, ignore_expires=True)
25152515
httpcodeout = r.status
25162516
httpcodereason = http_status_to_reason(r.status)
@@ -2563,7 +2563,7 @@ def download_file_from_http_file(url, headers=None, usehttp=__use_http_lib__, re
25632563
except (socket.timeout, socket.gaierror, URLError):
25642564
return False
25652565
if(resumefile is not None and hasattr(resumefile, "write")):
2566-
if resp.code == 206 and "Content-Range" in resp.info():
2566+
if resp.code == 206 and "Content-Range" in dict(resp.info()):
25672567
pass
25682568
else:
25692569
httpfile.truncate(0)
@@ -2582,7 +2582,7 @@ def download_file_from_http_file(url, headers=None, usehttp=__use_http_lib__, re
25822582
httpversionout = "HTTP/1.1"
25832583
httpmethodout = httpmethod
25842584
httpurlout = resp.geturl()
2585-
httpheaderout = resp.info()
2585+
httpheaderout = dict(resp.info())
25862586
reqhead = br.request
25872587
httpheadersentout = reqhead.header_items()
25882588
httpsession = br
@@ -2648,7 +2648,7 @@ def download_file_from_http_file(url, headers=None, usehttp=__use_http_lib__, re
26482648
except (socket.timeout, socket.gaierror, urllib3.exceptions.MaxRetryError):
26492649
return False
26502650
if(resumefile is not None and hasattr(resumefile, "write")):
2651-
if resp.status == 206 and "Content-Range" in resp.info():
2651+
if resp.status == 206 and "Content-Range" in dict(resp.info()):
26522652
pass
26532653
else:
26542654
httpfile.truncate(0)
@@ -2667,7 +2667,7 @@ def download_file_from_http_file(url, headers=None, usehttp=__use_http_lib__, re
26672667
httpversionout = "HTTP/1.1"
26682668
httpmethodout = httpmethod
26692669
httpurlout = resp.geturl()
2670-
httpheaderout = resp.info()
2670+
httpheaderout = dict(resp.info())
26712671
httpheadersentout = headers
26722672
resp.release_conn()
26732673
httpsession = http
@@ -2840,7 +2840,7 @@ def download_file_from_http_file(url, headers=None, usehttp=__use_http_lib__, re
28402840
return False
28412841
resp2 = decoded_stream(resp)
28422842
if(resumefile is not None and hasattr(resumefile, "write")):
2843-
if resp.getcode() == 206 and "Content-Range" in resp.info():
2843+
if resp.getcode() == 206 and "Content-Range" in dict(resp.info()):
28442844
pass
28452845
else:
28462846
httpfile.truncate(0)
@@ -2865,7 +2865,7 @@ def download_file_from_http_file(url, headers=None, usehttp=__use_http_lib__, re
28652865
except AttributeError:
28662866
httpmethodout = resp._method
28672867
httpurlout = resp.geturl()
2868-
httpheaderout = resp.info()
2868+
httpheaderout = dict(resp.info())
28692869
try:
28702870
httpheadersentout = req.unredirected_hdrs | req.headers
28712871
except AttributeError:

0 commit comments

Comments
 (0)