Skip to content

Commit ae9e5f0

Browse files
committed
Issue #22450: Use "Accept: */*" in the default headers for urllib.request
1 parent c87ae80 commit ae9e5f0

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

Lib/urllib/request.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1625,7 +1625,7 @@ def __init__(self, proxies=None, **x509):
16251625
self.proxies = proxies
16261626
self.key_file = x509.get('key_file')
16271627
self.cert_file = x509.get('cert_file')
1628-
self.addheaders = [('User-Agent', self.version)]
1628+
self.addheaders = [('User-Agent', self.version), ('Accept', '*/*')]
16291629
self.__tempfiles = []
16301630
self.__unlink = os.unlink # See cleanup()
16311631
self.tempcache = None

Misc/NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@ Library
7070
- Issue #27445: Don't pass str(_charset) to MIMEText.set_payload().
7171
Patch by Claude Paroz.
7272

73+
- Issue #22450: urllib now includes an "Accept: */*" header among the
74+
default headers. This makes the results of REST API requests more
75+
consistent and predictable especially when proxy servers are involved.
76+
7377
- lib2to3.pgen3.driver.load_grammar() now creates a stable cache file
7478
between runs given the same Grammar.txt input regardless of the hash
7579
randomization setting.

0 commit comments

Comments
 (0)