Enhanced HTTP connection handling

Refactored the HTTP wrapper classes to introduce `HTÜPVerbindung`, a new class that supports configurable timeout, source address, and block size for HTTP connections, enhancing flexibility and control for HTTP requests in the Deuthon project. The `HTÜPAntwort` class now focuses solely on reading the response.
This commit is contained in:
Kumi 2024-01-14 22:06:32 +01:00
parent f61f72cb1b
commit e8dd82a6ba
Signed by: kumi
GPG key ID: ECBCC9082395383F

View file

@ -1,9 +1,28 @@
importiere http.client importiere http.client
klasse HTÜPAntwort(http.client.HTTPResponse): klasse HTÜPVerbindung(http.client.HTTPConnection):
definiere __init__(selbst, *argumente, **swargumente): definiere __init__(selbst, gastgeber, anschluss,
super().__init__(*argumente, **swargumente) auszeit=Nichts, quelladdresse=Nicht,
blockgröße=Nichts):
swargumente = {
"host": gastgeber,
"port": anschluss,
}
falls auszeit:
swargumente["timeout"] = auszeit
falls quelladresse:
swargumente["source_address"] = quelladresse
falls blockgröße:
swargumente["blocksize"] = blockgröße
super().__init__(selbst, **swargumente)
klasse HTÜPAntwort(http.client.HTTPResponse):
definiere lesen(selbst, *argumente, **swargumente): definiere lesen(selbst, *argumente, **swargumente):
return super().read(*argumente, **swargumente) return super().read(*argumente, **swargumente)