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:
Saiyang Gou 2021-04-23 03:19:08 -07:00 committed by GitHub
parent 32980fb669
commit 927b841c21
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 41 additions and 0 deletions

View file

@ -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