]> granicus.if.org Git - python/commitdiff
Issue #22450: Use "Accept: */*" in the default headers for urllib
authorRaymond Hettinger <python@rcn.com>
Fri, 9 Sep 2016 23:23:06 +0000 (16:23 -0700)
committerRaymond Hettinger <python@rcn.com>
Fri, 9 Sep 2016 23:23:06 +0000 (16:23 -0700)
Lib/urllib.py
Misc/NEWS

index c3ba2c94cbfacf1bf3e6365c37fdd046d45ec183..7f70496b635a34c963ccd1af9cb3a00839caaae3 100644 (file)
@@ -138,7 +138,7 @@ class URLopener:
         self.key_file = x509.get('key_file')
         self.cert_file = x509.get('cert_file')
         self.context = context
-        self.addheaders = [('User-Agent', self.version)]
+        self.addheaders = [('User-Agent', self.version), ('Accept', '*/*')]
         self.__tempfiles = []
         self.__unlink = os.unlink # See cleanup()
         self.tempcache = None
index 63ec3bfaf76e21449dd2e400903f2fb406c83d9a..5f3eccb93c111e86c3e4782730e8b8ec5fcc7e4d 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -47,6 +47,10 @@ Library
 - Issue #27570: Avoid zero-length memcpy() etc calls with null source
   pointers in the "ctypes" and "array" modules.
 
+- Issue #22450: urllib now includes an "Accept: */*" header among the
+  default headers.  This makes the results of REST API requests more
+  consistent and predictable especially when proxy servers are involved.
+
 - lib2to3.pgen3.driver.load_grammar() now creates a stable cache file
   between runs given the same Grammar.txt input regardless of the hash
   randomization setting.