mirror of
https://github.com/python/cpython.git
synced 2025-12-23 09:19:18 +00:00
gh-87497: Document that urllib.request sends headers in camel case (GH-24661)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
(cherry picked from commit 325d6f5035)
Co-authored-by: Alix Lourme <alix.lourme@gmail.com>
This commit is contained in:
parent
edf1a77f23
commit
0ab5e83ff7
2 changed files with 10 additions and 0 deletions
|
|
@ -213,6 +213,7 @@ The following classes are provided:
|
|||
(X11; U; Linux i686) Gecko/20071127 Firefox/2.0.0.11"``, while
|
||||
:mod:`urllib`'s default user agent string is
|
||||
``"Python-urllib/2.6"`` (on Python 2.6).
|
||||
All header keys are sent in camel case.
|
||||
|
||||
An appropriate ``Content-Type`` header should be included if the *data*
|
||||
argument is present. If this header has not been provided and *data*
|
||||
|
|
|
|||
|
|
@ -613,6 +613,15 @@ class TestUrlopen(unittest.TestCase):
|
|||
pass
|
||||
self.assertEqual(handler.headers_received["Range"], "bytes=20-39")
|
||||
|
||||
def test_sending_headers_camel(self):
|
||||
handler = self.start_server()
|
||||
req = urllib.request.Request("http://localhost:%s/" % handler.port,
|
||||
headers={"X-SoMe-hEader": "foobar"})
|
||||
with urllib.request.urlopen(req):
|
||||
pass
|
||||
self.assertIn("X-Some-Header", handler.headers_received.keys())
|
||||
self.assertNotIn("X-SoMe-hEader", handler.headers_received.keys())
|
||||
|
||||
def test_basic(self):
|
||||
handler = self.start_server()
|
||||
with urllib.request.urlopen("http://localhost:%s" % handler.port) as open_url:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue