adafruit-circuitpython-httpserver 4.6.2__tar.gz → 4.6.4__tar.gz
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.6.4/.gitattributes +11 -0
- adafruit_circuitpython_httpserver-4.6.4/.pre-commit-config.yaml +21 -0
- {adafruit_circuitpython_httpserver-4.6.2 → adafruit_circuitpython_httpserver-4.6.4}/.readthedocs.yaml +1 -1
- {adafruit_circuitpython_httpserver-4.6.2 → adafruit_circuitpython_httpserver-4.6.4}/PKG-INFO +6 -5
- {adafruit_circuitpython_httpserver-4.6.2 → adafruit_circuitpython_httpserver-4.6.4}/README.rst +3 -3
- {adafruit_circuitpython_httpserver-4.6.2 → adafruit_circuitpython_httpserver-4.6.4}/adafruit_circuitpython_httpserver.egg-info/PKG-INFO +6 -5
- {adafruit_circuitpython_httpserver-4.6.2 → adafruit_circuitpython_httpserver-4.6.4}/adafruit_circuitpython_httpserver.egg-info/SOURCES.txt +2 -1
- {adafruit_circuitpython_httpserver-4.6.2 → adafruit_circuitpython_httpserver-4.6.4}/adafruit_httpserver/__init__.py +29 -29
- {adafruit_circuitpython_httpserver-4.6.2 → adafruit_circuitpython_httpserver-4.6.4}/adafruit_httpserver/authentication.py +4 -8
- {adafruit_circuitpython_httpserver-4.6.2 → adafruit_circuitpython_httpserver-4.6.4}/adafruit_httpserver/headers.py +3 -9
- {adafruit_circuitpython_httpserver-4.6.2 → adafruit_circuitpython_httpserver-4.6.4}/adafruit_httpserver/interfaces.py +18 -33
- {adafruit_circuitpython_httpserver-4.6.2 → adafruit_circuitpython_httpserver-4.6.4}/adafruit_httpserver/methods.py +0 -1
- {adafruit_circuitpython_httpserver-4.6.2 → adafruit_circuitpython_httpserver-4.6.4}/adafruit_httpserver/mime_types.py +1 -1
- {adafruit_circuitpython_httpserver-4.6.2 → adafruit_circuitpython_httpserver-4.6.4}/adafruit_httpserver/request.py +14 -30
- {adafruit_circuitpython_httpserver-4.6.2 → adafruit_circuitpython_httpserver-4.6.4}/adafruit_httpserver/response.py +34 -48
- {adafruit_circuitpython_httpserver-4.6.2 → adafruit_circuitpython_httpserver-4.6.4}/adafruit_httpserver/route.py +2 -4
- {adafruit_circuitpython_httpserver-4.6.2 → adafruit_circuitpython_httpserver-4.6.4}/adafruit_httpserver/server.py +21 -30
- {adafruit_circuitpython_httpserver-4.6.2 → adafruit_circuitpython_httpserver-4.6.4}/adafruit_httpserver/status.py +1 -1
- {adafruit_circuitpython_httpserver-4.6.2 → adafruit_circuitpython_httpserver-4.6.4}/docs/api.rst +3 -0
- {adafruit_circuitpython_httpserver-4.6.2 → adafruit_circuitpython_httpserver-4.6.4}/docs/conf.py +2 -6
- {adafruit_circuitpython_httpserver-4.6.2 → adafruit_circuitpython_httpserver-4.6.4}/docs/examples.rst +20 -20
- {adafruit_circuitpython_httpserver-4.6.2 → adafruit_circuitpython_httpserver-4.6.4}/docs/starting_methods.rst +4 -4
- {adafruit_circuitpython_httpserver-4.6.2 → adafruit_circuitpython_httpserver-4.6.4}/examples/httpserver_authentication_handlers.py +2 -3
- {adafruit_circuitpython_httpserver-4.6.2 → adafruit_circuitpython_httpserver-4.6.4}/examples/httpserver_authentication_server.py +1 -2
- {adafruit_circuitpython_httpserver-4.6.2 → adafruit_circuitpython_httpserver-4.6.4}/examples/httpserver_chunked.py +1 -2
- {adafruit_circuitpython_httpserver-4.6.2 → adafruit_circuitpython_httpserver-4.6.4}/examples/httpserver_cookies.py +1 -2
- {adafruit_circuitpython_httpserver-4.6.2 → adafruit_circuitpython_httpserver-4.6.4}/examples/httpserver_cpu_information.py +1 -2
- {adafruit_circuitpython_httpserver-4.6.2 → adafruit_circuitpython_httpserver-4.6.4}/examples/httpserver_cpython.py +1 -2
- {adafruit_circuitpython_httpserver-4.6.2 → adafruit_circuitpython_httpserver-4.6.4}/examples/httpserver_form_data.py +1 -2
- {adafruit_circuitpython_httpserver-4.6.2 → adafruit_circuitpython_httpserver-4.6.4}/examples/httpserver_handler_serves_file.py +1 -2
- {adafruit_circuitpython_httpserver-4.6.2 → adafruit_circuitpython_httpserver-4.6.4}/examples/httpserver_https.py +1 -2
- {adafruit_circuitpython_httpserver-4.6.2 → adafruit_circuitpython_httpserver-4.6.4}/examples/httpserver_mdns.py +1 -2
- {adafruit_circuitpython_httpserver-4.6.2 → adafruit_circuitpython_httpserver-4.6.4}/examples/httpserver_methods.py +4 -9
- {adafruit_circuitpython_httpserver-4.6.2 → adafruit_circuitpython_httpserver-4.6.4}/examples/httpserver_multiple_servers.py +1 -2
- {adafruit_circuitpython_httpserver-4.6.2 → adafruit_circuitpython_httpserver-4.6.4}/examples/httpserver_neopixel.py +1 -2
- {adafruit_circuitpython_httpserver-4.6.2 → adafruit_circuitpython_httpserver-4.6.4}/examples/httpserver_redirects.py +5 -6
- {adafruit_circuitpython_httpserver-4.6.2 → adafruit_circuitpython_httpserver-4.6.4}/examples/httpserver_simpletest_auto_connection_manager.py +1 -2
- {adafruit_circuitpython_httpserver-4.6.2 → adafruit_circuitpython_httpserver-4.6.4}/examples/httpserver_simpletest_auto_settings_toml.py +1 -2
- {adafruit_circuitpython_httpserver-4.6.2 → adafruit_circuitpython_httpserver-4.6.4}/examples/httpserver_simpletest_manual_ap.py +1 -2
- {adafruit_circuitpython_httpserver-4.6.2 → adafruit_circuitpython_httpserver-4.6.4}/examples/httpserver_simpletest_manual_ethernet.py +2 -3
- {adafruit_circuitpython_httpserver-4.6.2 → adafruit_circuitpython_httpserver-4.6.4}/examples/httpserver_simpletest_manual_wifi.py +1 -1
- {adafruit_circuitpython_httpserver-4.6.2 → adafruit_circuitpython_httpserver-4.6.4}/examples/httpserver_sse.py +3 -3
- {adafruit_circuitpython_httpserver-4.6.2 → adafruit_circuitpython_httpserver-4.6.4}/examples/httpserver_start_and_poll.py +2 -3
- {adafruit_circuitpython_httpserver-4.6.2 → adafruit_circuitpython_httpserver-4.6.4}/examples/httpserver_start_and_poll_asyncio.py +5 -4
- {adafruit_circuitpython_httpserver-4.6.2 → adafruit_circuitpython_httpserver-4.6.4}/examples/httpserver_static_files_serving.py +1 -2
- {adafruit_circuitpython_httpserver-4.6.2 → adafruit_circuitpython_httpserver-4.6.4}/examples/httpserver_templates.py +1 -1
- {adafruit_circuitpython_httpserver-4.6.2 → adafruit_circuitpython_httpserver-4.6.4}/examples/httpserver_url_parameters.py +8 -13
- {adafruit_circuitpython_httpserver-4.6.2 → adafruit_circuitpython_httpserver-4.6.4}/examples/httpserver_video_stream.py +3 -8
- {adafruit_circuitpython_httpserver-4.6.2 → adafruit_circuitpython_httpserver-4.6.4}/examples/httpserver_websocket.py +5 -4
- {adafruit_circuitpython_httpserver-4.6.2 → adafruit_circuitpython_httpserver-4.6.4}/pyproject.toml +1 -1
- adafruit_circuitpython_httpserver-4.6.4/ruff.toml +112 -0
- adafruit_circuitpython_httpserver-4.6.2/.pre-commit-config.yaml +0 -42
- adafruit_circuitpython_httpserver-4.6.2/.pylintrc +0 -399
- {adafruit_circuitpython_httpserver-4.6.2 → adafruit_circuitpython_httpserver-4.6.4}/.github/PULL_REQUEST_TEMPLATE/adafruit_circuitpython_pr.md +0 -0
- {adafruit_circuitpython_httpserver-4.6.2 → adafruit_circuitpython_httpserver-4.6.4}/.github/workflows/build.yml +0 -0
- {adafruit_circuitpython_httpserver-4.6.2 → adafruit_circuitpython_httpserver-4.6.4}/.github/workflows/failure-help-text.yml +0 -0
- {adafruit_circuitpython_httpserver-4.6.2 → adafruit_circuitpython_httpserver-4.6.4}/.github/workflows/release_gh.yml +0 -0
- {adafruit_circuitpython_httpserver-4.6.2 → adafruit_circuitpython_httpserver-4.6.4}/.github/workflows/release_pypi.yml +0 -0
- {adafruit_circuitpython_httpserver-4.6.2 → adafruit_circuitpython_httpserver-4.6.4}/.gitignore +0 -0
- {adafruit_circuitpython_httpserver-4.6.2 → adafruit_circuitpython_httpserver-4.6.4}/CODE_OF_CONDUCT.md +0 -0
- {adafruit_circuitpython_httpserver-4.6.2 → adafruit_circuitpython_httpserver-4.6.4}/LICENSE +0 -0
- {adafruit_circuitpython_httpserver-4.6.2 → adafruit_circuitpython_httpserver-4.6.4}/LICENSES/CC-BY-4.0.txt +0 -0
- {adafruit_circuitpython_httpserver-4.6.2 → adafruit_circuitpython_httpserver-4.6.4}/LICENSES/MIT.txt +0 -0
- {adafruit_circuitpython_httpserver-4.6.2 → adafruit_circuitpython_httpserver-4.6.4}/LICENSES/Unlicense.txt +0 -0
- {adafruit_circuitpython_httpserver-4.6.2 → adafruit_circuitpython_httpserver-4.6.4}/README.rst.license +0 -0
- {adafruit_circuitpython_httpserver-4.6.2 → adafruit_circuitpython_httpserver-4.6.4}/adafruit_circuitpython_httpserver.egg-info/dependency_links.txt +0 -0
- {adafruit_circuitpython_httpserver-4.6.2 → adafruit_circuitpython_httpserver-4.6.4}/adafruit_circuitpython_httpserver.egg-info/requires.txt +0 -0
- {adafruit_circuitpython_httpserver-4.6.2 → adafruit_circuitpython_httpserver-4.6.4}/adafruit_circuitpython_httpserver.egg-info/top_level.txt +0 -0
- {adafruit_circuitpython_httpserver-4.6.2 → adafruit_circuitpython_httpserver-4.6.4}/adafruit_httpserver/exceptions.py +0 -0
- {adafruit_circuitpython_httpserver-4.6.2 → adafruit_circuitpython_httpserver-4.6.4}/docs/_static/favicon.ico +0 -0
- {adafruit_circuitpython_httpserver-4.6.2 → adafruit_circuitpython_httpserver-4.6.4}/docs/_static/favicon.ico.license +0 -0
- {adafruit_circuitpython_httpserver-4.6.2 → adafruit_circuitpython_httpserver-4.6.4}/docs/api.rst.license +0 -0
- {adafruit_circuitpython_httpserver-4.6.2 → adafruit_circuitpython_httpserver-4.6.4}/docs/examples.rst.license +0 -0
- {adafruit_circuitpython_httpserver-4.6.2 → adafruit_circuitpython_httpserver-4.6.4}/docs/index.rst +0 -0
- {adafruit_circuitpython_httpserver-4.6.2 → adafruit_circuitpython_httpserver-4.6.4}/docs/index.rst.license +0 -0
- {adafruit_circuitpython_httpserver-4.6.2 → adafruit_circuitpython_httpserver-4.6.4}/docs/requirements.txt +0 -0
- {adafruit_circuitpython_httpserver-4.6.2 → adafruit_circuitpython_httpserver-4.6.4}/docs/starting_methods.rst.license +0 -0
- {adafruit_circuitpython_httpserver-4.6.2 → adafruit_circuitpython_httpserver-4.6.4}/examples/directory_listing.tpl.html +0 -0
- {adafruit_circuitpython_httpserver-4.6.2 → adafruit_circuitpython_httpserver-4.6.4}/examples/home.html +0 -0
- {adafruit_circuitpython_httpserver-4.6.2 → adafruit_circuitpython_httpserver-4.6.4}/examples/settings.toml +0 -0
- {adafruit_circuitpython_httpserver-4.6.2 → adafruit_circuitpython_httpserver-4.6.4}/optional_requirements.txt +0 -0
- {adafruit_circuitpython_httpserver-4.6.2 → adafruit_circuitpython_httpserver-4.6.4}/requirements.txt +0 -0
- {adafruit_circuitpython_httpserver-4.6.2 → adafruit_circuitpython_httpserver-4.6.4}/setup.cfg +0 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: 2024 Justin Myers for Adafruit Industries
|
|
2
|
+
#
|
|
3
|
+
# SPDX-License-Identifier: Unlicense
|
|
4
|
+
|
|
5
|
+
repos:
|
|
6
|
+
- repo: https://github.com/pre-commit/pre-commit-hooks
|
|
7
|
+
rev: v4.5.0
|
|
8
|
+
hooks:
|
|
9
|
+
- id: check-yaml
|
|
10
|
+
- id: end-of-file-fixer
|
|
11
|
+
- id: trailing-whitespace
|
|
12
|
+
- repo: https://github.com/astral-sh/ruff-pre-commit
|
|
13
|
+
rev: v0.3.4
|
|
14
|
+
hooks:
|
|
15
|
+
- id: ruff-format
|
|
16
|
+
- id: ruff
|
|
17
|
+
args: ["--fix"]
|
|
18
|
+
- repo: https://github.com/fsfe/reuse-tool
|
|
19
|
+
rev: v3.0.1
|
|
20
|
+
hooks:
|
|
21
|
+
- id: reuse
|
{adafruit_circuitpython_httpserver-4.6.2 → adafruit_circuitpython_httpserver-4.6.4}/PKG-INFO
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: adafruit-circuitpython-httpserver
|
|
3
|
-
Version: 4.6.
|
|
3
|
+
Version: 4.6.4
|
|
4
4
|
Summary: Simple HTTP Server for CircuitPython
|
|
5
5
|
Author-email: Adafruit Industries <circuitpython@adafruit.com>
|
|
6
6
|
License: MIT
|
|
@@ -16,6 +16,7 @@ Description-Content-Type: text/x-rst
|
|
|
16
16
|
License-File: LICENSE
|
|
17
17
|
Requires-Dist: Adafruit-Blinka
|
|
18
18
|
Provides-Extra: optional
|
|
19
|
+
Dynamic: license-file
|
|
19
20
|
|
|
20
21
|
Introduction
|
|
21
22
|
============
|
|
@@ -36,9 +37,9 @@ Introduction
|
|
|
36
37
|
:alt: Build Status
|
|
37
38
|
|
|
38
39
|
|
|
39
|
-
.. image:: https://img.shields.io/badge/
|
|
40
|
-
:target: https://github.com/
|
|
41
|
-
:alt: Code Style:
|
|
40
|
+
.. image:: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json
|
|
41
|
+
:target: https://github.com/astral-sh/ruff
|
|
42
|
+
:alt: Code Style: Ruff
|
|
42
43
|
|
|
43
44
|
HTTP Server for CircuitPython.
|
|
44
45
|
|
{adafruit_circuitpython_httpserver-4.6.2 → adafruit_circuitpython_httpserver-4.6.4}/README.rst
RENAMED
|
@@ -17,9 +17,9 @@ Introduction
|
|
|
17
17
|
:alt: Build Status
|
|
18
18
|
|
|
19
19
|
|
|
20
|
-
.. image:: https://img.shields.io/badge/
|
|
21
|
-
:target: https://github.com/
|
|
22
|
-
:alt: Code Style:
|
|
20
|
+
.. image:: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json
|
|
21
|
+
:target: https://github.com/astral-sh/ruff
|
|
22
|
+
:alt: Code Style: Ruff
|
|
23
23
|
|
|
24
24
|
HTTP Server for CircuitPython.
|
|
25
25
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: adafruit-circuitpython-httpserver
|
|
3
|
-
Version: 4.6.
|
|
3
|
+
Version: 4.6.4
|
|
4
4
|
Summary: Simple HTTP Server for CircuitPython
|
|
5
5
|
Author-email: Adafruit Industries <circuitpython@adafruit.com>
|
|
6
6
|
License: MIT
|
|
@@ -16,6 +16,7 @@ Description-Content-Type: text/x-rst
|
|
|
16
16
|
License-File: LICENSE
|
|
17
17
|
Requires-Dist: Adafruit-Blinka
|
|
18
18
|
Provides-Extra: optional
|
|
19
|
+
Dynamic: license-file
|
|
19
20
|
|
|
20
21
|
Introduction
|
|
21
22
|
============
|
|
@@ -36,9 +37,9 @@ Introduction
|
|
|
36
37
|
:alt: Build Status
|
|
37
38
|
|
|
38
39
|
|
|
39
|
-
.. image:: https://img.shields.io/badge/
|
|
40
|
-
:target: https://github.com/
|
|
41
|
-
:alt: Code Style:
|
|
40
|
+
.. image:: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json
|
|
41
|
+
:target: https://github.com/astral-sh/ruff
|
|
42
|
+
:alt: Code Style: Ruff
|
|
42
43
|
|
|
43
44
|
HTTP Server for CircuitPython.
|
|
44
45
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
.gitattributes
|
|
1
2
|
.gitignore
|
|
2
3
|
.pre-commit-config.yaml
|
|
3
|
-
.pylintrc
|
|
4
4
|
.readthedocs.yaml
|
|
5
5
|
CODE_OF_CONDUCT.md
|
|
6
6
|
LICENSE
|
|
@@ -9,6 +9,7 @@ README.rst.license
|
|
|
9
9
|
optional_requirements.txt
|
|
10
10
|
pyproject.toml
|
|
11
11
|
requirements.txt
|
|
12
|
+
ruff.toml
|
|
12
13
|
.github/PULL_REQUEST_TEMPLATE/adafruit_circuitpython_pr.md
|
|
13
14
|
.github/workflows/build.yml
|
|
14
15
|
.github/workflows/failure-help-text.yml
|
|
@@ -19,76 +19,76 @@ Implementation Notes
|
|
|
19
19
|
https://github.com/adafruit/circuitpython/releases
|
|
20
20
|
"""
|
|
21
21
|
|
|
22
|
-
__version__ = "4.6.
|
|
22
|
+
__version__ = "4.6.4"
|
|
23
23
|
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_HTTPServer.git"
|
|
24
24
|
|
|
25
25
|
|
|
26
26
|
from .authentication import (
|
|
27
27
|
Basic,
|
|
28
|
-
Token,
|
|
29
28
|
Bearer,
|
|
29
|
+
Token,
|
|
30
30
|
check_authentication,
|
|
31
31
|
require_authentication,
|
|
32
32
|
)
|
|
33
33
|
from .exceptions import (
|
|
34
|
-
ServerStoppedError,
|
|
35
34
|
AuthenticationError,
|
|
35
|
+
BackslashInPathError,
|
|
36
|
+
FileNotExistsError,
|
|
36
37
|
InvalidPathError,
|
|
37
38
|
ParentDirectoryReferenceError,
|
|
38
|
-
|
|
39
|
+
ServerStoppedError,
|
|
39
40
|
ServingFilesDisabledError,
|
|
40
|
-
FileNotExistsError,
|
|
41
41
|
)
|
|
42
42
|
from .headers import Headers
|
|
43
43
|
from .methods import (
|
|
44
|
-
|
|
45
|
-
POST,
|
|
46
|
-
PUT,
|
|
44
|
+
CONNECT,
|
|
47
45
|
DELETE,
|
|
48
|
-
|
|
46
|
+
GET,
|
|
49
47
|
HEAD,
|
|
50
48
|
OPTIONS,
|
|
49
|
+
PATCH,
|
|
50
|
+
POST,
|
|
51
|
+
PUT,
|
|
51
52
|
TRACE,
|
|
52
|
-
CONNECT,
|
|
53
53
|
)
|
|
54
54
|
from .mime_types import MIMETypes
|
|
55
|
-
from .request import
|
|
55
|
+
from .request import FormData, QueryParams, Request
|
|
56
56
|
from .response import (
|
|
57
|
-
Response,
|
|
58
|
-
FileResponse,
|
|
59
57
|
ChunkedResponse,
|
|
58
|
+
FileResponse,
|
|
60
59
|
JSONResponse,
|
|
61
60
|
Redirect,
|
|
61
|
+
Response,
|
|
62
62
|
SSEResponse,
|
|
63
63
|
Websocket,
|
|
64
64
|
)
|
|
65
65
|
from .route import Route, as_route
|
|
66
66
|
from .server import (
|
|
67
|
-
Server,
|
|
68
|
-
NO_REQUEST,
|
|
69
67
|
CONNECTION_TIMED_OUT,
|
|
68
|
+
NO_REQUEST,
|
|
70
69
|
REQUEST_HANDLED_NO_RESPONSE,
|
|
71
70
|
REQUEST_HANDLED_RESPONSE_SENT,
|
|
71
|
+
Server,
|
|
72
72
|
)
|
|
73
73
|
from .status import (
|
|
74
|
-
Status,
|
|
75
|
-
SWITCHING_PROTOCOLS_101,
|
|
76
|
-
OK_200,
|
|
77
|
-
CREATED_201,
|
|
78
74
|
ACCEPTED_202,
|
|
79
|
-
NO_CONTENT_204,
|
|
80
|
-
PARTIAL_CONTENT_206,
|
|
81
|
-
MOVED_PERMANENTLY_301,
|
|
82
|
-
FOUND_302,
|
|
83
|
-
TEMPORARY_REDIRECT_307,
|
|
84
|
-
PERMANENT_REDIRECT_308,
|
|
85
75
|
BAD_REQUEST_400,
|
|
86
|
-
|
|
76
|
+
CREATED_201,
|
|
87
77
|
FORBIDDEN_403,
|
|
88
|
-
|
|
89
|
-
METHOD_NOT_ALLOWED_405,
|
|
90
|
-
TOO_MANY_REQUESTS_429,
|
|
78
|
+
FOUND_302,
|
|
91
79
|
INTERNAL_SERVER_ERROR_500,
|
|
80
|
+
METHOD_NOT_ALLOWED_405,
|
|
81
|
+
MOVED_PERMANENTLY_301,
|
|
82
|
+
NO_CONTENT_204,
|
|
83
|
+
NOT_FOUND_404,
|
|
92
84
|
NOT_IMPLEMENTED_501,
|
|
85
|
+
OK_200,
|
|
86
|
+
PARTIAL_CONTENT_206,
|
|
87
|
+
PERMANENT_REDIRECT_308,
|
|
93
88
|
SERVICE_UNAVAILABLE_503,
|
|
89
|
+
SWITCHING_PROTOCOLS_101,
|
|
90
|
+
TEMPORARY_REDIRECT_307,
|
|
91
|
+
TOO_MANY_REQUESTS_429,
|
|
92
|
+
UNAUTHORIZED_401,
|
|
93
|
+
Status,
|
|
94
94
|
)
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"""
|
|
9
9
|
|
|
10
10
|
try:
|
|
11
|
-
from typing import
|
|
11
|
+
from typing import List, Union
|
|
12
12
|
except ImportError:
|
|
13
13
|
pass
|
|
14
14
|
|
|
@@ -40,15 +40,13 @@ class Token:
|
|
|
40
40
|
return f"{self.prefix} {self._value}"
|
|
41
41
|
|
|
42
42
|
|
|
43
|
-
class Bearer(Token):
|
|
43
|
+
class Bearer(Token):
|
|
44
44
|
"""Represents HTTP Bearer Token Authentication."""
|
|
45
45
|
|
|
46
46
|
prefix = "Bearer"
|
|
47
47
|
|
|
48
48
|
|
|
49
|
-
def check_authentication(
|
|
50
|
-
request: Request, auths: List[Union[Basic, Token, Bearer]]
|
|
51
|
-
) -> bool:
|
|
49
|
+
def check_authentication(request: Request, auths: List[Union[Basic, Token, Bearer]]) -> bool:
|
|
52
50
|
"""
|
|
53
51
|
Returns ``True`` if request is authorized by any of the authentications, ``False`` otherwise.
|
|
54
52
|
|
|
@@ -65,9 +63,7 @@ def check_authentication(
|
|
|
65
63
|
return any(auth_header == str(auth) for auth in auths)
|
|
66
64
|
|
|
67
65
|
|
|
68
|
-
def require_authentication(
|
|
69
|
-
request: Request, auths: List[Union[Basic, Token, Bearer]]
|
|
70
|
-
) -> None:
|
|
66
|
+
def require_authentication(request: Request, auths: List[Union[Basic, Token, Bearer]]) -> None:
|
|
71
67
|
"""
|
|
72
68
|
Checks if the request is authorized and raises ``AuthenticationError`` if not.
|
|
73
69
|
|
|
@@ -93,9 +93,7 @@ class Headers(_IFieldStorage):
|
|
|
93
93
|
return default
|
|
94
94
|
return header_value.split(";")[0].strip('" ')
|
|
95
95
|
|
|
96
|
-
def get_parameter(
|
|
97
|
-
self, name: str, parameter: str, default: str = None
|
|
98
|
-
) -> Union[str, None]:
|
|
96
|
+
def get_parameter(self, name: str, parameter: str, default: str = None) -> Union[str, None]:
|
|
99
97
|
"""
|
|
100
98
|
Returns the value of the given parameter for the given header name, or default if not found.
|
|
101
99
|
|
|
@@ -124,16 +122,12 @@ class Headers(_IFieldStorage):
|
|
|
124
122
|
|
|
125
123
|
def update(self, headers: Dict[str, str]):
|
|
126
124
|
"""Updates the headers with the given dict."""
|
|
127
|
-
return self._storage.update(
|
|
128
|
-
{key.lower(): [value] for key, value in headers.items()}
|
|
129
|
-
)
|
|
125
|
+
return self._storage.update({key.lower(): [value] for key, value in headers.items()})
|
|
130
126
|
|
|
131
127
|
def copy(self):
|
|
132
128
|
"""Returns a copy of the headers."""
|
|
133
129
|
return Headers(
|
|
134
|
-
"\r\n".join(
|
|
135
|
-
f"{key}: {value}" for key in self.fields for value in self.get_list(key)
|
|
136
|
-
)
|
|
130
|
+
"\r\n".join(f"{key}: {value}" for key in self.fields for value in self.get_list(key))
|
|
137
131
|
)
|
|
138
132
|
|
|
139
133
|
def __getitem__(self, name: str):
|
|
@@ -8,43 +8,34 @@
|
|
|
8
8
|
"""
|
|
9
9
|
|
|
10
10
|
try:
|
|
11
|
-
from typing import
|
|
11
|
+
from typing import Any, Dict, List, Tuple, Union
|
|
12
12
|
except ImportError:
|
|
13
13
|
pass
|
|
14
14
|
|
|
15
15
|
|
|
16
|
-
class _ISocket:
|
|
16
|
+
class _ISocket:
|
|
17
17
|
"""A class for typing necessary methods for a socket object."""
|
|
18
18
|
|
|
19
|
-
def accept(self) -> Tuple["_ISocket", Tuple[str, int]]:
|
|
20
|
-
...
|
|
19
|
+
def accept(self) -> Tuple["_ISocket", Tuple[str, int]]: ...
|
|
21
20
|
|
|
22
|
-
def bind(self, address: Tuple[str, int]) -> None:
|
|
23
|
-
...
|
|
21
|
+
def bind(self, address: Tuple[str, int]) -> None: ...
|
|
24
22
|
|
|
25
|
-
def setblocking(self, flag: bool) -> None:
|
|
26
|
-
...
|
|
23
|
+
def setblocking(self, flag: bool) -> None: ...
|
|
27
24
|
|
|
28
|
-
def settimeout(self, value: "Union[float, None]") -> None:
|
|
29
|
-
...
|
|
25
|
+
def settimeout(self, value: "Union[float, None]") -> None: ...
|
|
30
26
|
|
|
31
|
-
def setsockopt(self, level: int, optname: int, value: int) -> None:
|
|
32
|
-
...
|
|
27
|
+
def setsockopt(self, level: int, optname: int, value: int) -> None: ...
|
|
33
28
|
|
|
34
|
-
def listen(self, backlog: int) -> None:
|
|
35
|
-
...
|
|
29
|
+
def listen(self, backlog: int) -> None: ...
|
|
36
30
|
|
|
37
|
-
def send(self, data: bytes) -> int:
|
|
38
|
-
...
|
|
31
|
+
def send(self, data: bytes) -> int: ...
|
|
39
32
|
|
|
40
|
-
def recv_into(self, buffer: memoryview, nbytes: int) -> int:
|
|
41
|
-
...
|
|
33
|
+
def recv_into(self, buffer: memoryview, nbytes: int) -> int: ...
|
|
42
34
|
|
|
43
|
-
def close(self) -> None:
|
|
44
|
-
...
|
|
35
|
+
def close(self) -> None: ...
|
|
45
36
|
|
|
46
37
|
|
|
47
|
-
class _ISocketPool:
|
|
38
|
+
class _ISocketPool:
|
|
48
39
|
"""A class to typing necessary methods and properties for a socket pool object."""
|
|
49
40
|
|
|
50
41
|
AF_INET: int
|
|
@@ -52,15 +43,14 @@ class _ISocketPool: # pylint: disable=missing-function-docstring,no-self-use,un
|
|
|
52
43
|
SOCK_STREAM: int
|
|
53
44
|
SOL_SOCKET: int
|
|
54
45
|
|
|
55
|
-
def socket(
|
|
46
|
+
def socket(
|
|
56
47
|
self,
|
|
57
48
|
family: int = ...,
|
|
58
49
|
type: int = ...,
|
|
59
50
|
proto: int = ...,
|
|
60
|
-
) -> _ISocket:
|
|
61
|
-
...
|
|
51
|
+
) -> _ISocket: ...
|
|
62
52
|
|
|
63
|
-
def getaddrinfo(
|
|
53
|
+
def getaddrinfo(
|
|
64
54
|
self,
|
|
65
55
|
host: str,
|
|
66
56
|
port: int,
|
|
@@ -68,8 +58,7 @@ class _ISocketPool: # pylint: disable=missing-function-docstring,no-self-use,un
|
|
|
68
58
|
type: int = ...,
|
|
69
59
|
proto: int = ...,
|
|
70
60
|
flags: int = ...,
|
|
71
|
-
) -> Tuple[int, int, int, str, Tuple[str, int]]:
|
|
72
|
-
...
|
|
61
|
+
) -> Tuple[int, int, int, str, Tuple[str, int]]: ...
|
|
73
62
|
|
|
74
63
|
|
|
75
64
|
class _IFieldStorage:
|
|
@@ -140,9 +129,7 @@ def _encode_html_entities(value: Union[str, None]) -> Union[str, None]:
|
|
|
140
129
|
|
|
141
130
|
|
|
142
131
|
class _IXSSSafeFieldStorage(_IFieldStorage):
|
|
143
|
-
def get(
|
|
144
|
-
self, field_name: str, default: Any = None, *, safe=True
|
|
145
|
-
) -> Union[Any, None]:
|
|
132
|
+
def get(self, field_name: str, default: Any = None, *, safe=True) -> Union[Any, None]:
|
|
146
133
|
if safe:
|
|
147
134
|
return _encode_html_entities(super().get(field_name, default))
|
|
148
135
|
|
|
@@ -151,9 +138,7 @@ class _IXSSSafeFieldStorage(_IFieldStorage):
|
|
|
151
138
|
|
|
152
139
|
def get_list(self, field_name: str, *, safe=True) -> List[Any]:
|
|
153
140
|
if safe:
|
|
154
|
-
return [
|
|
155
|
-
_encode_html_entities(value) for value in super().get_list(field_name)
|
|
156
|
-
]
|
|
141
|
+
return [_encode_html_entities(value) for value in super().get_list(field_name)]
|
|
157
142
|
|
|
158
143
|
_debug_warning_nonencoded_output()
|
|
159
144
|
return super().get_list(field_name)
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"""
|
|
9
9
|
|
|
10
10
|
try:
|
|
11
|
-
from typing import
|
|
11
|
+
from typing import TYPE_CHECKING, Any, Dict, List, Tuple, Union
|
|
12
12
|
|
|
13
13
|
if TYPE_CHECKING:
|
|
14
14
|
from .server import Server
|
|
@@ -18,8 +18,8 @@ except ImportError:
|
|
|
18
18
|
import json
|
|
19
19
|
|
|
20
20
|
from .headers import Headers
|
|
21
|
-
from .interfaces import
|
|
22
|
-
from .methods import
|
|
21
|
+
from .interfaces import _IFieldStorage, _ISocket, _IXSSSafeFieldStorage
|
|
22
|
+
from .methods import DELETE, PATCH, POST, PUT
|
|
23
23
|
|
|
24
24
|
|
|
25
25
|
class QueryParams(_IXSSSafeFieldStorage):
|
|
@@ -54,9 +54,7 @@ class QueryParams(_IXSSSafeFieldStorage):
|
|
|
54
54
|
def _add_field_value(self, field_name: str, value: str) -> None:
|
|
55
55
|
super()._add_field_value(field_name, value)
|
|
56
56
|
|
|
57
|
-
def get(
|
|
58
|
-
self, field_name: str, default: str = None, *, safe=True
|
|
59
|
-
) -> Union[str, None]:
|
|
57
|
+
def get(self, field_name: str, default: str = None, *, safe=True) -> Union[str, None]:
|
|
60
58
|
return super().get(field_name, default, safe=safe)
|
|
61
59
|
|
|
62
60
|
def get_list(self, field_name: str, *, safe=True) -> List[str]:
|
|
@@ -92,9 +90,7 @@ class File:
|
|
|
92
90
|
content: Union[str, bytes]
|
|
93
91
|
"""Content of the file."""
|
|
94
92
|
|
|
95
|
-
def __init__(
|
|
96
|
-
self, filename: str, content_type: str, content: Union[str, bytes]
|
|
97
|
-
) -> None:
|
|
93
|
+
def __init__(self, filename: str, content_type: str, content: Union[str, bytes]) -> None:
|
|
98
94
|
self.filename = filename
|
|
99
95
|
self.content_type = content_type
|
|
100
96
|
self.content = content
|
|
@@ -112,11 +108,7 @@ class File:
|
|
|
112
108
|
with open(file.filename, "wb") as f:
|
|
113
109
|
f.write(file.content_bytes)
|
|
114
110
|
"""
|
|
115
|
-
return (
|
|
116
|
-
self.content.encode("utf-8")
|
|
117
|
-
if isinstance(self.content, str)
|
|
118
|
-
else self.content
|
|
119
|
-
)
|
|
111
|
+
return self.content.encode("utf-8") if isinstance(self.content, str) else self.content
|
|
120
112
|
|
|
121
113
|
@property
|
|
122
114
|
def size(self) -> int:
|
|
@@ -177,11 +169,11 @@ class FormData(_IXSSSafeFieldStorage):
|
|
|
177
169
|
|
|
178
170
|
@staticmethod
|
|
179
171
|
def _check_is_supported_content_type(content_type: str) -> None:
|
|
180
|
-
return content_type in
|
|
172
|
+
return content_type in {
|
|
181
173
|
"application/x-www-form-urlencoded",
|
|
182
174
|
"multipart/form-data",
|
|
183
175
|
"text/plain",
|
|
184
|
-
|
|
176
|
+
}
|
|
185
177
|
|
|
186
178
|
def __init__(self, data: bytes, headers: Headers, *, debug: bool = False) -> None:
|
|
187
179
|
self._storage = {}
|
|
@@ -231,9 +223,7 @@ class FormData(_IXSSSafeFieldStorage):
|
|
|
231
223
|
# TODO: Other text content types (e.g. application/json) should be decoded as well and
|
|
232
224
|
|
|
233
225
|
if filename is not None:
|
|
234
|
-
self.files._add_field_value(
|
|
235
|
-
field_name, File(filename, content_type, value)
|
|
236
|
-
)
|
|
226
|
+
self.files._add_field_value(field_name, File(filename, content_type, value))
|
|
237
227
|
else:
|
|
238
228
|
self._add_field_value(field_name, value)
|
|
239
229
|
|
|
@@ -258,12 +248,10 @@ class FormData(_IXSSSafeFieldStorage):
|
|
|
258
248
|
|
|
259
249
|
def __repr__(self) -> str:
|
|
260
250
|
class_name = self.__class__.__name__
|
|
261
|
-
return (
|
|
262
|
-
f"<{class_name} {repr(self._storage)}, files={repr(self.files._storage)}>"
|
|
263
|
-
)
|
|
251
|
+
return f"<{class_name} {repr(self._storage)}, files={repr(self.files._storage)}>"
|
|
264
252
|
|
|
265
253
|
|
|
266
|
-
class Request:
|
|
254
|
+
class Request:
|
|
267
255
|
"""
|
|
268
256
|
Incoming request, constructed from raw incoming bytes.
|
|
269
257
|
It is passed as first argument to all route handlers.
|
|
@@ -367,9 +355,7 @@ class Request: # pylint: disable=too-many-instance-attributes
|
|
|
367
355
|
|
|
368
356
|
return {
|
|
369
357
|
name: value.strip('"')
|
|
370
|
-
for name, value in [
|
|
371
|
-
cookie.strip().split("=", 1) for cookie in cookie_header.split(";")
|
|
372
|
-
]
|
|
358
|
+
for name, value in [cookie.strip().split("=", 1) for cookie in cookie_header.split(";")]
|
|
373
359
|
}
|
|
374
360
|
|
|
375
361
|
@property
|
|
@@ -443,7 +429,7 @@ class Request: # pylint: disable=too-many-instance-attributes
|
|
|
443
429
|
"""
|
|
444
430
|
return (
|
|
445
431
|
json.loads(self.body)
|
|
446
|
-
if (self.body and self.method in
|
|
432
|
+
if (self.body and self.method in {POST, PUT, PATCH, DELETE})
|
|
447
433
|
else None
|
|
448
434
|
)
|
|
449
435
|
|
|
@@ -467,9 +453,7 @@ class Request: # pylint: disable=too-many-instance-attributes
|
|
|
467
453
|
) -> Tuple[str, str, QueryParams, str, Headers]:
|
|
468
454
|
"""Parse HTTP Start line to method, path, query_params and http_version."""
|
|
469
455
|
|
|
470
|
-
start_line, headers_string = (
|
|
471
|
-
header_bytes.decode("utf-8").strip().split("\r\n", 1)
|
|
472
|
-
)
|
|
456
|
+
start_line, headers_string = header_bytes.decode("utf-8").strip().split("\r\n", 1)
|
|
473
457
|
|
|
474
458
|
method, path, http_version = start_line.strip().split()
|
|
475
459
|
|