mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
bpo-37363: Add audit events to the http.client
module (GH-21321)
Add audit events to the `http.client` module Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
This commit is contained in:
parent
32980fb669
commit
927b841c21
5 changed files with 41 additions and 0 deletions
|
@ -341,6 +341,24 @@ def test_gc():
|
|||
gc.get_referents(y)
|
||||
|
||||
|
||||
def test_http_client():
|
||||
import http.client
|
||||
|
||||
def hook(event, args):
|
||||
if event.startswith("http.client."):
|
||||
print(event, *args[1:])
|
||||
|
||||
sys.addaudithook(hook)
|
||||
|
||||
conn = http.client.HTTPConnection('www.python.org')
|
||||
try:
|
||||
conn.request('GET', '/')
|
||||
except OSError:
|
||||
print('http.client.send', '[cannot send]')
|
||||
finally:
|
||||
conn.close()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
from test.support import suppress_msvcrt_asserts
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue