tigrcorn-core 0.3.16__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.
@@ -0,0 +1,98 @@
1
+ from __future__ import annotations
2
+
3
+ from .constants import (
4
+ ASGI_SPEC_VERSION,
5
+ ASGI_VERSION,
6
+ DEFAULT_BACKLOG,
7
+ DEFAULT_ENV_PREFIX,
8
+ DEFAULT_HOST,
9
+ DEFAULT_HTTP1_BUFFER_SIZE,
10
+ DEFAULT_HTTP1_MAX_INCOMPLETE_EVENT_SIZE,
11
+ DEFAULT_HTTP2_INITIAL_CONNECTION_WINDOW_SIZE,
12
+ DEFAULT_HTTP2_INITIAL_STREAM_WINDOW_SIZE,
13
+ DEFAULT_HTTP2_MAX_CONCURRENT_STREAMS,
14
+ DEFAULT_HTTP2_MAX_FRAME_SIZE,
15
+ DEFAULT_HTTP2_MAX_HEADERS_SIZE,
16
+ DEFAULT_HTTP_CONTENT_CODINGS,
17
+ DEFAULT_IDLE_TIMEOUT,
18
+ DEFAULT_KEEPALIVE_TIMEOUT,
19
+ DEFAULT_LIFESPAN,
20
+ DEFAULT_LOG_LEVEL,
21
+ DEFAULT_MAX_BODY_SIZE,
22
+ DEFAULT_MAX_DATAGRAM_SIZE,
23
+ DEFAULT_MAX_HEADER_SIZE,
24
+ DEFAULT_PIPE_MODE,
25
+ DEFAULT_PORT,
26
+ DEFAULT_QUIC_SECRET,
27
+ DEFAULT_READ_TIMEOUT,
28
+ DEFAULT_RUNTIME,
29
+ DEFAULT_SERVER_HEADER,
30
+ DEFAULT_SHUTDOWN_TIMEOUT,
31
+ DEFAULT_WEBSOCKET_MAX_MESSAGE_SIZE,
32
+ DEFAULT_WEBSOCKET_MAX_QUEUE,
33
+ DEFAULT_WORKER_CLASS,
34
+ DEFAULT_WORKER_HEALTHCHECK_TIMEOUT,
35
+ DEFAULT_WORKERS,
36
+ DEFAULT_WRITE_TIMEOUT,
37
+ H2_PREFACE,
38
+ SUPPORTED_RUNTIMES,
39
+ SUPPORTED_WORKER_CLASS_ALIASES,
40
+ WEBSOCKET_SPEC_VERSION,
41
+ )
42
+ from .errors import AppLoadError, ConfigError, ProtocolError, ServerError, TigrCornError, UnsupportedFeature
43
+ from .types import ASGIApp, Address, Headers, MaybeAddress, Message, Receive, Scope, Send, StreamReaderLike
44
+
45
+ __all__ = [
46
+ "ASGIApp",
47
+ "ASGI_SPEC_VERSION",
48
+ "ASGI_VERSION",
49
+ "Address",
50
+ "AppLoadError",
51
+ "ConfigError",
52
+ "DEFAULT_BACKLOG",
53
+ "DEFAULT_ENV_PREFIX",
54
+ "DEFAULT_HOST",
55
+ "DEFAULT_HTTP1_BUFFER_SIZE",
56
+ "DEFAULT_HTTP1_MAX_INCOMPLETE_EVENT_SIZE",
57
+ "DEFAULT_HTTP2_INITIAL_CONNECTION_WINDOW_SIZE",
58
+ "DEFAULT_HTTP2_INITIAL_STREAM_WINDOW_SIZE",
59
+ "DEFAULT_HTTP2_MAX_CONCURRENT_STREAMS",
60
+ "DEFAULT_HTTP2_MAX_FRAME_SIZE",
61
+ "DEFAULT_HTTP2_MAX_HEADERS_SIZE",
62
+ "DEFAULT_HTTP_CONTENT_CODINGS",
63
+ "DEFAULT_IDLE_TIMEOUT",
64
+ "DEFAULT_KEEPALIVE_TIMEOUT",
65
+ "DEFAULT_LIFESPAN",
66
+ "DEFAULT_LOG_LEVEL",
67
+ "DEFAULT_MAX_BODY_SIZE",
68
+ "DEFAULT_MAX_DATAGRAM_SIZE",
69
+ "DEFAULT_MAX_HEADER_SIZE",
70
+ "DEFAULT_PIPE_MODE",
71
+ "DEFAULT_PORT",
72
+ "DEFAULT_QUIC_SECRET",
73
+ "DEFAULT_READ_TIMEOUT",
74
+ "DEFAULT_RUNTIME",
75
+ "DEFAULT_SERVER_HEADER",
76
+ "DEFAULT_SHUTDOWN_TIMEOUT",
77
+ "DEFAULT_WEBSOCKET_MAX_MESSAGE_SIZE",
78
+ "DEFAULT_WEBSOCKET_MAX_QUEUE",
79
+ "DEFAULT_WORKER_CLASS",
80
+ "DEFAULT_WORKER_HEALTHCHECK_TIMEOUT",
81
+ "DEFAULT_WORKERS",
82
+ "DEFAULT_WRITE_TIMEOUT",
83
+ "H2_PREFACE",
84
+ "Headers",
85
+ "MaybeAddress",
86
+ "Message",
87
+ "ProtocolError",
88
+ "Receive",
89
+ "Scope",
90
+ "Send",
91
+ "ServerError",
92
+ "StreamReaderLike",
93
+ "SUPPORTED_RUNTIMES",
94
+ "SUPPORTED_WORKER_CLASS_ALIASES",
95
+ "TigrCornError",
96
+ "UnsupportedFeature",
97
+ "WEBSOCKET_SPEC_VERSION",
98
+ ]
@@ -0,0 +1,80 @@
1
+ from __future__ import annotations
2
+
3
+ ASGI_VERSION = "3.0"
4
+ ASGI_SPEC_VERSION = "2.3"
5
+ WEBSOCKET_SPEC_VERSION = "2.3"
6
+
7
+ DEFAULT_HOST = "127.0.0.1"
8
+ DEFAULT_PORT = 8000
9
+ DEFAULT_BACKLOG = 2048
10
+ DEFAULT_LOG_LEVEL = "info"
11
+ DEFAULT_LIFESPAN = "auto"
12
+ DEFAULT_ENV_PREFIX = "TIGRCORN"
13
+ DEFAULT_WORKERS = 1
14
+ DEFAULT_WORKER_CLASS = "local"
15
+ DEFAULT_RUNTIME = "auto"
16
+ SUPPORTED_RUNTIMES = ("auto", "asyncio", "uvloop")
17
+ SUPPORTED_WORKER_CLASS_ALIASES = ("asyncio", "uvloop")
18
+ DEFAULT_WORKER_HEALTHCHECK_TIMEOUT = 30.0
19
+ DEFAULT_MAX_BODY_SIZE = 16 * 1024 * 1024
20
+ DEFAULT_MAX_HEADER_SIZE = 64 * 1024
21
+ DEFAULT_HTTP1_MAX_INCOMPLETE_EVENT_SIZE = DEFAULT_MAX_HEADER_SIZE
22
+ DEFAULT_HTTP1_BUFFER_SIZE = 64 * 1024
23
+ DEFAULT_HTTP2_MAX_CONCURRENT_STREAMS = 128
24
+ DEFAULT_HTTP2_MAX_HEADERS_SIZE = DEFAULT_MAX_HEADER_SIZE
25
+ DEFAULT_HTTP2_MAX_FRAME_SIZE = 16 * 1024
26
+ DEFAULT_HTTP2_INITIAL_CONNECTION_WINDOW_SIZE = 65_535
27
+ DEFAULT_HTTP2_INITIAL_STREAM_WINDOW_SIZE = 65_535
28
+ DEFAULT_WEBSOCKET_MAX_MESSAGE_SIZE = 16 * 1024 * 1024
29
+ DEFAULT_WEBSOCKET_MAX_QUEUE = 32
30
+ DEFAULT_MAX_DATAGRAM_SIZE = 1200
31
+ DEFAULT_READ_TIMEOUT = 30.0
32
+ DEFAULT_WRITE_TIMEOUT = 30.0
33
+ DEFAULT_SHUTDOWN_TIMEOUT = 30.0
34
+ DEFAULT_KEEPALIVE_TIMEOUT = 5.0
35
+ DEFAULT_IDLE_TIMEOUT = 30.0
36
+ DEFAULT_SERVER_HEADER = b"tigrcorn"
37
+ DEFAULT_QUIC_SECRET = b"tigrcorn-quic-shared-secret"
38
+ DEFAULT_PIPE_MODE = "rawframed"
39
+ DEFAULT_HTTP_CONTENT_CODINGS = ("gzip", "deflate", "br")
40
+ H2_PREFACE = b"PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n"
41
+
42
+ __all__ = [
43
+ "ASGI_SPEC_VERSION",
44
+ "ASGI_VERSION",
45
+ "DEFAULT_BACKLOG",
46
+ "DEFAULT_ENV_PREFIX",
47
+ "DEFAULT_HOST",
48
+ "DEFAULT_HTTP1_BUFFER_SIZE",
49
+ "DEFAULT_HTTP1_MAX_INCOMPLETE_EVENT_SIZE",
50
+ "DEFAULT_HTTP2_INITIAL_CONNECTION_WINDOW_SIZE",
51
+ "DEFAULT_HTTP2_INITIAL_STREAM_WINDOW_SIZE",
52
+ "DEFAULT_HTTP2_MAX_CONCURRENT_STREAMS",
53
+ "DEFAULT_HTTP2_MAX_FRAME_SIZE",
54
+ "DEFAULT_HTTP2_MAX_HEADERS_SIZE",
55
+ "DEFAULT_HTTP_CONTENT_CODINGS",
56
+ "DEFAULT_IDLE_TIMEOUT",
57
+ "DEFAULT_KEEPALIVE_TIMEOUT",
58
+ "DEFAULT_LIFESPAN",
59
+ "DEFAULT_LOG_LEVEL",
60
+ "DEFAULT_MAX_BODY_SIZE",
61
+ "DEFAULT_MAX_DATAGRAM_SIZE",
62
+ "DEFAULT_MAX_HEADER_SIZE",
63
+ "DEFAULT_PIPE_MODE",
64
+ "DEFAULT_PORT",
65
+ "DEFAULT_QUIC_SECRET",
66
+ "DEFAULT_READ_TIMEOUT",
67
+ "DEFAULT_RUNTIME",
68
+ "DEFAULT_SERVER_HEADER",
69
+ "DEFAULT_SHUTDOWN_TIMEOUT",
70
+ "DEFAULT_WEBSOCKET_MAX_MESSAGE_SIZE",
71
+ "DEFAULT_WEBSOCKET_MAX_QUEUE",
72
+ "DEFAULT_WORKER_CLASS",
73
+ "DEFAULT_WORKER_HEALTHCHECK_TIMEOUT",
74
+ "DEFAULT_WORKERS",
75
+ "DEFAULT_WRITE_TIMEOUT",
76
+ "H2_PREFACE",
77
+ "SUPPORTED_RUNTIMES",
78
+ "SUPPORTED_WORKER_CLASS_ALIASES",
79
+ "WEBSOCKET_SPEC_VERSION",
80
+ ]
@@ -0,0 +1,35 @@
1
+ from __future__ import annotations
2
+
3
+
4
+ class TigrCornError(Exception):
5
+ """Base exception for the package."""
6
+
7
+
8
+ class ConfigError(TigrCornError):
9
+ """Raised for invalid configuration."""
10
+
11
+
12
+ class AppLoadError(TigrCornError):
13
+ """Raised when an ASGI application cannot be imported."""
14
+
15
+
16
+ class ProtocolError(TigrCornError):
17
+ """Raised when the wire protocol is malformed or unsupported."""
18
+
19
+
20
+ class UnsupportedFeature(TigrCornError):
21
+ """Raised when a requested feature or protocol is not implemented."""
22
+
23
+
24
+ class ServerError(TigrCornError):
25
+ """Raised for server lifecycle errors."""
26
+
27
+
28
+ __all__ = [
29
+ "AppLoadError",
30
+ "ConfigError",
31
+ "ProtocolError",
32
+ "ServerError",
33
+ "TigrCornError",
34
+ "UnsupportedFeature",
35
+ ]
tigrcorn_core/py.typed ADDED
@@ -0,0 +1 @@
1
+
tigrcorn_core/types.py ADDED
@@ -0,0 +1,33 @@
1
+ from __future__ import annotations
2
+
3
+ from collections.abc import Awaitable, Callable
4
+ from typing import Any, Protocol, runtime_checkable
5
+
6
+ Scope = dict[str, Any]
7
+ Message = dict[str, Any]
8
+ Receive = Callable[[], Awaitable[Message]]
9
+ Send = Callable[[Message], Awaitable[None]]
10
+ ASGIApp = Callable[[Scope, Receive, Send], Awaitable[None]]
11
+ Headers = list[tuple[bytes, bytes]]
12
+ Address = tuple[str, int]
13
+ MaybeAddress = tuple[str, int | None]
14
+
15
+
16
+ @runtime_checkable
17
+ class StreamReaderLike(Protocol):
18
+ async def read(self, n: int = -1) -> bytes: ...
19
+ async def readexactly(self, n: int) -> bytes: ...
20
+ async def readuntil(self, separator: bytes = b"\n") -> bytes: ...
21
+
22
+
23
+ __all__ = [
24
+ "ASGIApp",
25
+ "Address",
26
+ "Headers",
27
+ "MaybeAddress",
28
+ "Message",
29
+ "Receive",
30
+ "Scope",
31
+ "Send",
32
+ "StreamReaderLike",
33
+ ]
@@ -0,0 +1 @@
1
+ __all__ = []
@@ -0,0 +1,55 @@
1
+ from __future__ import annotations
2
+
3
+ from typing import Iterable
4
+
5
+
6
+ def split_authority(value: bytes | str | None) -> tuple[str, int | None]:
7
+ if value is None:
8
+ return '', None
9
+ if isinstance(value, bytes):
10
+ value = value.decode('latin1', 'ignore')
11
+ raw = value.strip()
12
+ if not raw:
13
+ return '', None
14
+ if raw.startswith('['):
15
+ if ']:' in raw:
16
+ host, port = raw.rsplit(':', 1)
17
+ return host[1:-1].lower(), int(port)
18
+ return raw.strip('[]').lower(), None
19
+ if raw.count(':') == 1:
20
+ host, port = raw.rsplit(':', 1)
21
+ if port.isdigit():
22
+ return host.lower(), int(port)
23
+ return raw.lower(), None
24
+
25
+
26
+ def authority_allowed(authority: bytes | str | None, allowlist: Iterable[str]) -> bool:
27
+ entries = [entry.strip().lower() for entry in allowlist if entry and entry.strip()]
28
+ if not entries:
29
+ return True
30
+ host, port = split_authority(authority)
31
+ if not host:
32
+ return False
33
+ full = f'{host}:{port}' if port is not None else host
34
+ for entry in entries:
35
+ if entry == '*':
36
+ return True
37
+ allowed_host, allowed_port = split_authority(entry)
38
+ if allowed_host.startswith('*.'):
39
+ suffix = allowed_host[1:]
40
+ if host.endswith(suffix) and host != suffix[1:]:
41
+ if allowed_port is None or allowed_port == port:
42
+ return True
43
+ continue
44
+ if allowed_host.startswith('.'):
45
+ suffix = allowed_host
46
+ if host.endswith(suffix) and host != suffix[1:]:
47
+ if allowed_port is None or allowed_port == port:
48
+ return True
49
+ continue
50
+ if allowed_port is not None:
51
+ if full == f'{allowed_host}:{allowed_port}':
52
+ return True
53
+ elif host == allowed_host:
54
+ return True
55
+ return False
@@ -0,0 +1,79 @@
1
+ from __future__ import annotations
2
+
3
+ from collections.abc import Iterable, Iterator
4
+
5
+
6
+ def clamp(value: int, minimum: int, maximum: int) -> int:
7
+ return max(minimum, min(maximum, value))
8
+
9
+
10
+ def split_chunks(data: bytes, size: int) -> Iterator[bytes]:
11
+ if size <= 0:
12
+ raise ValueError("size must be positive")
13
+ for offset in range(0, len(data), size):
14
+ yield data[offset : offset + size]
15
+
16
+
17
+ def encode_u24(value: int) -> bytes:
18
+ if not 0 <= value <= 0xFFFFFF:
19
+ raise ValueError("u24 out of range")
20
+ return value.to_bytes(3, "big")
21
+
22
+
23
+ def decode_u24(data: bytes) -> int:
24
+ if len(data) != 3:
25
+ raise ValueError("u24 requires exactly 3 bytes")
26
+ return int.from_bytes(data, "big")
27
+
28
+
29
+ def xor_bytes(left: bytes, right: bytes) -> bytes:
30
+ if len(left) != len(right):
31
+ raise ValueError("buffers must have equal length")
32
+ return bytes(a ^ b for a, b in zip(left, right))
33
+
34
+
35
+ def encode_quic_varint(value: int) -> bytes:
36
+ if value < 0:
37
+ raise ValueError("varint must be non-negative")
38
+ if value < 2**6:
39
+ return bytes([value])
40
+ if value < 2**14:
41
+ raw = value | 0x4000
42
+ return raw.to_bytes(2, "big")
43
+ if value < 2**30:
44
+ raw = value | 0x80000000
45
+ return raw.to_bytes(4, "big")
46
+ if value < 2**62:
47
+ raw = value | 0xC000000000000000
48
+ return raw.to_bytes(8, "big")
49
+ raise ValueError("varint too large")
50
+
51
+
52
+ def decode_quic_varint(data: bytes, offset: int = 0) -> tuple[int, int]:
53
+ if offset >= len(data):
54
+ raise ValueError("buffer underflow")
55
+ first = data[offset]
56
+ prefix = first >> 6
57
+ length = 1 << prefix
58
+ end = offset + length
59
+ if end > len(data):
60
+ raise ValueError("buffer underflow")
61
+ value = int.from_bytes(data[offset:end], "big")
62
+ mask = (1 << (length * 8 - 2)) - 1
63
+ return value & mask, end
64
+
65
+
66
+ def pack_varbytes(payload: bytes) -> bytes:
67
+ return encode_quic_varint(len(payload)) + payload
68
+
69
+
70
+ def unpack_varbytes(data: bytes, offset: int = 0) -> tuple[bytes, int]:
71
+ length, offset = decode_quic_varint(data, offset)
72
+ end = offset + length
73
+ if end > len(data):
74
+ raise ValueError("buffer underflow")
75
+ return data[offset:end], end
76
+
77
+
78
+ def join_bytes(parts: Iterable[bytes]) -> bytes:
79
+ return b"".join(parts)
@@ -0,0 +1,151 @@
1
+ from __future__ import annotations
2
+
3
+ from collections.abc import Iterable, Mapping
4
+ from email.utils import formatdate
5
+ from typing import Any
6
+
7
+
8
+ HeaderPair = tuple[bytes, bytes]
9
+
10
+ _EARLY_HINT_SAFE_HEADERS = {b"link"}
11
+
12
+
13
+ def _to_bytes(value: bytes | bytearray | memoryview | str) -> bytes:
14
+ if isinstance(value, bytes):
15
+ return value
16
+ if isinstance(value, str):
17
+ return value.encode('latin1')
18
+ return bytes(value)
19
+
20
+
21
+ def normalize_headers(headers: Iterable[tuple[bytes, bytes]]) -> list[tuple[bytes, bytes]]:
22
+ return [(bytes(k).lower(), bytes(v)) for k, v in headers]
23
+
24
+
25
+ def get_header(headers: Iterable[tuple[bytes, bytes]], name: bytes) -> bytes | None:
26
+ wanted = name.lower()
27
+ for key, value in headers:
28
+ if key.lower() == wanted:
29
+ return value
30
+ return None
31
+
32
+
33
+ def get_headers(headers: Iterable[tuple[bytes, bytes]], name: bytes) -> list[bytes]:
34
+ wanted = name.lower()
35
+ return [value for key, value in headers if key.lower() == wanted]
36
+
37
+
38
+ def header_contains_token(headers: Iterable[tuple[bytes, bytes]], name: bytes, token: bytes) -> bool:
39
+ wanted_name = name.lower()
40
+ wanted_token = token.lower()
41
+ for key, value in headers:
42
+ if key.lower() != wanted_name:
43
+ continue
44
+ values = [part.strip().lower() for part in value.split(b",")]
45
+ if wanted_token in values:
46
+ return True
47
+ return False
48
+
49
+
50
+ def append_if_missing(headers: list[tuple[bytes, bytes]], name: bytes, value: bytes) -> None:
51
+ if get_header(headers, name) is None:
52
+ headers.append((name.lower(), value))
53
+
54
+
55
+ def replace_header(headers: list[HeaderPair], name: bytes, value: bytes | None) -> list[HeaderPair]:
56
+ wanted = name.lower()
57
+ filtered = [(key, item_value) for key, item_value in headers if key.lower() != wanted]
58
+ if value is not None:
59
+ filtered.append((wanted, value))
60
+ return filtered
61
+
62
+
63
+ def strip_connection_specific_headers(headers: Iterable[tuple[bytes, bytes]]) -> list[tuple[bytes, bytes]]:
64
+ banned = {
65
+ b"connection",
66
+ b"keep-alive",
67
+ b"proxy-connection",
68
+ b"transfer-encoding",
69
+ b"upgrade",
70
+ }
71
+ return [(k, v) for k, v in headers if k.lower() not in banned]
72
+
73
+
74
+ def http_date_now() -> bytes:
75
+ return formatdate(usegmt=True).encode('ascii')
76
+
77
+
78
+ def parse_header_entry(value: Any) -> HeaderPair:
79
+ if isinstance(value, Mapping):
80
+ name = value.get('name')
81
+ header_value = value.get('value')
82
+ if name is None or header_value is None:
83
+ raise ValueError('header mappings require name and value keys')
84
+ return _to_bytes(name).lower(), _to_bytes(header_value)
85
+ if isinstance(value, (tuple, list)) and len(value) == 2:
86
+ name, header_value = value
87
+ return _to_bytes(name).lower(), _to_bytes(header_value)
88
+ if isinstance(value, str):
89
+ if ':' not in value:
90
+ raise ValueError('header entries must use name:value syntax')
91
+ name, header_value = value.split(':', 1)
92
+ name_b = name.strip().encode('latin1').lower()
93
+ value_b = header_value.strip().encode('latin1')
94
+ if not name_b:
95
+ raise ValueError('header name cannot be empty')
96
+ return name_b, value_b
97
+ raise ValueError(f'unsupported header entry: {value!r}')
98
+
99
+
100
+ def normalize_header_entries(values: Iterable[Any] | Any | None) -> list[HeaderPair]:
101
+ if values is None:
102
+ return []
103
+ if isinstance(values, (str, bytes, bytearray, memoryview, Mapping)):
104
+ values = [values]
105
+ normalized: list[HeaderPair] = []
106
+ for item in values:
107
+ normalized.append(parse_header_entry(item))
108
+ return normalized
109
+
110
+
111
+ def normalize_alt_svc_entries(values: Iterable[Any] | Any | None) -> list[bytes]:
112
+ if values is None:
113
+ return []
114
+ if isinstance(values, (str, bytes, bytearray, memoryview)):
115
+ values = [values]
116
+ normalized: list[bytes] = []
117
+ for item in values:
118
+ value = _to_bytes(item).strip()
119
+ if value:
120
+ normalized.append(value)
121
+ return normalized
122
+
123
+
124
+ def sanitize_early_hints_headers(headers: Iterable[tuple[bytes, bytes]]) -> list[HeaderPair]:
125
+ normalized = strip_connection_specific_headers(headers)
126
+ return [
127
+ (bytes(name).lower(), bytes(value))
128
+ for name, value in normalized
129
+ if bytes(name).lower() in _EARLY_HINT_SAFE_HEADERS
130
+ ]
131
+
132
+
133
+ def apply_response_header_policy(
134
+ headers: Iterable[tuple[bytes, bytes]],
135
+ *,
136
+ server_header: bytes | None = None,
137
+ include_date_header: bool = True,
138
+ default_headers: Iterable[Any] = (),
139
+ alt_svc_values: Iterable[Any] = (),
140
+ ) -> list[HeaderPair]:
141
+ normalized = [(bytes(k).lower(), bytes(v)) for k, v in headers]
142
+ for name, value in normalize_header_entries(default_headers):
143
+ append_if_missing(normalized, name, value)
144
+ if include_date_header:
145
+ append_if_missing(normalized, b'date', http_date_now())
146
+ if server_header:
147
+ append_if_missing(normalized, b'server', server_header)
148
+ if get_header(normalized, b'alt-svc') is None:
149
+ for value in normalize_alt_svc_entries(alt_svc_values):
150
+ normalized.append((b'alt-svc', value))
151
+ return normalized
@@ -0,0 +1,19 @@
1
+ from __future__ import annotations
2
+
3
+ import itertools
4
+
5
+ _counter = itertools.count(1)
6
+ _session_counter = itertools.count(1)
7
+ _stream_counter = itertools.count(1)
8
+
9
+
10
+ def next_id() -> int:
11
+ return next(_counter)
12
+
13
+
14
+ def next_session_id() -> int:
15
+ return next(_session_counter)
16
+
17
+
18
+ def next_stream_id() -> int:
19
+ return next(_stream_counter)
@@ -0,0 +1,14 @@
1
+ from __future__ import annotations
2
+
3
+ import importlib
4
+
5
+
6
+ def import_from_string(target: str):
7
+ if ":" not in target:
8
+ raise ValueError(f"import string must be 'module:attr', got {target!r}")
9
+ module_name, attr_name = target.split(":", 1)
10
+ module = importlib.import_module(module_name)
11
+ obj = module
12
+ for part in attr_name.split("."):
13
+ obj = getattr(obj, part)
14
+ return obj
@@ -0,0 +1,22 @@
1
+ from __future__ import annotations
2
+
3
+ from pathlib import Path
4
+
5
+
6
+ def peer_parts(peername) -> tuple[str | None, int | None]:
7
+ if isinstance(peername, tuple) and len(peername) >= 2:
8
+ host = peername[0]
9
+ port = peername[1]
10
+ if isinstance(host, str) and isinstance(port, int):
11
+ return host, port
12
+ return None, None
13
+
14
+
15
+ def format_bind(host: str, port: int) -> str:
16
+ if ":" in host and not host.startswith("["):
17
+ return f"[{host}]:{port}"
18
+ return f"{host}:{port}"
19
+
20
+
21
+ def ensure_parent_dir(path: str) -> None:
22
+ Path(path).parent.mkdir(parents=True, exist_ok=True)
@@ -0,0 +1,170 @@
1
+ from __future__ import annotations
2
+
3
+ from dataclasses import dataclass
4
+ from ipaddress import ip_address, ip_network
5
+ from typing import Iterable, Sequence
6
+
7
+ from .headers import get_header
8
+
9
+
10
+ @dataclass(slots=True)
11
+ class ProxyView:
12
+ client: tuple[str, int] | None
13
+ server: tuple[str, int] | tuple[str, None] | None
14
+ scheme: str
15
+ root_path: str
16
+
17
+
18
+ def _decode(value: bytes | None) -> str | None:
19
+ if value is None:
20
+ return None
21
+ return value.decode('latin1', 'ignore').strip() or None
22
+
23
+
24
+ def _normalize_root_path(root_path: str) -> str:
25
+ if not root_path:
26
+ return ''
27
+ root_path = root_path.strip()
28
+ if not root_path:
29
+ return ''
30
+ if not root_path.startswith('/'):
31
+ root_path = '/' + root_path
32
+ return root_path.rstrip('/') or '/'
33
+
34
+
35
+ def _split_host_port(value: str) -> tuple[str, int | None]:
36
+ value = value.strip().strip('"')
37
+ if not value:
38
+ return '', None
39
+ if value.startswith('[') and ']:' in value:
40
+ host, port = value.rsplit(':', 1)
41
+ return host[1:-1], int(port)
42
+ if value.count(':') == 1 and value.rsplit(':', 1)[1].isdigit():
43
+ host, port = value.rsplit(':', 1)
44
+ return host, int(port)
45
+ return value.strip('[]'), None
46
+
47
+
48
+ def _first_csv(value: str | None) -> str | None:
49
+ if not value:
50
+ return None
51
+ first = value.split(',', 1)[0].strip()
52
+ return first or None
53
+
54
+
55
+ def _parse_forwarded(header_value: str | None) -> dict[str, str]:
56
+ if not header_value:
57
+ return {}
58
+ first = header_value.split(',', 1)[0]
59
+ result: dict[str, str] = {}
60
+ for part in first.split(';'):
61
+ if '=' not in part:
62
+ continue
63
+ key, value = part.split('=', 1)
64
+ result[key.strip().lower()] = value.strip().strip('"')
65
+ return result
66
+
67
+
68
+ def _client_ip(client: tuple[str, int] | None) -> str | None:
69
+ return client[0] if client else None
70
+
71
+
72
+ def _trusted(client: tuple[str, int] | None, allowlist: Sequence[str]) -> bool:
73
+ host = _client_ip(client)
74
+ if host is None:
75
+ return False
76
+ if not allowlist:
77
+ try:
78
+ return ip_address(host).is_loopback
79
+ except ValueError:
80
+ return host in {'localhost'}
81
+ for entry in allowlist:
82
+ item = entry.strip()
83
+ if not item:
84
+ continue
85
+ if item == '*':
86
+ return True
87
+ if item.lower() in {'unix', 'localhost'} and host in {'127.0.0.1', '::1', 'localhost'}:
88
+ return True
89
+ try:
90
+ if '/' in item:
91
+ if ip_address(host) in ip_network(item, strict=False):
92
+ return True
93
+ continue
94
+ if ip_address(host) == ip_address(item):
95
+ return True
96
+
97
+ except ValueError:
98
+ if host == item:
99
+ return True
100
+ return False
101
+
102
+
103
+ def resolve_proxy_view(
104
+ headers: Iterable[tuple[bytes, bytes]],
105
+ *,
106
+ client: tuple[str, int] | None,
107
+ server: tuple[str, int] | tuple[str, None] | None,
108
+ scheme: str,
109
+ root_path: str = '',
110
+ enabled: bool = False,
111
+ forwarded_allow_ips: Sequence[str] = (),
112
+ ) -> ProxyView:
113
+ resolved_root = _normalize_root_path(root_path)
114
+ view = ProxyView(client=client, server=server, scheme=scheme, root_path=resolved_root)
115
+ if not enabled or not _trusted(client, forwarded_allow_ips):
116
+ return view
117
+
118
+ forwarded = _parse_forwarded(_decode(get_header(headers, b'forwarded')))
119
+ xf_for = _first_csv(_decode(get_header(headers, b'x-forwarded-for')))
120
+ xf_proto = _first_csv(_decode(get_header(headers, b'x-forwarded-proto')))
121
+ xf_host = _first_csv(_decode(get_header(headers, b'x-forwarded-host')))
122
+ xf_prefix = _first_csv(_decode(get_header(headers, b'x-forwarded-prefix')))
123
+ x_script_name = _decode(get_header(headers, b'x-script-name'))
124
+
125
+ forwarded_for = forwarded.get('for')
126
+ if forwarded_for:
127
+ host, port = _split_host_port(forwarded_for)
128
+ if host:
129
+ view.client = (host, port or (client[1] if client else 0))
130
+ elif xf_for:
131
+ host, port = _split_host_port(xf_for)
132
+ if host:
133
+ view.client = (host, port or (client[1] if client else 0))
134
+
135
+ forwarded_proto = forwarded.get('proto')
136
+ if forwarded_proto:
137
+ view.scheme = forwarded_proto
138
+ elif xf_proto:
139
+ view.scheme = xf_proto
140
+
141
+ forwarded_host = forwarded.get('host')
142
+ host_value = forwarded_host or xf_host
143
+ if host_value:
144
+ host, port = _split_host_port(host_value)
145
+ if host:
146
+ current_port = server[1] if server else None
147
+ view.server = (host, port if port is not None else current_port)
148
+
149
+ prefix = forwarded.get('path') or xf_prefix or x_script_name
150
+ if prefix:
151
+ normalized = _normalize_root_path(prefix)
152
+ if view.root_path and normalized and normalized != view.root_path:
153
+ combined = _normalize_root_path(view.root_path + '/' + normalized.lstrip('/'))
154
+ view.root_path = combined
155
+ else:
156
+ view.root_path = normalized or view.root_path
157
+ return view
158
+
159
+
160
+ def strip_root_path(path: str, raw_path: bytes, root_path: str) -> tuple[str, bytes]:
161
+ normalized = _normalize_root_path(root_path)
162
+ if not normalized or normalized == '/':
163
+ return path, raw_path
164
+ if path == normalized:
165
+ return '/', b'/'
166
+ if path.startswith(normalized + '/'):
167
+ stripped_path = path[len(normalized):] or '/'
168
+ stripped_raw = raw_path[len(normalized.encode('latin1')):] or b'/'
169
+ return stripped_path, stripped_raw
170
+ return path, raw_path
@@ -0,0 +1 @@
1
+ __version__ = "0.3.16"
@@ -0,0 +1,289 @@
1
+ Metadata-Version: 2.4
2
+ Name: tigrcorn-core
3
+ Version: 0.3.16
4
+ Summary: Typed core primitives, errors, constants, and utilities shared by the Tigrcorn ASGI3 Python web server packages.
5
+ Author-email: Jacob Stewart <jacob@swarmauri.com>
6
+ License: Apache License
7
+ Version 2.0, January 2004
8
+ http://www.apache.org/licenses/
9
+
10
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
11
+
12
+ 1. Definitions.
13
+
14
+ "License" shall mean the terms and conditions for use, reproduction, and
15
+ distribution as defined by Sections 1 through 9 of this document.
16
+
17
+ "Licensor" shall mean the copyright owner or entity authorized by the
18
+ copyright owner that is granting the License.
19
+
20
+ "Legal Entity" shall mean the union of the acting entity and all other
21
+ entities that control, are controlled by, or are under common control with
22
+ that entity. For the purposes of this definition, "control" means (i) the
23
+ power, direct or indirect, to cause the direction or management of such
24
+ entity, whether by contract or otherwise, or (ii) ownership of fifty percent
25
+ (50%) or more of the outstanding shares, or (iii) beneficial ownership of
26
+ such entity.
27
+
28
+ "You" (or "Your") shall mean an individual or Legal Entity exercising
29
+ permissions granted by this License.
30
+
31
+ "Source" form shall mean the preferred form for making modifications,
32
+ including but not limited to software source code, documentation source, and
33
+ configuration files.
34
+
35
+ "Object" form shall mean any form resulting from mechanical transformation
36
+ or translation of a Source form, including but not limited to compiled object
37
+ code, generated documentation, and conversions to other media types.
38
+
39
+ "Work" shall mean the work of authorship, whether in Source or Object form,
40
+ made available under the License, as indicated by a copyright notice that is
41
+ included in or attached to the work (an example is provided in the Appendix
42
+ below).
43
+
44
+ "Derivative Works" shall mean any work, whether in Source or Object form,
45
+ that is based on (or derived from) the Work and for which the editorial
46
+ revisions, annotations, elaborations, or other modifications represent, as a
47
+ whole, an original work of authorship. For the purposes of this License,
48
+ Derivative Works shall not include works that remain separable from, or
49
+ merely link (or bind by name) to the interfaces of, the Work and Derivative
50
+ Works thereof.
51
+
52
+ "Contribution" shall mean any work of authorship, including the original
53
+ version of the Work and any modifications or additions to that Work or
54
+ Derivative Works thereof, that is intentionally submitted to Licensor for
55
+ inclusion in the Work by the copyright owner or by an individual or Legal
56
+ Entity authorized to submit on behalf of the copyright owner. For the
57
+ purposes of this definition, "submitted" means any form of electronic,
58
+ verbal, or written communication sent to the Licensor or its representatives,
59
+ including but not limited to communication on electronic mailing lists,
60
+ source code control systems, and issue tracking systems that are managed by,
61
+ or on behalf of, the Licensor for the purpose of discussing and improving the
62
+ Work, but excluding communication that is conspicuously marked or otherwise
63
+ designated in writing by the copyright owner as "Not a Contribution."
64
+
65
+ "Contributor" shall mean Licensor and any individual or Legal Entity on
66
+ behalf of whom a Contribution has been received by Licensor and subsequently
67
+ incorporated within the Work.
68
+
69
+ 2. Grant of Copyright License. Subject to the terms and conditions of this
70
+ License, each Contributor hereby grants to You a perpetual, worldwide,
71
+ non-exclusive, no-charge, royalty-free, irrevocable copyright license to
72
+ reproduce, prepare Derivative Works of, publicly display, publicly perform,
73
+ sublicense, and distribute the Work and such Derivative Works in Source or
74
+ Object form.
75
+
76
+ 3. Grant of Patent License. Subject to the terms and conditions of this
77
+ License, each Contributor hereby grants to You a perpetual, worldwide,
78
+ non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this
79
+ section) patent license to make, have made, use, offer to sell, sell, import,
80
+ and otherwise transfer the Work, where such license applies only to those
81
+ patent claims licensable by such Contributor that are necessarily infringed by
82
+ their Contribution(s) alone or by combination of their Contribution(s) with
83
+ the Work to which such Contribution(s) was submitted. If You institute patent
84
+ litigation against any entity (including a cross-claim or counterclaim in a
85
+ lawsuit) alleging that the Work or a Contribution incorporated within the Work
86
+ constitutes direct or contributory patent infringement, then any patent
87
+ licenses granted to You under this License for that Work shall terminate as of
88
+ the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the Work or
91
+ Derivative Works thereof in any medium, with or without modifications, and in
92
+ Source or Object form, provided that You meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or Derivative Works a copy
95
+ of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices stating that
98
+ You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works that You
101
+ distribute, all copyright, patent, trademark, and attribution notices
102
+ from the Source form of the Work, excluding those notices that do not
103
+ pertain to any part of the Derivative Works; and
104
+
105
+ (d) If the Work includes a "NOTICE" text file as part of its distribution,
106
+ then any Derivative Works that You distribute must include a readable copy
107
+ of the attribution notices contained within such NOTICE file, excluding
108
+ those notices that do not pertain to any part of the Derivative Works, in
109
+ at least one of the following places: within a NOTICE text file distributed
110
+ as part of the Derivative Works; within the Source form or documentation,
111
+ if provided along with the Derivative Works; or, within a display generated
112
+ by the Derivative Works, if and wherever such third-party notices normally
113
+ appear. The contents of the NOTICE file are for informational purposes only
114
+ and do not modify the License. You may add Your own attribution notices
115
+ within Derivative Works that You distribute, alongside or as an addendum to
116
+ the NOTICE text from the Work, provided that such additional attribution
117
+ notices cannot be construed as modifying the License.
118
+
119
+ You may add Your own copyright statement to Your modifications and may provide
120
+ additional or different license terms and conditions for use, reproduction, or
121
+ distribution of Your modifications, or for any such Derivative Works as a
122
+ whole, provided Your use, reproduction, and distribution of the Work otherwise
123
+ complies with the conditions stated in this License.
124
+
125
+ 5. Submission of Contributions. Unless You explicitly state otherwise, any
126
+ Contribution intentionally submitted for inclusion in the Work by You to the
127
+ Licensor shall be under the terms and conditions of this License, without any
128
+ additional terms or conditions. Notwithstanding the above, nothing herein
129
+ shall supersede or modify the terms of any separate license agreement you may
130
+ have executed with Licensor regarding such Contributions.
131
+
132
+ 6. Trademarks. This License does not grant permission to use the trade names,
133
+ trademarks, service marks, or product names of the Licensor, except as
134
+ required for reasonable and customary use in describing the origin of the Work
135
+ and reproducing the content of the NOTICE file.
136
+
137
+ 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in
138
+ writing, Licensor provides the Work (and each Contributor provides its
139
+ Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
140
+ KIND, either express or implied, including, without limitation, any warranties
141
+ or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
142
+ PARTICULAR PURPOSE. You are solely responsible for determining the
143
+ appropriateness of using or redistributing the Work and assume any risks
144
+ associated with Your exercise of permissions under this License.
145
+
146
+ 8. Limitation of Liability. In no event and under no legal theory, whether in
147
+ tort (including negligence), contract, or otherwise, unless required by
148
+ applicable law (such as deliberate and grossly negligent acts) or agreed to in
149
+ writing, shall any Contributor be liable to You for damages, including any
150
+ direct, indirect, special, incidental, or consequential damages of any
151
+ character arising as a result of this License or out of the use or inability
152
+ to use the Work (including but not limited to damages for loss of goodwill,
153
+ work stoppage, computer failure or malfunction, or any and all other
154
+ commercial damages or losses), even if such Contributor has been advised of
155
+ the possibility of such damages.
156
+
157
+ 9. Accepting Warranty or Additional Liability. While redistributing the Work or
158
+ Derivative Works thereof, You may choose to offer, and charge a fee for,
159
+ acceptance of support, warranty, indemnity, or other liability obligations
160
+ and/or rights consistent with this License. However, in accepting such
161
+ obligations, You may act only on Your own behalf and on Your sole
162
+ responsibility, not on behalf of any other Contributor, and only if You agree
163
+ to indemnify, defend, and hold each Contributor harmless for any liability
164
+ incurred by, or claims asserted against, such Contributor by reason of your
165
+ accepting any such warranty or additional liability.
166
+
167
+ END OF TERMS AND CONDITIONS
168
+
169
+
170
+ Keywords: tigrcorn,core,python,asgi,typed,protocol-primitives
171
+ Classifier: Development Status :: 3 - Alpha
172
+ Classifier: Framework :: AsyncIO
173
+ Classifier: Intended Audience :: Developers
174
+ Classifier: License :: OSI Approved :: Apache Software License
175
+ Classifier: Operating System :: OS Independent
176
+ Classifier: Programming Language :: Python :: 3
177
+ Classifier: Programming Language :: Python :: 3 :: Only
178
+ Classifier: Programming Language :: Python :: 3.10
179
+ Classifier: Programming Language :: Python :: 3.11
180
+ Classifier: Programming Language :: Python :: 3.12
181
+ Classifier: Programming Language :: Python :: 3.13
182
+ Classifier: Programming Language :: Python :: 3.14
183
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
184
+ Classifier: Typing :: Typed
185
+ Requires-Python: <3.15,>=3.10
186
+ Description-Content-Type: text/markdown
187
+ License-File: LICENSE
188
+ Dynamic: license-file
189
+
190
+ <div align="center">
191
+ <h1>tigrcorn-core</h1>
192
+ <img
193
+ src="https://raw.githubusercontent.com/Tigrbl/tigrcorn/master/assets/tigrcorn_logo.png"
194
+ alt="Tigrcorn tiger-unicorn logo"
195
+ width="140"
196
+ />
197
+
198
+ <p><strong>Typed core primitives, errors, constants, and utilities shared by the Tigrcorn ASGI3 Python web server packages.</strong></p>
199
+
200
+ <a href="https://pypi.org/project/tigrcorn-core/"><img alt="PyPI version for tigrcorn-core" src="https://img.shields.io/pypi/v/tigrcorn-core?label=PyPI"></a>
201
+ <a href="https://pypi.org/project/tigrcorn-core/"><img alt="tigrcorn-core package on PyPI" src="https://img.shields.io/badge/package-PyPI-blue"></a>
202
+ <a href="https://pepy.tech/project/tigrcorn-core"><img alt="Downloads for tigrcorn-core" src="https://static.pepy.tech/badge/tigrcorn-core"></a>
203
+ <a href="https://github.com/tigrbl/tigrcorn/blob/master/pkgs/tigrcorn-core/README.md"><img alt="Hits for tigrcorn-core README" src="https://hits.sh/github.com/tigrbl/tigrcorn/blob/master/pkgs/tigrcorn-core/README.md.svg?label=hits"></a>
204
+ <a href="LICENSE"><img alt="Apache 2.0 license" src="https://img.shields.io/badge/license-Apache%202.0-525252"></a>
205
+ <a href="pyproject.toml"><img alt="Python 3.10 | 3.11 | 3.12 | 3.13 | 3.14 supported" src="https://img.shields.io/badge/python-3.10%20%7C%203.11%20%7C%203.12%20%7C%203.13%20%7C%203.14-3776ab"></a>
206
+ <a href="https://pypi.org/project/tigrcorn-core/"><img alt="core role package" src="https://img.shields.io/badge/role-core-0a7f5a"></a>
207
+ </div>
208
+
209
+ <p align="center"><a href="https://github.com/Tigrbl/tigrcorn/blob/master/.ssot/registry.json"><img alt="SSOT governed" src="https://img.shields.io/badge/SSOT-governed-2f6f4e.svg"></a> <a href="https://discord.gg/jzvrbEtTtt"><img alt="Discord" src="https://img.shields.io/badge/Discord-Join%20chat-5865F2?logo=discord&amp;logoColor=white"></a></p>
210
+
211
+ ## Install
212
+
213
+ ```bash
214
+ uv add tigrcorn-core
215
+ ```
216
+
217
+ ```bash
218
+ pip install tigrcorn-core
219
+ ```
220
+
221
+ Use the aggregate [tigrcorn](https://pypi.org/project/tigrcorn/) distribution when you want the full ASGI3 Python web server stack. Install <code>tigrcorn-core</code> directly when you want only this package boundary and its declared dependencies.
222
+
223
+ ## What It Owns
224
+
225
+ <code>tigrcorn-core</code> owns constants, errors, types, and utils primitives. Its import package is <code>tigrcorn_core</code>, and its declared package dependencies are: none.
226
+
227
+ This package page is written for developers searching for Tigrcorn ASGI3 server components, Python web server packages, HTTP/3 and QUIC support, WebSocket and WebTransport-adjacent surfaces, and Apache 2.0 licensed infrastructure.
228
+
229
+ ## Why Use This?
230
+
231
+ Use <code>tigrcorn-core</code> when you want the core layer as a direct install target instead of the full server bundle. It lets application, operator, or certification workflows depend on this boundary explicitly while keeping the broader Tigrcorn runtime assembled from smaller repo-owned package surfaces.
232
+
233
+ ## FAQ
234
+
235
+ ### What does this package export?
236
+
237
+ The package exports through the <code>tigrcorn_core</code> namespace and keeps the root <code>tigrcorn</code> package as the compatibility umbrella.
238
+
239
+ ### Which boundary does this package own?
240
+
241
+ It is the package boundary for constants, errors, types, and utils primitives in the Tigrcorn package graph.
242
+
243
+ ### What does this package intentionally avoid?
244
+
245
+ It stays dependency-light and infrastructure-neutral so every higher Tigrcorn package can reuse shared constants, types, and core errors without pulling in HTTP, TLS, protocol, or runtime stacks.
246
+
247
+ ## Features
248
+
249
+ - Owns constants, errors, types, and utils primitives inside the Tigrcorn split-package architecture.
250
+ - Publishes the <code>tigrcorn_core</code> import surface for named public helpers and entrypoints.
251
+ - Declared runtime dependencies: none.
252
+ - Optional dependency surface: none.
253
+ - Supports Python 3.10, 3.11, 3.12, 3.13, and 3.14.
254
+
255
+ ## Use It When
256
+
257
+ Use <code>tigrcorn-core</code> when you need core-level behavior without pulling the entire server stack into the import surface. It is part of Tigrcorn's split-package architecture, so it can be installed independently while remaining linked to the rest of the Tigrcorn package family on PyPI.
258
+
259
+ ## Import Surface
260
+
261
+ ```python
262
+ import tigrcorn_core
263
+
264
+ print(tigrcorn_core.DEFAULT_HOST)
265
+ print(tigrcorn_core.DEFAULT_PORT)
266
+ ```
267
+
268
+ The package exposes its supported public surface through the <code>tigrcorn_core</code> namespace. The root [tigrcorn](https://pypi.org/project/tigrcorn/) package keeps compatibility shims for users who install the full server distribution.
269
+
270
+ ## Related Packages
271
+
272
+ - [tigrcorn](https://pypi.org/project/tigrcorn/)
273
+ - [tigrcorn-config](https://pypi.org/project/tigrcorn-config/)
274
+ - [tigrcorn-http](https://pypi.org/project/tigrcorn-http/)
275
+ - [tigrcorn-asgi](https://pypi.org/project/tigrcorn-asgi/)
276
+
277
+ ## Package Graph
278
+
279
+ [tigrcorn-core](https://pypi.org/project/tigrcorn-core/) | [tigrcorn-config](https://pypi.org/project/tigrcorn-config/) | [tigrcorn-http](https://pypi.org/project/tigrcorn-http/) | [tigrcorn-asgi](https://pypi.org/project/tigrcorn-asgi/) | [tigrcorn-contract](https://pypi.org/project/tigrcorn-contract/) | [tigrcorn-transports](https://pypi.org/project/tigrcorn-transports/) | [tigrcorn-security](https://pypi.org/project/tigrcorn-security/) | [tigrcorn-protocols](https://pypi.org/project/tigrcorn-protocols/) | [tigrcorn-static](https://pypi.org/project/tigrcorn-static/) | [tigrcorn-observability](https://pypi.org/project/tigrcorn-observability/) | [tigrcorn-runtime](https://pypi.org/project/tigrcorn-runtime/) | [tigrcorn-compat](https://pypi.org/project/tigrcorn-compat/) | [tigrcorn-certification](https://pypi.org/project/tigrcorn-certification/)
280
+
281
+ ## Best Practices
282
+
283
+ - Keep this package at the bottom of new dependency chains.
284
+ - Import protocol, runtime, or security behavior from higher packages instead of backfilling it here.
285
+ - Use the exported constants and error types instead of cloning parallel primitives in downstream packages.
286
+
287
+ ## License
288
+
289
+ Apache-2.0
@@ -0,0 +1,19 @@
1
+ tigrcorn_core/__init__.py,sha256=AZ-3N00FSnqbHyy0QH77hnJ4JfQfYBKzg9qODmRpls4,2783
2
+ tigrcorn_core/constants.py,sha256=ogeBmt78O2qkgop29DqfJs4WeO3QUEZY1R6RJzKUDiI,2577
3
+ tigrcorn_core/errors.py,sha256=I0_BO4Et8kVt7wnr6Gmbz6WPyc4XL3v5Z7hxbs8ion4,738
4
+ tigrcorn_core/py.typed,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
5
+ tigrcorn_core/types.py,sha256=VMiRarERM_25hfURS0zfpAunlOiun6OBmFDAQ3CifHQ,823
6
+ tigrcorn_core/version.py,sha256=Vxi__HBWfSiWE44FCAaz8K_3N8LJgmxIle1XoC0ZUMk,23
7
+ tigrcorn_core/utils/__init__.py,sha256=da1PTClDMl-IBkrSvq6JC1lnS-K_BASzCvxVhNxN5Ls,13
8
+ tigrcorn_core/utils/authority.py,sha256=-lAT-Dcy4L74lFfdtkHTCgjqK6Oe2vwq0fNQly3DZcM,1893
9
+ tigrcorn_core/utils/bytes.py,sha256=ib8UCk-eaXmtFAKmG1jiY7D3hpOEs3W4dXX_5FkqnN8,2283
10
+ tigrcorn_core/utils/headers.py,sha256=SKsww_LXZHbG-WM6lzcpVxRUmfbABTkNhfOrr8MdndY,5160
11
+ tigrcorn_core/utils/ids.py,sha256=Y4dyq7AaLg2W_9DM7zlYx6JgRRZ5QYCQyux5rKG5pXQ,339
12
+ tigrcorn_core/utils/imports.py,sha256=YNdcNcvvMddeQtahi6SjP2TGzYa2i6Ud-RAq86Bu3RM,402
13
+ tigrcorn_core/utils/net.py,sha256=PxBK6t2na3e3wMI2JywkjJ_UKxtMzrr1WXX_5TwTb_0,607
14
+ tigrcorn_core/utils/proxy.py,sha256=Ne6qLQYCB-m2mCcYYscWqR_eK6lW4l69ba4JffAqPlw,5544
15
+ tigrcorn_core-0.3.16.dist-info/licenses/LICENSE,sha256=xhBSirl227aDQNeQ8tk2v_yiU9nbQpJ4EZp6OtATX-s,9591
16
+ tigrcorn_core-0.3.16.dist-info/METADATA,sha256=qf3yWaHWxFr22UFLUC2XwCZjx-J4YkMaEViNeRXchMI,17977
17
+ tigrcorn_core-0.3.16.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
18
+ tigrcorn_core-0.3.16.dist-info/top_level.txt,sha256=FkHXAUXTJC-VCQF3FddMaKkfF7db6hhUmo_41xNDysc,14
19
+ tigrcorn_core-0.3.16.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (82.0.1)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,163 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction, and
10
+ distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by the
13
+ copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all other
16
+ entities that control, are controlled by, or are under common control with
17
+ that entity. For the purposes of this definition, "control" means (i) the
18
+ power, direct or indirect, to cause the direction or management of such
19
+ entity, whether by contract or otherwise, or (ii) ownership of fifty percent
20
+ (50%) or more of the outstanding shares, or (iii) beneficial ownership of
21
+ such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity exercising
24
+ permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation source, and
28
+ configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical transformation
31
+ or translation of a Source form, including but not limited to compiled object
32
+ code, generated documentation, and conversions to other media types.
33
+
34
+ "Work" shall mean the work of authorship, whether in Source or Object form,
35
+ made available under the License, as indicated by a copyright notice that is
36
+ included in or attached to the work (an example is provided in the Appendix
37
+ below).
38
+
39
+ "Derivative Works" shall mean any work, whether in Source or Object form,
40
+ that is based on (or derived from) the Work and for which the editorial
41
+ revisions, annotations, elaborations, or other modifications represent, as a
42
+ whole, an original work of authorship. For the purposes of this License,
43
+ Derivative Works shall not include works that remain separable from, or
44
+ merely link (or bind by name) to the interfaces of, the Work and Derivative
45
+ Works thereof.
46
+
47
+ "Contribution" shall mean any work of authorship, including the original
48
+ version of the Work and any modifications or additions to that Work or
49
+ Derivative Works thereof, that is intentionally submitted to Licensor for
50
+ inclusion in the Work by the copyright owner or by an individual or Legal
51
+ Entity authorized to submit on behalf of the copyright owner. For the
52
+ purposes of this definition, "submitted" means any form of electronic,
53
+ verbal, or written communication sent to the Licensor or its representatives,
54
+ including but not limited to communication on electronic mailing lists,
55
+ source code control systems, and issue tracking systems that are managed by,
56
+ or on behalf of, the Licensor for the purpose of discussing and improving the
57
+ Work, but excluding communication that is conspicuously marked or otherwise
58
+ designated in writing by the copyright owner as "Not a Contribution."
59
+
60
+ "Contributor" shall mean Licensor and any individual or Legal Entity on
61
+ behalf of whom a Contribution has been received by Licensor and subsequently
62
+ incorporated within the Work.
63
+
64
+ 2. Grant of Copyright License. Subject to the terms and conditions of this
65
+ License, each Contributor hereby grants to You a perpetual, worldwide,
66
+ non-exclusive, no-charge, royalty-free, irrevocable copyright license to
67
+ reproduce, prepare Derivative Works of, publicly display, publicly perform,
68
+ sublicense, and distribute the Work and such Derivative Works in Source or
69
+ Object form.
70
+
71
+ 3. Grant of Patent License. Subject to the terms and conditions of this
72
+ License, each Contributor hereby grants to You a perpetual, worldwide,
73
+ non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this
74
+ section) patent license to make, have made, use, offer to sell, sell, import,
75
+ and otherwise transfer the Work, where such license applies only to those
76
+ patent claims licensable by such Contributor that are necessarily infringed by
77
+ their Contribution(s) alone or by combination of their Contribution(s) with
78
+ the Work to which such Contribution(s) was submitted. If You institute patent
79
+ litigation against any entity (including a cross-claim or counterclaim in a
80
+ lawsuit) alleging that the Work or a Contribution incorporated within the Work
81
+ constitutes direct or contributory patent infringement, then any patent
82
+ licenses granted to You under this License for that Work shall terminate as of
83
+ the date such litigation is filed.
84
+
85
+ 4. Redistribution. You may reproduce and distribute copies of the Work or
86
+ Derivative Works thereof in any medium, with or without modifications, and in
87
+ Source or Object form, provided that You meet the following conditions:
88
+
89
+ (a) You must give any other recipients of the Work or Derivative Works a copy
90
+ of this License; and
91
+
92
+ (b) You must cause any modified files to carry prominent notices stating that
93
+ You changed the files; and
94
+
95
+ (c) You must retain, in the Source form of any Derivative Works that You
96
+ distribute, all copyright, patent, trademark, and attribution notices
97
+ from the Source form of the Work, excluding those notices that do not
98
+ pertain to any part of the Derivative Works; and
99
+
100
+ (d) If the Work includes a "NOTICE" text file as part of its distribution,
101
+ then any Derivative Works that You distribute must include a readable copy
102
+ of the attribution notices contained within such NOTICE file, excluding
103
+ those notices that do not pertain to any part of the Derivative Works, in
104
+ at least one of the following places: within a NOTICE text file distributed
105
+ as part of the Derivative Works; within the Source form or documentation,
106
+ if provided along with the Derivative Works; or, within a display generated
107
+ by the Derivative Works, if and wherever such third-party notices normally
108
+ appear. The contents of the NOTICE file are for informational purposes only
109
+ and do not modify the License. You may add Your own attribution notices
110
+ within Derivative Works that You distribute, alongside or as an addendum to
111
+ the NOTICE text from the Work, provided that such additional attribution
112
+ notices cannot be construed as modifying the License.
113
+
114
+ You may add Your own copyright statement to Your modifications and may provide
115
+ additional or different license terms and conditions for use, reproduction, or
116
+ distribution of Your modifications, or for any such Derivative Works as a
117
+ whole, provided Your use, reproduction, and distribution of the Work otherwise
118
+ complies with the conditions stated in this License.
119
+
120
+ 5. Submission of Contributions. Unless You explicitly state otherwise, any
121
+ Contribution intentionally submitted for inclusion in the Work by You to the
122
+ Licensor shall be under the terms and conditions of this License, without any
123
+ additional terms or conditions. Notwithstanding the above, nothing herein
124
+ shall supersede or modify the terms of any separate license agreement you may
125
+ have executed with Licensor regarding such Contributions.
126
+
127
+ 6. Trademarks. This License does not grant permission to use the trade names,
128
+ trademarks, service marks, or product names of the Licensor, except as
129
+ required for reasonable and customary use in describing the origin of the Work
130
+ and reproducing the content of the NOTICE file.
131
+
132
+ 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in
133
+ writing, Licensor provides the Work (and each Contributor provides its
134
+ Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
135
+ KIND, either express or implied, including, without limitation, any warranties
136
+ or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
137
+ PARTICULAR PURPOSE. You are solely responsible for determining the
138
+ appropriateness of using or redistributing the Work and assume any risks
139
+ associated with Your exercise of permissions under this License.
140
+
141
+ 8. Limitation of Liability. In no event and under no legal theory, whether in
142
+ tort (including negligence), contract, or otherwise, unless required by
143
+ applicable law (such as deliberate and grossly negligent acts) or agreed to in
144
+ writing, shall any Contributor be liable to You for damages, including any
145
+ direct, indirect, special, incidental, or consequential damages of any
146
+ character arising as a result of this License or out of the use or inability
147
+ to use the Work (including but not limited to damages for loss of goodwill,
148
+ work stoppage, computer failure or malfunction, or any and all other
149
+ commercial damages or losses), even if such Contributor has been advised of
150
+ the possibility of such damages.
151
+
152
+ 9. Accepting Warranty or Additional Liability. While redistributing the Work or
153
+ Derivative Works thereof, You may choose to offer, and charge a fee for,
154
+ acceptance of support, warranty, indemnity, or other liability obligations
155
+ and/or rights consistent with this License. However, in accepting such
156
+ obligations, You may act only on Your own behalf and on Your sole
157
+ responsibility, not on behalf of any other Contributor, and only if You agree
158
+ to indemnify, defend, and hold each Contributor harmless for any liability
159
+ incurred by, or claims asserted against, such Contributor by reason of your
160
+ accepting any such warranty or additional liability.
161
+
162
+ END OF TERMS AND CONDITIONS
163
+
@@ -0,0 +1 @@
1
+ tigrcorn_core