summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_httplib.py
Commit message (Collapse)AuthorAgeFilesLines
* gh-102247: http: support rfc9110 status codes (GH-117611)Michiel W. Beijen2024-04-131-7/+14
| | | | | | | | | | | | | | | | | | | | rfc9110 obsoletes the earlier rfc 7231. This document also includes some status codes that were previously only used for WebDAV and assigns more generic names to these status codes. ref: https://www.rfc-editor.org/rfc/rfc9110.html#name-changes-from-rfc-7231 - http.HTTPStatus.CONTENT_TOO_LARGE (413, previously REQUEST_ENTITY_TOO_LARGE) - http.HTTPStatus.URI_TOO_LONG (414, previously REQUEST_URI_TOO_LONG) - http.HTTPStatus.RANGE_NOT_SATISFYABLE (416, previously REQUEST_RANGE_NOT_SATISFYABLE) - http.HTTPStatus.UNPROCESSABLE_CONTENT (422, previously UNPROCESSABLE_ENTITY) The new constants are added to http.HTTPStatus and the old constant names are preserved for backwards compatibility. References in documentation to the obsoleted rfc 7231 are updated
* gh-100985: Consistently wrap IPv6 IP address during CONNECT (GH-100986)Derek Higgins2024-02-171-0/+16
| | | | | | Update _get_hostport to always remove square brackets from IPv6 addresses. Then add them if needed in "CONNECT .." and "Host: ".
* gh-113199: Make read1() and readline() of HTTPResponse close IO after ↵Illia Volochii2023-12-181-2/+14
| | | | reading all data (GH-113200)
* gh-73561: Omit interface scope from IPv6 when used as Host header (#93324)Michael2023-11-191-0/+16
| | | | | | | Omit the `@interface_scope` from an IPv6 address when used as Host header by `http.client`. --------- Co-authored-by: Gregory P. Smith <greg@krypto.org> [Google LLC]
* gh-108303: Move all certificates to `Lib/test/certdata/` (#109489)Nikita Sobolev2023-09-161-3/+5
|
* gh-108416: Mark slow but not CPU bound test methods with ↵Serhiy Storchaka2023-09-051-0/+1
| | | | requires_resource('walltime') (GH-108480)
* gh-105626: Change the default return value of ↵Nikita Sobolev2023-07-141-0/+13
| | | | `HTTPConnection.get_proxy_response_headers` (#105628)
* gh-69152: add method get_proxy_response_headers to HTTPConnection class ↵Alexey Namyotkin2023-05-161-1/+1
| | | | | | | | | | (#104248) Add http.client.HTTPConnection method get_proxy_response_headers() - this is a followup to https://github.com/python/cpython/pull/26152 which added it as a non-public attribute. This way we don't pre-compute a headers dictionary that most users will never access. The new method is properly public and documented and triggers full proxy header parsing into a dict only when actually called. --------- Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com> Co-authored-by: Gregory P. Smith <greg@krypto.org>
* gh-69152: Add _proxy_response_headers attribute to HTTPConnection (#26152)Alexey Namyotkin2023-05-051-0/+14
| | | | | | | Add _proxy_response_headers attribute to HTTPConnection (#26152) --------- Co-authored-by: Senthil Kumaran <senthil@python.org>
* GH-103472: close response in HTTPConnection._tunnel (#103473)Thomas Grainger2023-05-021-0/+23
| | | | | | | | Avoid a potential `ResourceWarning` in `http.client.HTTPConnection` by closing the proxy / tunnel's CONNECT response explicitly. --------- Co-authored-by: Gregory P. Smith <greg@krypto.org>
* gh-66897: Upgrade HTTP CONNECT to protocol HTTP/1.1 (#8305)Michael Handler2023-04-051-15/+132
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * bpo-22708: Upgrade HTTP CONNECT to protocol HTTP/1.1 (GH-NNNN) Use protocol HTTP/1.1 when sending HTTP CONNECT tunnelling requests; generate Host: headers if one is not already provided (required by HTTP/1.1), convert IDN domains to punycode in HTTP CONNECT requests. * Refactor tests to pass under -bb (fix ByteWarnings); missed some lines >80. * Use consistent 'tunnelling' spelling in Lib/http/client.py * Lib/test/test_httplib: Remove remnant of obsoleted test. * Use dict.copy() not copy.copy() * fix version changed * Update Lib/http/client.py Co-authored-by: bgehman <bgehman@users.noreply.github.com> * Switch to for/else: syntax, as suggested * Don't use for: else: * Sure, fine, w/e * Oops * 1nm to the left --------- Co-authored-by: Éric <merwok@netwok.org> Co-authored-by: bgehman <bgehman@users.noreply.github.com> Co-authored-by: Oleg Iarygin <oleg@arhadthedev.net>
* gh-102515: Remove unused imports in the `Lib/` directory (#102516)Alex Waygood2023-03-081-2/+0
|
* gh-94172: Remove keyfile, certfile and check_hostname parameters (#94173)Victor Stinner2022-11-031-31/+12
| | | | | | | | | | | | Remove the keyfile, certfile and check_hostname parameters, deprecated since Python 3.6, in modules: ftplib, http.client, imaplib, poplib and smtplib. Use the context parameter (ssl_context in imaplib) instead. Parameters following the removed parameters become keyword-only parameters. ftplib: Remove the FTP_TLS.ssl_version class attribute: use the context parameter instead.
* gh-95149: Enhance `http.HTTPStatus` with properties that indicate the HTTP ↵Alexandru Mărășteanu2022-08-301-0/+45
| | | | status category (GH-95453)
* bpo-40280: Skip socket, fork, subprocess tests on Emscripten (GH-31986)Christian Heimes2022-03-221-0/+1
| | | | | | | | | | | - Add requires_fork and requires_subprocess to more tests - Skip extension import tests if dlopen is not available - Don't assume that _testcapi is a shared extension - Skip a lot of socket tests that don't work on Emscripten - Skip mmap tests, mmap emulation is incomplete - venv does not work yet - Cannot get libc from executable The "entire" test suite is now passing on Emscripten with EMSDK from git head (91 suites are skipped).
* bpo-44022: Improve the regression test. (GH-26503)Gregory P. Smith2021-06-031-1/+6
| | | | It wasn't actually detecting the regression due to the assertion being too lenient.
* bpo-44022: Fix http client infinite line reading (DoS) after a HTTP 100 ↵Gen Xu2021-05-051-1/+9
| | | | | | | Continue (GH-25916) Fixes http.client potential denial of service where it could get stuck reading lines from a malicious server after a 100 Continue response. Co-authored-by: Gregory P. Smith <greg@krypto.org>
* bpo-43651: Fix EncodingWarning in tests. (GH-25655)Inada Naoki2021-04-291-2/+2
| | | | | * test_httplib * test_httpservers * test_logging
* bpo-38659: [Enum] add _simple_enum decorator (GH-25497)Ethan Furman2021-04-211-0/+145
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | add: * `_simple_enum` decorator to transform a normal class into an enum * `_test_simple_enum` function to compare * `_old_convert_` to enable checking `_convert_` generated enums `_simple_enum` takes a normal class and converts it into an enum: @simple_enum(Enum) class Color: RED = 1 GREEN = 2 BLUE = 3 `_old_convert_` works much like` _convert_` does, using the original logic: # in a test file import socket, enum CheckedAddressFamily = enum._old_convert_( enum.IntEnum, 'AddressFamily', 'socket', lambda C: C.isupper() and C.startswith('AF_'), source=_socket, ) `_test_simple_enum` takes a traditional enum and a simple enum and compares the two: # in the REPL or the same module as Color class CheckedColor(Enum): RED = 1 GREEN = 2 BLUE = 3 _test_simple_enum(CheckedColor, Color) _test_simple_enum(CheckedAddressFamily, socket.AddressFamily) Any important differences will raise a TypeError
* Revert "bpo-38659: [Enum] add _simple_enum decorator (GH-25285)" (GH-25476)Ethan Furman2021-04-201-145/+0
| | | This reverts commit dbac8f40e81eb0a29dc833e6409a1abf47467da6.
* bpo-38659: [Enum] add _simple_enum decorator (GH-25285)Ethan Furman2021-04-201-0/+145
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | add: _simple_enum decorator to transform a normal class into an enum _test_simple_enum function to compare _old_convert_ to enable checking _convert_ generated enums _simple_enum takes a normal class and converts it into an enum: @simple_enum(Enum) class Color: RED = 1 GREEN = 2 BLUE = 3 _old_convert_ works much like _convert_ does, using the original logic: # in a test file import socket, enum CheckedAddressFamily = enum._old_convert_( enum.IntEnum, 'AddressFamily', 'socket', lambda C: C.isupper() and C.startswith('AF_'), source=_socket, ) test_simple_enum takes a traditional enum and a simple enum and compares the two: # in the REPL or the same module as Color class CheckedColor(Enum): RED = 1 GREEN = 2 BLUE = 3 _test_simple_enum(CheckedColor, Color) _test_simple_enum(CheckedAddressFamily, socket.AddressFamily) Any important differences will raise a TypeError
* bpo-43332: Buffer proxy connection setup packets before sending. (GH-24780)Gregory P. Smith2021-03-081-0/+18
| | | | | | We now buffer the CONNECT request + tunnel HTTP headers into a single send call. This prevents the OS from generating multiple network packets for connection setup when not necessary, improving efficiency.
* bpo-40084: Enum - dir() includes member attributes (GH-19219)Angelin BOOZ2020-09-211-1/+5
|
* bpo-41521: Replace whitelist/blacklist with allowlist/denylist (GH-21822)Victor Stinner2020-08-111-2/+2
| | | Automerge-Triggered-By: @tiran
* bpo-39603: Prevent header injection in http methods (GH-18485)AMIR2020-07-181-0/+22
| | | reject control chars in http method in http.client.putrequest to prevent http header injection
* bpo-40275: Use new test.support helper submodules in tests (GH-21314)Hai Shi2020-07-061-9/+12
|
* bpo-41002: Optimize HTTPResponse.read with a given amount (GH-20943)Bruce Merry2020-06-251-0/+27
| | | | | I've done the implementation for both non-chunked and chunked reads. I haven't benchmarked chunked reads because I don't currently have a convenient way to generate a high-bandwidth chunked stream, but I don't see any reason that it shouldn't enjoy the same benefits that the non-chunked case does. I've used the benchmark attached to the bpo bug to verify that performance now matches the unsized read case. Automerge-Triggered-By: @methane
* bpo-40275: Move transient_internet from test.support to socket_helper (GH-19711)Serhiy Storchaka2020-04-291-5/+5
|
* bpo-40275: Avoid importing socket in test.support (GH-19603)Serhiy Storchaka2020-04-251-4/+5
| | | | | | * Move socket related functions from test.support to socket_helper. * Import socket, nntplib and urllib.error lazily in transient_internet(). * Remove importing multiprocess.
* bpo-39507: Add HTTP status 418 "I'm a Teapot" (GH-18291)Ross2020-03-151-0/+1
|
* bpo-38576: Disallow control characters in hostnames in http.client (GH-18995)Ashwin Ramaswami2020-03-141-1/+12
| | | | Add host validation for control characters for more CVE-2019-18348 protection.
* bpo-39509: Update HTTP status code to follow IANA (GH-18294)Dong-hee Na2020-03-141-0/+2
| | | Add status codes 103 EARLY_HINTS and 425 TOO_EARLY.
* bpo-38216, bpo-36274: Allow subclasses to separately override validation and ↵Jason R. Coombs2019-09-281-0/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | encoding behavior (GH-16448) * bpo-38216: Allow bypassing input validation * bpo-36274: Also allow the URL encoding to be overridden. * bpo-38216, bpo-36274: Add tests demonstrating a hook for overriding validation, test demonstrating override encoding, and a test to capture expectation of the interface for the URL. * Call with skip_host to avoid tripping on the host checking in the URL. * Remove obsolete comment. * Make _prepare_path_encoding its own attr. This makes overriding just that simpler. Also, don't use the := operator to make backporting easier. * Add a news entry. * _prepare_path_encoding -> _encode_prepared_path() * Once again separate the path validation and request encoding, drastically simplifying the behavior. Drop the guarantee that all processing happens in _prepare_path.
* bpo-26589: Add http status code 451 (GH-15413)Raymond Hettinger2019-08-231-0/+1
|
* bpo-37795: Capture DeprecationWarnings in the test suite (GH-15184)Pablo Galindo2019-08-081-2/+6
|
* bpo-37440: Enable TLS 1.3 post-handshake auth in http.client (GH-14448)Christian Heimes2019-07-011-0/+18
| | | | | | Post-handshake authentication is required for conditional client cert authentication with TLS 1.3. https://bugs.python.org/issue37440
* bpo-35925: Skip SSL tests that fail due to weak external certs. (GH-13124)Gregory P. Smith2019-05-061-4/+21
| | | | | | | | Modern Linux distros such as Debian Buster have default OpenSSL system configurations that reject connections to servers with weak certificates by default. This causes our test suite run with external networking resources enabled to skip these tests when they encounter such a failure. Fixing the network servers is a separate issue.
* bpo-35934: Add socket.create_server() utility function (GH-11784)Giampaolo Rodola2019-04-081-4/+1
|
* bpo-36522: Print all values for headers with multiple values. (GH-12681)Matt Houglum2019-04-041-2/+4
|
* bpo-33365: print the header values beside the keys (GH-6611)Marco Strigl2018-06-191-0/+15
| | | | | with debuglevel=1 only the header keys got printed. With this change the header values get printed as well and the single header entries get '\n' as a separator.
* bpo-30399: Get rid of trailing comma in the repr of BaseException. (#1650)Serhiy Storchaka2017-11-151-1/+1
|
* bpo-31945: Configurable blocksize in HTTP(S)Connection (#4279)Nir Soffer2017-11-061-0/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | blocksize was hardcoded to 8192, preventing efficient upload when using file-like body. Add blocksize argument to __init__, so users can configure the blocksize to fit their needs. I tested this uploading data from /dev/zero to a web server dropping the received data, to test the overhead of the HTTPConnection.send() with a file-like object. Here is an example 10g upload with the default buffer size (8192): $ time ~/src/cpython/release/python upload-httplib.py 10 https://localhost:8000/ Uploaded 10.00g in 17.53 seconds (584.00m/s) real 0m17.574s user 0m8.887s sys 0m5.971s Same with 512k blocksize: $ time ~/src/cpython/release/python upload-httplib.py 10 https://localhost:8000/ Uploaded 10.00g in 6.60 seconds (1551.15m/s) real 0m6.641s user 0m3.426s sys 0m2.162s In real world usage the difference will be smaller, depending on the local and remote storage and the network. See https://github.com/nirs/http-bench for more info.
* bpo-30553: Add status code 421 to http.HTTPStatus (GH-2589)Vitor Pereira2017-10-261-0/+1
|
* Trivial cleanups following bpo-31370 (#3649)Antoine Pitrou2017-09-181-2/+1
| | | | | | * Trivial cleanups following bpo-31370 * Also cleanup the "importlib._bootstrap_external" module
* bpo-31346: Use PROTOCOL_TLS_CLIENT/SERVER (#3058)Christian Heimes2017-09-151-9/+6
| | | | | | Replaces PROTOCOL_TLSv* and PROTOCOL_SSLv23 with PROTOCOL_TLS_CLIENT and PROTOCOL_TLS_SERVER. Signed-off-by: Christian Heimes <christian@python.org>
* Issue #28394: Merge typo fixes from 3.5 into 3.6Martin Panter2016-10-101-1/+1
|\
| * Issue #28394: Spelling and typo fixes in code comments and changelogMartin Panter2016-10-101-1/+1
| | | | | | | | Includes patch by Ville Skyttä.
* | Issue 28022: Catch deprecation warning in test_httplib, reported by Martin ↵Christian Heimes2016-09-111-6/+9
| | | | | | | | Panter
* | Merge: #22233: Only split headers on \r and/or \n, per email RFCs.R David Murray2016-09-071-0/+30
|\ \ | |/
| * #22233: Only split headers on \r and/or \n, per email RFCs.R David Murray2016-09-071-0/+30
| | | | | | | | Original patch by Martin Panter, new policy fixes by me.