summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_urllib.py
Commit message (Collapse)AuthorAgeFilesLines
* gh-105382: Remove urllib.request cafile parameter (#105384)Victor Stinner2023-06-061-9/+0
| | | | Remove cafile, capath and cadefault parameters of the urllib.request.urlopen() function, deprecated in Python 3.6.
* gh-88500: Reduce memory use of `urllib.unquote` (#96763)Gregory P. Smith2022-12-111-0/+2
| | | | | | | | | | | `urllib.unquote_to_bytes` and `urllib.unquote` could both potentially generate `O(len(string))` intermediate `bytes` or `str` objects while computing the unquoted final result depending on the input provided. As Python objects are relatively large, this could consume a lot of ram. This switches the implementation to using an expanding `bytearray` and a generator internally instead of precomputed `split()` style operations. Microbenchmarks with some antagonistic inputs like `mess = "\u0141%%%20a%fe"*1000` show this is 10-20% slower for unquote and unquote_to_bytes and no different for typical inputs that are short or lack much unicode or % escaping. But the functions are already quite fast anyways so not a big deal. The slowdown scales consistently linear with input size as expected. Memory usage observed manually using `/usr/bin/time -v` on `python -m timeit` runs of larger inputs. Unittesting memory consumption is difficult and does not seem worthwhile. Observed memory usage is ~1/2 for `unquote()` and <1/3 for `unquote_to_bytes()` using `python -m timeit -s 'from urllib.parse import unquote, unquote_to_bytes; v="\u0141%01\u0161%20"*500_000' 'unquote_to_bytes(v)'` as a test.
* gh-90473: WASI: skip gethostname tests (GH-93092)Christian Heimes2022-05-231-0/+5
| | | | | | - WASI's ``gethostname()`` is a stub that always fails with OSError ``ENOTSUP`` - skip mailcap ``test`` if subprocess is not available - WASI process_time clock does not work.
* bpo-45046: Support context managers in unittest (GH-28045)Serhiy Storchaka2022-05-081-6/+1
| | | | | | Add methods enterContext() and enterClassContext() in TestCase. Add method enterAsyncContext() in IsolatedAsyncioTestCase. Add function enterModuleContext().
* bpo-43607: Fix urllib handling of Windows paths with \\?\ prefix (GH-25539)Steve Dower2021-04-231-0/+18
|
* bpo-40275: Use new test.support helper submodules in tests (GH-21219)Hai Shi2020-06-301-23/+25
|
* bpo-41069: Make TESTFN and the CWD for tests containing non-ascii ↵Serhiy Storchaka2020-06-251-3/+4
| | | | characters. (GH-21035)
* bpo-38576: Disallow control characters in hostnames in http.client (GH-18995)Ashwin Ramaswami2020-03-141-2/+34
| | | | Add host validation for control characters for more CVE-2019-18348 protection.
* bpo-39057: Fix urllib.request.proxy_bypass_environment(). (GH-17619)Serhiy Storchaka2020-01-051-0/+22
| | | Ignore leading dots and no longer ignore a trailing newline.
* Remove code commented for more than 10 years (GH-16965)Victor Stinner2019-10-281-79/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | test_urllib commented since 2007: commit d9880d07fc032884e8bd5cf3ac636d3a3778d5f7 Author: Facundo Batista <facundobatista@gmail.com> Date: Fri May 25 04:20:22 2007 +0000 Commenting out the tests until find out who can test them in one of the problematic enviroments. pynche code commented since 1998 and 2001: commit ef30092207e684bd3e74fe3d6172b97327a0a089 Author: Barry Warsaw <barry@python.org> Date: Tue Dec 15 01:04:38 1998 +0000 Added most of the mechanism to change the strips from color variations to color constants (i.e. red constant, green constant, blue constant). But I haven't hooked this up yet because the UI gets more crowded and the arrows don't reflect the correct values. Added "Go to Black" and "Go to White" buttons. commit 741eae0b3129c123ed4319d8d9e5b877b09aefa8 Author: Barry Warsaw <barry@python.org> Date: Wed Apr 18 03:51:55 2001 +0000 StripWidget.__init__(), update_yourself(): Removed some unused local variables reported by PyChecker. __togglegentype(): PyChecker accurately reported that the variable __gentypevar was unused -- actually this whole method is currently unused so comment it out.
* bpo-32498: urllib.parse.unquote also accepts bytes (GH-7768)Stein Karlsen2019-10-141-2/+23
|
* bpo-12707: deprecate info(), geturl(), getcode() methods in favor of ↵Ashwin Ramaswami2019-09-131-0/+9
| | | | | headers, url, and status properties for HTTPResponse and addinfourl (GH-11447) Co-Authored-By: epicfaace <aramaswamis@gmail.com>
* bpo-37421: urllib.request tests call urlcleanup() (GH-14529)Victor Stinner2019-07-021-0/+10
| | | | | | | | urllib.request tests now call urlcleanup() to remove temporary files created by urlretrieve() tests and to clear the _opener global variable set by urlopen() and functions calling indirectly urlopen(). regrtest now checks if urllib.request._url_tempfiles and urllib.request._opener are changed by tests.
* bpo-36918: Fix "Exception ignored in" in test_urllib (GH-13996)Victor Stinner2019-06-121-6/+15
| | | | Mock the HTTPConnection.close() method in a few unit tests to avoid logging "Exception ignored in: ..." messages.
* bpo-35907, CVE-2019-9948: urllib rejects local_file:// scheme (GH-13474)Victor Stinner2019-05-221-0/+13
| | | | | | | CVE-2019-9948: Avoid file reading as disallowing the unnecessary URL scheme in URLopener().open() and URLopener().retrieve() of urllib.request. Co-Authored-By: SH <push0ebp@gmail.com>
* bpo-36948: Fix test_urlopener_retrieve_file on Windows (GH-13476)Berker Peksag2019-05-211-1/+2
|
* bpo-36948: Fix NameError in urllib.request.URLopener.retrieve (GH-13389)Xtreak2019-05-191-1/+19
|
* bpo-30458: Use InvalidURL instead of ValueError. (GH-13044)Gregory P. Smith2019-05-011-4/+6
| | | Use http.client.InvalidURL instead of ValueError as the new error case's exception.
* bpo-30458: Disable https related urllib tests on a build without ssl (GH-13032)Xtreak2019-05-011-0/+2
| | | | | | These tests require an SSL enabled build. Skip these tests when python is built without SSL to fix test failures. https://bugs.python.org/issue30458
* bpo-30458: Disallow control chars in http URLs. (GH-12755)Gregory P. Smith2019-05-011-0/+49
| | | Disallow control chars in http URLs in urllib.urlopen. This addresses a potential security problem for applications that do not sanity check their URLs where http request headers could be injected.
* bpo-36019: Use pythontest.net instead of example.com in network tests (GH-11941)Stéphane Wirtel2019-02-221-2/+2
|
* Minor spell fix and formatting fixes in urllib tests. (#959)Senthil Kumaran2017-04-021-1/+5
|
* bpo-16285: Update urllib quoting to RFC 3986 (#173)Ratnadeep Debnath2017-02-251-2/+2
| | | | | | | | | | * bpo-16285: Update urllib quoting to RFC 3986 urllib.parse.quote is now based on RFC 3986, and hence includes `'~'` in the set of characters that is not escaped by default. Patch by Christian Theune and Ratnadeep Debnath.
* Issue #29142: Merge 3.5.Xiang Zhang2017-01-091-1/+2
|\
| * Issue #29142: Fix suffixes in no_proxy handling in urllib.Xiang Zhang2017-01-091-1/+2
| | | | | | | | | | | | In urllib.request, suffixes in no_proxy environment variable with leading dots could match related hostnames again (e.g. .b.c matches a.b.c). Patch by Milan Oberkirch.
| * Issue #27895: Spelling fixes (Contributed by Ville Skyttä).Martin Panter2016-09-071-1/+1
| |
* | Issue #28022: Deprecate ssl-related arguments in favor of SSLContext.Christian Heimes2016-09-101-4/+5
| | | | | | | | | | | | | | The deprecation include manual creation of SSLSocket and certfile/keyfile (or similar) in ftplib, httplib, imaplib, smtplib, poplib and urllib. ssl.wrap_socket() is not marked as deprecated yet.
* | #27364: fix "incorrect" uses of escape character in the stdlib.R David Murray2016-09-081-2/+2
| | | | | | | | | | | | | | And most of the tools. Patch by Emanual Barry, reviewed by me, Serhiy Storchaka, and Martin Panter.
* | Issue #27895: Spelling fixes (Contributed by Ville Skyttä).Raymond Hettinger2016-08-301-1/+1
|/
* [merge from 3.4] - Prevent HTTPoxy attack (CVE-2016-1000110)Senthil Kumaran2016-07-311-0/+12
|\ | | | | | | | | | | | | Ignore the HTTP_PROXY variable when REQUEST_METHOD environment is set, which indicates that the script is in CGI mode. Issue #27568 Reported and patch contributed by Rémi Rampin.
| * [merge from 3.3] Prevent HTTPoxy attack (CVE-2016-1000110)Senthil Kumaran2016-07-311-0/+13
| |\ | | | | | | | | | | | | | | | | | | Ignore the HTTP_PROXY variable when REQUEST_METHOD environment is set, which indicates that the script is in CGI mode. Issue #27568 Reported and patch contributed by Rémi Rampin.
| | * Prevent HTTPoxy attack (CVE-2016-1000110)Senthil Kumaran2016-07-311-0/+13
| | | | | | | | | | | | | | | | | | | | | Ignore the HTTP_PROXY variable when REQUEST_METHOD environment is set, which indicates that the script is in CGI mode. Issue #27568 Reported and patch contributed by Rémi Rampin.
* | | Issue #14132: Fix redirect handling when target is just a query stringMartin Panter2016-05-161-3/+4
| | |
* | | Issue #26864: Fix case insensitivity and suffix comparison with no_proxyMartin Panter2016-04-301-0/+13
| | | | | | | | | | | | Patch by Xiang Zhang.
* | | Issue #26804: urllib.request will prefer lower_case proxy environment variablesSenthil Kumaran2016-04-251-1/+39
| | | | | | | | | | | | | | | | | | over UPPER_CASE or Mixed_Case ones. Patch contributed by Hans-Peter Jansen. Reviewed by Martin Panter and Senthil Kumaran.
* | | Issue #12923: Reset FancyURLopener's redirect counter even on exceptionMartin Panter2016-02-041-6/+25
| | | | | | | | | | | | Based on patches by Brian Brazil and Daniel Rocco.
* | | Issue #25523: Merge "a" to "an" fixes from 3.4 into 3.5Martin Panter2015-11-021-1/+1
|\ \ \ | |/ /
| * | Issue #25523: Correct "a" article to "an" articleMartin Panter2015-11-021-1/+1
| | | | | | | | | | | | | | | | | | This changes the main documentation, doc strings, source code comments, and a couple error messages in the test suite. In some cases the word was removed or edited some other way to fix the grammar.
* | | Added more tests for urllib.parse utility functions.Serhiy Storchaka2015-03-021-15/+0
|\ \ \ | |/ / | | | | | | These functions are not documented but used in third-party code.
| * | Added more tests for urllib.parse utility functions.Serhiy Storchaka2015-03-021-15/+0
| | | | | | | | | | | | These functions are not documented but used in third-party code.
| * | backport context argument of urlopen (#22366) for pep 476Senthil Kumaran2014-09-191-0/+8
| | |
* | | Fix test_urllib without the ssl moduleAntoine Pitrou2014-11-021-1/+5
| | |
* | | Issue #22366: urllib.request.urlopen will accept a context object (SSLContext)Senthil Kumaran2014-09-191-0/+8
| | | | | | | | | | | | | | | | | | as an argument which will then used be for HTTPS connection. Patch by Alex Gaynor.
* | | Issue #19524: Fixed resource leak in the HTTP connection when an invalidSerhiy Storchaka2014-09-061-27/+32
|\ \ \ | |/ / | | | | | | response is received. Patch by Martin Panter.
| * | Issue #19524: Fixed resource leak in the HTTP connection when an invalidSerhiy Storchaka2014-09-061-27/+32
| | | | | | | | | | | | response is received. Patch by Martin Panter.
* | | Issue #21566: Make use of socket.listen() default backlog.Charles-François Natali2014-07-231-1/+1
|/ /
* | in ftp cache pruning, avoid changing the size of a dict while iterating over ↵Benjamin Peterson2014-06-071-1/+31
| | | | | | | | | | | | it (closes #21463) Patch by Skyler Leigh Amador.
* | Issue #20555: Use specific asserts in urllib, httplib, ftplib, cgi, wsgiref ↵Serhiy Storchaka2014-02-081-2/+2
|\ \ | |/ | | | | tests.
| * Issue #20555: Use specific asserts in urllib, httplib, ftplib, cgi, wsgiref ↵Serhiy Storchaka2014-02-081-2/+2
| | | | | | | | tests.
* | #18466: merge with 3.3.Ezio Melotti2013-08-171-1/+1
|\ \ | |/