chumicro-http-server-experimental 0.18.0__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.
- chumicro_http_server/__init__.py +87 -0
- chumicro_http_server/_wire.py +811 -0
- chumicro_http_server/server.py +1166 -0
- chumicro_http_server/sockets_factory.py +53 -0
- chumicro_http_server/streaming.py +461 -0
- chumicro_http_server/testing.py +71 -0
- chumicro_http_server_experimental-0.18.0.dist-info/METADATA +187 -0
- chumicro_http_server_experimental-0.18.0.dist-info/RECORD +9 -0
- chumicro_http_server_experimental-0.18.0.dist-info/WHEEL +4 -0
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"""Non-blocking HTTP/1.1 server for CircuitPython, MicroPython, and CPython.
|
|
2
|
+
|
|
3
|
+
Built on :mod:`chumicro_sockets` (TCP listener + accepted client
|
|
4
|
+
sockets) and :mod:`chumicro_timing` (ticks). Tick-based runner
|
|
5
|
+
contract — :meth:`HttpServer.check(now_ms)` reports whether work is
|
|
6
|
+
pending and :meth:`handle(now_ms)` does one slice of progress per
|
|
7
|
+
call, so an LED can keep blinking on the same board even through a
|
|
8
|
+
slow upload or stalled client.
|
|
9
|
+
|
|
10
|
+
Not supported: HTTP/1.1 keep-alive or connection pooling (every
|
|
11
|
+
response carries ``Connection: close``); chunked request bodies
|
|
12
|
+
(use ``Content-Length``); WebSockets, sessions / cookies / auth
|
|
13
|
+
helpers, multipart upload, sub-app mounting, async handlers.
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
import gc
|
|
17
|
+
|
|
18
|
+
# Streamed response bodies are an opt-in submodule
|
|
19
|
+
# (``chumicro_http_server.streaming`` — ``StreamingResponse`` /
|
|
20
|
+
# ``build_streaming_response`` / ``encode_streaming_headers``), NOT
|
|
21
|
+
# re-exported here: the base ``HttpServer`` recognizes a streaming
|
|
22
|
+
# response by duck type and lazy-loads the framing machine only to drive
|
|
23
|
+
# one, so a server that never streams never pays its bytecode. The two
|
|
24
|
+
# constants below live in ``_wire`` (always imported) so the streaming
|
|
25
|
+
# submodule and the constructor default share them without pulling the
|
|
26
|
+
# framing code in.
|
|
27
|
+
from chumicro_http_server._wire import (
|
|
28
|
+
DEFAULT_MAX_CONNECTIONS,
|
|
29
|
+
DEFAULT_MAX_HEADERS_BYTES,
|
|
30
|
+
DEFAULT_MAX_REQUEST_BODY_BYTES,
|
|
31
|
+
DEFAULT_MAX_REQUEST_LINE_BYTES,
|
|
32
|
+
DEFAULT_RECV_BUDGET_PER_TICK,
|
|
33
|
+
DEFAULT_REQUEST_TIMEOUT_MS,
|
|
34
|
+
DEFAULT_SEND_BUDGET_PER_TICK,
|
|
35
|
+
DEFAULT_STREAM_BUFFER_SIZE,
|
|
36
|
+
SOURCE_EOF,
|
|
37
|
+
CaseInsensitiveDict,
|
|
38
|
+
RequestParser,
|
|
39
|
+
RequestParseState,
|
|
40
|
+
ServerError,
|
|
41
|
+
ServerHeadersTooLargeError,
|
|
42
|
+
ServerLimitError,
|
|
43
|
+
ServerOversizedError,
|
|
44
|
+
ServerProtocolError,
|
|
45
|
+
ServerRequestLineTooLargeError,
|
|
46
|
+
parse_charset,
|
|
47
|
+
parse_query,
|
|
48
|
+
split_target,
|
|
49
|
+
)
|
|
50
|
+
from chumicro_http_server.server import (
|
|
51
|
+
HttpServer,
|
|
52
|
+
Request,
|
|
53
|
+
Response,
|
|
54
|
+
build_response,
|
|
55
|
+
encode_response,
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
__all__ = [
|
|
59
|
+
"DEFAULT_MAX_CONNECTIONS",
|
|
60
|
+
"DEFAULT_MAX_HEADERS_BYTES",
|
|
61
|
+
"DEFAULT_MAX_REQUEST_BODY_BYTES",
|
|
62
|
+
"DEFAULT_MAX_REQUEST_LINE_BYTES",
|
|
63
|
+
"DEFAULT_RECV_BUDGET_PER_TICK",
|
|
64
|
+
"DEFAULT_REQUEST_TIMEOUT_MS",
|
|
65
|
+
"DEFAULT_SEND_BUDGET_PER_TICK",
|
|
66
|
+
"DEFAULT_STREAM_BUFFER_SIZE",
|
|
67
|
+
"SOURCE_EOF",
|
|
68
|
+
"CaseInsensitiveDict",
|
|
69
|
+
"HttpServer",
|
|
70
|
+
"Request",
|
|
71
|
+
"RequestParseState",
|
|
72
|
+
"RequestParser",
|
|
73
|
+
"Response",
|
|
74
|
+
"ServerError",
|
|
75
|
+
"ServerHeadersTooLargeError",
|
|
76
|
+
"ServerLimitError",
|
|
77
|
+
"ServerOversizedError",
|
|
78
|
+
"ServerProtocolError",
|
|
79
|
+
"ServerRequestLineTooLargeError",
|
|
80
|
+
"build_response",
|
|
81
|
+
"encode_response",
|
|
82
|
+
"parse_charset",
|
|
83
|
+
"parse_query",
|
|
84
|
+
"split_target",
|
|
85
|
+
]
|
|
86
|
+
|
|
87
|
+
gc.collect()
|