adafruit-circuitpython-httpserver 4.8.2__py3-none-any.whl → 4.8.4__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {adafruit_circuitpython_httpserver-4.8.2.dist-info → adafruit_circuitpython_httpserver-4.8.4.dist-info}/METADATA +1 -1
- {adafruit_circuitpython_httpserver-4.8.2.dist-info → adafruit_circuitpython_httpserver-4.8.4.dist-info}/RECORD +7 -7
- {adafruit_circuitpython_httpserver-4.8.2.dist-info → adafruit_circuitpython_httpserver-4.8.4.dist-info}/WHEEL +1 -1
- adafruit_httpserver/__init__.py +1 -1
- adafruit_httpserver/server.py +40 -17
- {adafruit_circuitpython_httpserver-4.8.2.dist-info → adafruit_circuitpython_httpserver-4.8.4.dist-info}/licenses/LICENSE +0 -0
- {adafruit_circuitpython_httpserver-4.8.2.dist-info → adafruit_circuitpython_httpserver-4.8.4.dist-info}/top_level.txt +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
adafruit_circuitpython_httpserver-4.8.
|
|
2
|
-
adafruit_httpserver/__init__.py,sha256=
|
|
1
|
+
adafruit_circuitpython_httpserver-4.8.4.dist-info/licenses/LICENSE,sha256=gyhZwtwoqSsDGoSrV4MrLpKKWyG_jE3eROTZp1EjIUM,1102
|
|
2
|
+
adafruit_httpserver/__init__.py,sha256=aX4gnVzJrgC_Mwy94nr_AticnqA94EUOcNg_0-voGWA,1994
|
|
3
3
|
adafruit_httpserver/authentication.py,sha256=zBBFsAv3Qfl8meUjlS1jPQoSxhHWKNAPwbiS8MRagsg,2026
|
|
4
4
|
adafruit_httpserver/exceptions.py,sha256=790rlZj4ij29hG6lSMAfWMHvDRtKetAUxuulGj6JQrg,1948
|
|
5
5
|
adafruit_httpserver/headers.py,sha256=8PnkazQmun6ARU9CQFdw6FVgSuqcZN9VMvU50F4hOec,4510
|
|
@@ -9,9 +9,9 @@ adafruit_httpserver/mime_types.py,sha256=rGNoC9kop2O3hAzMAppb3Qt6qH6VsF8l9NzsZ8J
|
|
|
9
9
|
adafruit_httpserver/request.py,sha256=uG4jfgruoknz41SYndV7wnDAXvTHAHoIk_z3IgLu80A,14823
|
|
10
10
|
adafruit_httpserver/response.py,sha256=Sx8rtjtK1bcpNVWSQ5UazRGLLGUf7GN-V4tdyHAXO3I,34979
|
|
11
11
|
adafruit_httpserver/route.py,sha256=C-2i1T_ykr2KAuDuREJ6P_1G5Llh3d-g0r_a1ETDMJc,6125
|
|
12
|
-
adafruit_httpserver/server.py,sha256=
|
|
12
|
+
adafruit_httpserver/server.py,sha256=_l3d_14b5XCvxNuOINMjUIZdIU6hazjOfDq1PWWpmhI,23382
|
|
13
13
|
adafruit_httpserver/status.py,sha256=YyMleWebUadx4dwJDldYoo9aLEPDd6NVdvB2w4uY7sk,1825
|
|
14
|
-
adafruit_circuitpython_httpserver-4.8.
|
|
15
|
-
adafruit_circuitpython_httpserver-4.8.
|
|
16
|
-
adafruit_circuitpython_httpserver-4.8.
|
|
17
|
-
adafruit_circuitpython_httpserver-4.8.
|
|
14
|
+
adafruit_circuitpython_httpserver-4.8.4.dist-info/METADATA,sha256=0neoUZOmwCueQHSUDd089oGc82fUmE_tMjNdTyDqK7c,4838
|
|
15
|
+
adafruit_circuitpython_httpserver-4.8.4.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
|
|
16
|
+
adafruit_circuitpython_httpserver-4.8.4.dist-info/top_level.txt,sha256=N8L9ONfZQ9bILxcOPVWXOjUDA-BNLPKFir7KqAbMQbA,20
|
|
17
|
+
adafruit_circuitpython_httpserver-4.8.4.dist-info/RECORD,,
|
adafruit_httpserver/__init__.py
CHANGED
adafruit_httpserver/server.py
CHANGED
|
@@ -53,6 +53,25 @@ REQUEST_HANDLED_RESPONSE_SENT = "request_handled_response_sent"
|
|
|
53
53
|
# CircuitPython does not have these error codes
|
|
54
54
|
MBEDTLS_ERR_SSL_FATAL_ALERT_MESSAGE = -30592
|
|
55
55
|
|
|
56
|
+
# Errors after which poll() closes the connection and returns NO_REQUEST.
|
|
57
|
+
#
|
|
58
|
+
# Built once here so poll() does not allocate a new tuple on every error.
|
|
59
|
+
_IGNORED_ERRNOS = (
|
|
60
|
+
EAGAIN, # No data available right now.
|
|
61
|
+
ECONNRESET, # Connection reset by peer.
|
|
62
|
+
MBEDTLS_ERR_SSL_FATAL_ALERT_MESSAGE, # The client sent a fatal TLS alert.
|
|
63
|
+
)
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
def _is_tls_error(error: OSError) -> bool:
|
|
67
|
+
"""True if the error came from the TLS layer, such as a failed handshake."""
|
|
68
|
+
# CircuitPython's ssl module has no SSLError. It raises OSError with a negative
|
|
69
|
+
# mbedTLS error code, and other OSErrors have positive errnos.
|
|
70
|
+
# CPython raises ssl.SSLError, whose errno is positive.
|
|
71
|
+
if implementation.name == "circuitpython":
|
|
72
|
+
return isinstance(error.errno, int) and error.errno < 0
|
|
73
|
+
return isinstance(error, SSLError)
|
|
74
|
+
|
|
56
75
|
|
|
57
76
|
class Server:
|
|
58
77
|
"""A basic socket-based HTTP server."""
|
|
@@ -326,6 +345,8 @@ class Server:
|
|
|
326
345
|
while b"\r\n\r\n" not in received_bytes:
|
|
327
346
|
try:
|
|
328
347
|
length = sock.recv_into(self._buffer, len(self._buffer))
|
|
348
|
+
if length == 0:
|
|
349
|
+
break
|
|
329
350
|
received_bytes += self._buffer[:length]
|
|
330
351
|
except TimeoutError:
|
|
331
352
|
break
|
|
@@ -347,6 +368,8 @@ class Server:
|
|
|
347
368
|
while len(received_body_bytes) < content_length:
|
|
348
369
|
try:
|
|
349
370
|
length = sock.recv_into(self._buffer, len(self._buffer))
|
|
371
|
+
if length == 0:
|
|
372
|
+
break
|
|
350
373
|
received_body_bytes += self._buffer[:length]
|
|
351
374
|
except TimeoutError:
|
|
352
375
|
break
|
|
@@ -478,7 +501,14 @@ class Server:
|
|
|
478
501
|
if self.debug:
|
|
479
502
|
_debug_start_time = monotonic()
|
|
480
503
|
|
|
481
|
-
|
|
504
|
+
try:
|
|
505
|
+
conn, client_address = self._sock.accept()
|
|
506
|
+
except OSError as error:
|
|
507
|
+
# On an HTTPS server, accept() also does the TLS handshake.
|
|
508
|
+
# If it fails, drop this client and keep serving others.
|
|
509
|
+
if self.https and _is_tls_error(error):
|
|
510
|
+
return NO_REQUEST
|
|
511
|
+
raise
|
|
482
512
|
conn.settimeout(self._timeout)
|
|
483
513
|
|
|
484
514
|
# Receive the whole request
|
|
@@ -508,22 +538,15 @@ class Server:
|
|
|
508
538
|
return REQUEST_HANDLED_RESPONSE_SENT
|
|
509
539
|
|
|
510
540
|
except Exception as error:
|
|
511
|
-
if isinstance(error, OSError)
|
|
512
|
-
#
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
return NO_REQUEST
|
|
521
|
-
|
|
522
|
-
# CPython specific SSL related errors
|
|
523
|
-
if implementation.name != "circuitpython" and isinstance(error, SSLError):
|
|
524
|
-
# Ignore unknown SSL certificate errors
|
|
525
|
-
if getattr(error, "reason", None) == "SSLV3_ALERT_CERTIFICATE_UNKNOWN":
|
|
526
|
-
return NO_REQUEST
|
|
541
|
+
if (isinstance(error, OSError) and error.errno in _IGNORED_ERRNOS) or (
|
|
542
|
+
# CPython-specific: ignore unknown SSL certificate errors.
|
|
543
|
+
implementation.name != "circuitpython"
|
|
544
|
+
and isinstance(error, SSLError)
|
|
545
|
+
and getattr(error, "reason", None) == "SSLV3_ALERT_CERTIFICATE_UNKNOWN"
|
|
546
|
+
):
|
|
547
|
+
if conn is not None:
|
|
548
|
+
conn.close()
|
|
549
|
+
return NO_REQUEST
|
|
527
550
|
|
|
528
551
|
if self.debug:
|
|
529
552
|
_debug_exception_in_handler(error)
|
|
File without changes
|