httplint 2026.1.8__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.
- httplint-2026.1.8/LICENSE.md +19 -0
- httplint-2026.1.8/PKG-INFO +150 -0
- httplint-2026.1.8/README.md +91 -0
- httplint-2026.1.8/httplint/__init__.py +6 -0
- httplint-2026.1.8/httplint/cache.py +617 -0
- httplint-2026.1.8/httplint/cli/__init__.py +43 -0
- httplint-2026.1.8/httplint/cli/http_parser.py +116 -0
- httplint-2026.1.8/httplint/content_encoding.py +188 -0
- httplint-2026.1.8/httplint/content_type.py +186 -0
- httplint-2026.1.8/httplint/field/__init__.py +145 -0
- httplint-2026.1.8/httplint/field/broken_field.py +49 -0
- httplint-2026.1.8/httplint/field/cors.py +99 -0
- httplint-2026.1.8/httplint/field/deprecated.py +100 -0
- httplint-2026.1.8/httplint/field/description.py +18 -0
- httplint-2026.1.8/httplint/field/finder.py +120 -0
- httplint-2026.1.8/httplint/field/json_field.py +48 -0
- httplint-2026.1.8/httplint/field/notes.py +172 -0
- httplint-2026.1.8/httplint/field/parsers/__init__.py +8 -0
- httplint-2026.1.8/httplint/field/parsers/accept.py +25 -0
- httplint-2026.1.8/httplint/field/parsers/accept_ch.py +133 -0
- httplint-2026.1.8/httplint/field/parsers/accept_encoding.py +43 -0
- httplint-2026.1.8/httplint/field/parsers/accept_language.py +25 -0
- httplint-2026.1.8/httplint/field/parsers/accept_ranges.py +65 -0
- httplint-2026.1.8/httplint/field/parsers/access_control.py +22 -0
- httplint-2026.1.8/httplint/field/parsers/access_control_allow_credentials.py +44 -0
- httplint-2026.1.8/httplint/field/parsers/access_control_allow_headers.py +54 -0
- httplint-2026.1.8/httplint/field/parsers/access_control_allow_methods.py +54 -0
- httplint-2026.1.8/httplint/field/parsers/access_control_allow_origin.py +57 -0
- httplint-2026.1.8/httplint/field/parsers/access_control_expose_headers.py +22 -0
- httplint-2026.1.8/httplint/field/parsers/access_control_max_age.py +55 -0
- httplint-2026.1.8/httplint/field/parsers/access_control_request_headers.py +95 -0
- httplint-2026.1.8/httplint/field/parsers/access_control_request_method.py +62 -0
- httplint-2026.1.8/httplint/field/parsers/age.py +93 -0
- httplint-2026.1.8/httplint/field/parsers/allow.py +20 -0
- httplint-2026.1.8/httplint/field/parsers/alt_svc.py +82 -0
- httplint-2026.1.8/httplint/field/parsers/authentication_info.py +37 -0
- httplint-2026.1.8/httplint/field/parsers/authorization.py +25 -0
- httplint-2026.1.8/httplint/field/parsers/available_dictionary.py +108 -0
- httplint-2026.1.8/httplint/field/parsers/cache_control.py +383 -0
- httplint-2026.1.8/httplint/field/parsers/cache_group_invalidation.py +120 -0
- httplint-2026.1.8/httplint/field/parsers/cache_groups.py +60 -0
- httplint-2026.1.8/httplint/field/parsers/cache_status.py +157 -0
- httplint-2026.1.8/httplint/field/parsers/cdn_cache_control.py +113 -0
- httplint-2026.1.8/httplint/field/parsers/clear_site_data.py +56 -0
- httplint-2026.1.8/httplint/field/parsers/connection.py +26 -0
- httplint-2026.1.8/httplint/field/parsers/connectiox.py +19 -0
- httplint-2026.1.8/httplint/field/parsers/content_base.py +15 -0
- httplint-2026.1.8/httplint/field/parsers/content_disposition.py +158 -0
- httplint-2026.1.8/httplint/field/parsers/content_encoding.py +123 -0
- httplint-2026.1.8/httplint/field/parsers/content_language.py +59 -0
- httplint-2026.1.8/httplint/field/parsers/content_length.py +129 -0
- httplint-2026.1.8/httplint/field/parsers/content_location.py +22 -0
- httplint-2026.1.8/httplint/field/parsers/content_md5.py +25 -0
- httplint-2026.1.8/httplint/field/parsers/content_range.py +157 -0
- httplint-2026.1.8/httplint/field/parsers/content_security_policy.py +249 -0
- httplint-2026.1.8/httplint/field/parsers/content_security_policy_report_only.py +28 -0
- httplint-2026.1.8/httplint/field/parsers/content_transfer_encoding.py +14 -0
- httplint-2026.1.8/httplint/field/parsers/content_type.py +37 -0
- httplint-2026.1.8/httplint/field/parsers/cross_origin_embedder_policy.py +142 -0
- httplint-2026.1.8/httplint/field/parsers/cross_origin_embedder_policy_report_only.py +51 -0
- httplint-2026.1.8/httplint/field/parsers/cross_origin_opener_policy.py +141 -0
- httplint-2026.1.8/httplint/field/parsers/cross_origin_opener_policy_report_only.py +51 -0
- httplint-2026.1.8/httplint/field/parsers/cross_origin_resource_policy.py +107 -0
- httplint-2026.1.8/httplint/field/parsers/cteonnt_length.py +19 -0
- httplint-2026.1.8/httplint/field/parsers/date.py +108 -0
- httplint-2026.1.8/httplint/field/parsers/etag.py +43 -0
- httplint-2026.1.8/httplint/field/parsers/expect.py +75 -0
- httplint-2026.1.8/httplint/field/parsers/expires.py +47 -0
- httplint-2026.1.8/httplint/field/parsers/from_field.py +25 -0
- httplint-2026.1.8/httplint/field/parsers/host.py +26 -0
- httplint-2026.1.8/httplint/field/parsers/if_match.py +25 -0
- httplint-2026.1.8/httplint/field/parsers/if_modified_since.py +26 -0
- httplint-2026.1.8/httplint/field/parsers/if_none_match.py +26 -0
- httplint-2026.1.8/httplint/field/parsers/if_range.py +26 -0
- httplint-2026.1.8/httplint/field/parsers/if_unmodified_since.py +26 -0
- httplint-2026.1.8/httplint/field/parsers/keep_alive.py +50 -0
- httplint-2026.1.8/httplint/field/parsers/last_modified.py +78 -0
- httplint-2026.1.8/httplint/field/parsers/link.py +113 -0
- httplint-2026.1.8/httplint/field/parsers/location.py +80 -0
- httplint-2026.1.8/httplint/field/parsers/max_forwards.py +70 -0
- httplint-2026.1.8/httplint/field/parsers/mime_version.py +18 -0
- httplint-2026.1.8/httplint/field/parsers/nel.py +150 -0
- httplint-2026.1.8/httplint/field/parsers/p3p.py +15 -0
- httplint-2026.1.8/httplint/field/parsers/permissions_policy.py +160 -0
- httplint-2026.1.8/httplint/field/parsers/pragma.py +42 -0
- httplint-2026.1.8/httplint/field/parsers/proxy_authenticate.py +14 -0
- httplint-2026.1.8/httplint/field/parsers/proxy_authentication_info.py +37 -0
- httplint-2026.1.8/httplint/field/parsers/proxy_authorization.py +25 -0
- httplint-2026.1.8/httplint/field/parsers/proxy_status.py +197 -0
- httplint-2026.1.8/httplint/field/parsers/range.py +25 -0
- httplint-2026.1.8/httplint/field/parsers/referer.py +80 -0
- httplint-2026.1.8/httplint/field/parsers/referrer_policy.py +109 -0
- httplint-2026.1.8/httplint/field/parsers/report_to.py +113 -0
- httplint-2026.1.8/httplint/field/parsers/retry_after.py +16 -0
- httplint-2026.1.8/httplint/field/parsers/server.py +54 -0
- httplint-2026.1.8/httplint/field/parsers/server_timing.py +118 -0
- httplint-2026.1.8/httplint/field/parsers/set_cookie.py +722 -0
- httplint-2026.1.8/httplint/field/parsers/set_cookie2.py +14 -0
- httplint-2026.1.8/httplint/field/parsers/soapaction.py +13 -0
- httplint-2026.1.8/httplint/field/parsers/strict_transport_security.py +388 -0
- httplint-2026.1.8/httplint/field/parsers/tcn.py +24 -0
- httplint-2026.1.8/httplint/field/parsers/te.py +41 -0
- httplint-2026.1.8/httplint/field/parsers/trailer.py +15 -0
- httplint-2026.1.8/httplint/field/parsers/transfer_encoding.py +163 -0
- httplint-2026.1.8/httplint/field/parsers/upgrade.py +27 -0
- httplint-2026.1.8/httplint/field/parsers/use_as_dictionary.py +100 -0
- httplint-2026.1.8/httplint/field/parsers/user_agent.py +24 -0
- httplint-2026.1.8/httplint/field/parsers/vary.py +113 -0
- httplint-2026.1.8/httplint/field/parsers/via.py +50 -0
- httplint-2026.1.8/httplint/field/parsers/warning.py +24 -0
- httplint-2026.1.8/httplint/field/parsers/www_authenticate.py +22 -0
- httplint-2026.1.8/httplint/field/parsers/x_cache.py +14 -0
- httplint-2026.1.8/httplint/field/parsers/x_cache_lookup.py +14 -0
- httplint-2026.1.8/httplint/field/parsers/x_content_type_options.py +60 -0
- httplint-2026.1.8/httplint/field/parsers/x_frame_options.py +123 -0
- httplint-2026.1.8/httplint/field/parsers/x_pad.py +21 -0
- httplint-2026.1.8/httplint/field/section.py +134 -0
- httplint-2026.1.8/httplint/field/singleton_field.py +56 -0
- httplint-2026.1.8/httplint/field/structured_field.py +88 -0
- httplint-2026.1.8/httplint/field/tests.py +115 -0
- httplint-2026.1.8/httplint/field/unnecessary.py +56 -0
- httplint-2026.1.8/httplint/field/utils.py +227 -0
- httplint-2026.1.8/httplint/i18n.py +65 -0
- httplint-2026.1.8/httplint/message.py +334 -0
- httplint-2026.1.8/httplint/note.py +112 -0
- httplint-2026.1.8/httplint/py.typed +1 -0
- httplint-2026.1.8/httplint/status.py +721 -0
- httplint-2026.1.8/httplint/syntax/__init__.py +17 -0
- httplint-2026.1.8/httplint/syntax/rfc3986.py +228 -0
- httplint-2026.1.8/httplint/syntax/rfc5234.py +92 -0
- httplint-2026.1.8/httplint/syntax/rfc5322.py +121 -0
- httplint-2026.1.8/httplint/syntax/rfc5646.py +152 -0
- httplint-2026.1.8/httplint/syntax/rfc5987.py +70 -0
- httplint-2026.1.8/httplint/syntax/rfc5988.py +112 -0
- httplint-2026.1.8/httplint/syntax/rfc9110.py +673 -0
- httplint-2026.1.8/httplint/syntax/rfc9111.py +83 -0
- httplint-2026.1.8/httplint/syntax/rfc9112.py +166 -0
- httplint-2026.1.8/httplint/syntax/rfc9651.py +87 -0
- httplint-2026.1.8/httplint/translations/es/LC_MESSAGES/messages.mo +0 -0
- httplint-2026.1.8/httplint/translations/es/LC_MESSAGES/messages.po +5706 -0
- httplint-2026.1.8/httplint/translations/fr/LC_MESSAGES/messages.mo +0 -0
- httplint-2026.1.8/httplint/translations/fr/LC_MESSAGES/messages.po +5722 -0
- httplint-2026.1.8/httplint/translations/ja/LC_MESSAGES/messages.mo +0 -0
- httplint-2026.1.8/httplint/translations/ja/LC_MESSAGES/messages.po +5024 -0
- httplint-2026.1.8/httplint/translations/messages.pot +4078 -0
- httplint-2026.1.8/httplint/translations/zh/LC_MESSAGES/messages.mo +0 -0
- httplint-2026.1.8/httplint/translations/zh/LC_MESSAGES/messages.po +4823 -0
- httplint-2026.1.8/httplint/types.py +25 -0
- httplint-2026.1.8/httplint/util.py +124 -0
- httplint-2026.1.8/httplint.egg-info/PKG-INFO +150 -0
- httplint-2026.1.8/httplint.egg-info/SOURCES.txt +176 -0
- httplint-2026.1.8/httplint.egg-info/dependency_links.txt +1 -0
- httplint-2026.1.8/httplint.egg-info/entry_points.txt +2 -0
- httplint-2026.1.8/httplint.egg-info/requires.txt +22 -0
- httplint-2026.1.8/httplint.egg-info/top_level.txt +4 -0
- httplint-2026.1.8/pyproject.toml +119 -0
- httplint-2026.1.8/setup.cfg +4 -0
- httplint-2026.1.8/test/smoke.py +19 -0
- httplint-2026.1.8/test/test_cache.py +144 -0
- httplint-2026.1.8/test/test_content_encoding.py +35 -0
- httplint-2026.1.8/test/test_description.py +31 -0
- httplint-2026.1.8/test/test_dictionary_transport.py +92 -0
- httplint-2026.1.8/test/test_duplicate_keys.py +22 -0
- httplint-2026.1.8/test/test_fields.py +149 -0
- httplint-2026.1.8/test/test_i18n.py +34 -0
- httplint-2026.1.8/test/test_message.py +101 -0
- httplint-2026.1.8/test/test_notes.py +27 -0
- httplint-2026.1.8/test/test_status.py +118 -0
- httplint-2026.1.8/test/test_syntax.py +35 -0
- httplint-2026.1.8/test/test_unnecessary.py +37 -0
- httplint-2026.1.8/test/utils.py +25 -0
- httplint-2026.1.8/tools/__init__.py +0 -0
- httplint-2026.1.8/tools/i18n/__init__.py +0 -0
- httplint-2026.1.8/tools/i18n/autotranslate.py +118 -0
- httplint-2026.1.8/tools/i18n/check.py +100 -0
- httplint-2026.1.8/tools/i18n/extractors.py +70 -0
- httplint-2026.1.8/tools/i18n/utils.py +29 -0
- httplint-2026.1.8/tools/update_readme.py +53 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
Copyright (c) Mark Nottingham
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
5
|
+
in the Software without restriction, including without limitation the rights
|
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
8
|
+
furnished to do so, subject to the following conditions:
|
|
9
|
+
|
|
10
|
+
The above copyright notice and this permission notice shall be included in
|
|
11
|
+
all copies or substantial portions of the Software.
|
|
12
|
+
|
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
19
|
+
THE SOFTWARE.
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: httplint
|
|
3
|
+
Version: 2026.1.8
|
|
4
|
+
Summary: Lint for HTTP messages.
|
|
5
|
+
Author-email: Mark Nottingham <mnot@mnot.net>
|
|
6
|
+
License: Copyright (c) Mark Nottingham
|
|
7
|
+
|
|
8
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
9
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
10
|
+
in the Software without restriction, including without limitation the rights
|
|
11
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
12
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
13
|
+
furnished to do so, subject to the following conditions:
|
|
14
|
+
|
|
15
|
+
The above copyright notice and this permission notice shall be included in
|
|
16
|
+
all copies or substantial portions of the Software.
|
|
17
|
+
|
|
18
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
19
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
20
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
21
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
22
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
23
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
24
|
+
THE SOFTWARE.
|
|
25
|
+
|
|
26
|
+
Project-URL: homepage, https://github.com/mnot/httplint/
|
|
27
|
+
Classifier: Operating System :: OS Independent
|
|
28
|
+
Classifier: Development Status :: 4 - Beta
|
|
29
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
30
|
+
Classifier: Intended Audience :: Developers
|
|
31
|
+
Classifier: Intended Audience :: System Administrators
|
|
32
|
+
Classifier: Topic :: Internet :: WWW/HTTP
|
|
33
|
+
Classifier: Topic :: Software Development :: Testing
|
|
34
|
+
Requires-Python: >=3.10
|
|
35
|
+
Description-Content-Type: text/markdown
|
|
36
|
+
License-File: LICENSE.md
|
|
37
|
+
Requires-Dist: Markdown
|
|
38
|
+
Requires-Dist: MarkupSafe
|
|
39
|
+
Requires-Dist: thor
|
|
40
|
+
Requires-Dist: typing_extensions
|
|
41
|
+
Requires-Dist: http-sf>=1.0.7
|
|
42
|
+
Requires-Dist: sniffpy==1.0.0
|
|
43
|
+
Requires-Dist: Babel
|
|
44
|
+
Requires-Dist: Brotli
|
|
45
|
+
Provides-Extra: dev
|
|
46
|
+
Requires-Dist: mypy; extra == "dev"
|
|
47
|
+
Requires-Dist: black; extra == "dev"
|
|
48
|
+
Requires-Dist: pylint; extra == "dev"
|
|
49
|
+
Requires-Dist: pytest; extra == "dev"
|
|
50
|
+
Requires-Dist: pytest-md; extra == "dev"
|
|
51
|
+
Requires-Dist: validate-pyproject; extra == "dev"
|
|
52
|
+
Requires-Dist: build; extra == "dev"
|
|
53
|
+
Requires-Dist: twine; extra == "dev"
|
|
54
|
+
Requires-Dist: types-Markdown; extra == "dev"
|
|
55
|
+
Requires-Dist: llm; extra == "dev"
|
|
56
|
+
Requires-Dist: llm-mlx; extra == "dev"
|
|
57
|
+
Requires-Dist: brotli-stubs; extra == "dev"
|
|
58
|
+
Dynamic: license-file
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
# httplint
|
|
62
|
+
|
|
63
|
+
This Python library _lints_ HTTP messages; it checks them for correctness and reports any issues it finds. httplint can report on 237 different aspects of your HTTP message, including checks against 164 header fields.
|
|
64
|
+
|
|
65
|
+
It performs all message-level checks for [REDbot](https://redbot.org/), but does not perform any 'active' checks by making requests to the network, and it does not have a Web user interface.
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
## Using httplint as a Library
|
|
69
|
+
|
|
70
|
+
httplint exposes two classes for linting: `HttpRequestLinter` and `HttpResponseLinter`. They expose the following methods for telling the linter about the HTTP message:
|
|
71
|
+
|
|
72
|
+
* As appropriate:
|
|
73
|
+
* `process_request_topline`, which takes three `bytes` arguments: `method`, `uri`, and `version`
|
|
74
|
+
* `process_response_topline`, which takes three `bytes` arguments: `version`, `status_code`, and `status_phrase`
|
|
75
|
+
* `process_headers` for the headers, taking a list of (`name`, `value`) tuples (both `bytes`)
|
|
76
|
+
* `feed_content` for the body (which can be called zero to many times), taking an `inbytes` argument
|
|
77
|
+
* `finish_content` when done, which has two arguments; a `bool` indicating whether the response was complete, and an optional list of tuples for the trailers, in the same format that `process_headers` takes.
|
|
78
|
+
|
|
79
|
+
For example:
|
|
80
|
+
|
|
81
|
+
~~~ python
|
|
82
|
+
from httplint import HttpResponseLinter
|
|
83
|
+
|
|
84
|
+
linter = HttpResponseLinter()
|
|
85
|
+
linter.process_response_topline(b'HTTP/1.1', b'200', b'OK')
|
|
86
|
+
linter.process_headers([
|
|
87
|
+
(b'Content-Type', b'text/plain'),
|
|
88
|
+
(b'Content-Length', b'10'),
|
|
89
|
+
(b'Cache-Control', b'max-age=60')
|
|
90
|
+
])
|
|
91
|
+
linter.feed_content(b'12345')
|
|
92
|
+
linter.feed_content(b'67890')
|
|
93
|
+
linter.finish_content(True)
|
|
94
|
+
~~~
|
|
95
|
+
|
|
96
|
+
## Using httplint from the Command Line
|
|
97
|
+
|
|
98
|
+
httplint can also be used from the command line. For example:
|
|
99
|
+
|
|
100
|
+
~~~
|
|
101
|
+
> curl -s -i --raw https://www.mnot.net/ | httplint -n
|
|
102
|
+
* The Content-Length header is correct.
|
|
103
|
+
* The resource last changed 8 days 6 hr ago.
|
|
104
|
+
* This response allows all caches to store it.
|
|
105
|
+
* The server's clock is correct.
|
|
106
|
+
* This response is fresh until 3 hr from now.
|
|
107
|
+
* This response may still be served by a cache once it becomes stale.
|
|
108
|
+
~~~
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
### Interpreting Notes
|
|
112
|
+
|
|
113
|
+
Once a message has been linted, the results will appear on the `notes` property. This is a list of `Note` objects, each having the following attributes:
|
|
114
|
+
|
|
115
|
+
* `category` - the Note's category; see `note.categories`
|
|
116
|
+
* `level` - see `note.levels`
|
|
117
|
+
* `summary` - a brief, one-line description of the note
|
|
118
|
+
* `detail` - a longer explanation
|
|
119
|
+
* `subnotes` - a list of child `Note` objects
|
|
120
|
+
|
|
121
|
+
Note that `summary` is textual, and needs to be escaped in a markup environment; `detail`, however, is already escaped HTML.
|
|
122
|
+
|
|
123
|
+
Continuing our example:
|
|
124
|
+
|
|
125
|
+
~~~ python
|
|
126
|
+
for note in linter.notes:
|
|
127
|
+
print(note.summary)
|
|
128
|
+
~~~
|
|
129
|
+
|
|
130
|
+
and the output should be:
|
|
131
|
+
|
|
132
|
+
~~~
|
|
133
|
+
The Content-Length header is correct.
|
|
134
|
+
This response allows all caches to store it.
|
|
135
|
+
This response doesn't have a Date header.
|
|
136
|
+
This response is fresh until 1 min from now.
|
|
137
|
+
This response may still be served by a cache once it becomes stale.
|
|
138
|
+
~~~
|
|
139
|
+
|
|
140
|
+
### Field Descriptions
|
|
141
|
+
|
|
142
|
+
The description of any field can be found by calling `get_field_description`. For example:
|
|
143
|
+
|
|
144
|
+
~~~ python
|
|
145
|
+
>>> from httplint import get_field_description
|
|
146
|
+
>>> get_field_description("Allow")
|
|
147
|
+
'The `Allow` response header advertises the set of methods that are supported by the resource.'
|
|
148
|
+
~~~
|
|
149
|
+
|
|
150
|
+
If a description cannot be found it will return `None`.
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
|
|
2
|
+
# httplint
|
|
3
|
+
|
|
4
|
+
This Python library _lints_ HTTP messages; it checks them for correctness and reports any issues it finds. httplint can report on 237 different aspects of your HTTP message, including checks against 164 header fields.
|
|
5
|
+
|
|
6
|
+
It performs all message-level checks for [REDbot](https://redbot.org/), but does not perform any 'active' checks by making requests to the network, and it does not have a Web user interface.
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
## Using httplint as a Library
|
|
10
|
+
|
|
11
|
+
httplint exposes two classes for linting: `HttpRequestLinter` and `HttpResponseLinter`. They expose the following methods for telling the linter about the HTTP message:
|
|
12
|
+
|
|
13
|
+
* As appropriate:
|
|
14
|
+
* `process_request_topline`, which takes three `bytes` arguments: `method`, `uri`, and `version`
|
|
15
|
+
* `process_response_topline`, which takes three `bytes` arguments: `version`, `status_code`, and `status_phrase`
|
|
16
|
+
* `process_headers` for the headers, taking a list of (`name`, `value`) tuples (both `bytes`)
|
|
17
|
+
* `feed_content` for the body (which can be called zero to many times), taking an `inbytes` argument
|
|
18
|
+
* `finish_content` when done, which has two arguments; a `bool` indicating whether the response was complete, and an optional list of tuples for the trailers, in the same format that `process_headers` takes.
|
|
19
|
+
|
|
20
|
+
For example:
|
|
21
|
+
|
|
22
|
+
~~~ python
|
|
23
|
+
from httplint import HttpResponseLinter
|
|
24
|
+
|
|
25
|
+
linter = HttpResponseLinter()
|
|
26
|
+
linter.process_response_topline(b'HTTP/1.1', b'200', b'OK')
|
|
27
|
+
linter.process_headers([
|
|
28
|
+
(b'Content-Type', b'text/plain'),
|
|
29
|
+
(b'Content-Length', b'10'),
|
|
30
|
+
(b'Cache-Control', b'max-age=60')
|
|
31
|
+
])
|
|
32
|
+
linter.feed_content(b'12345')
|
|
33
|
+
linter.feed_content(b'67890')
|
|
34
|
+
linter.finish_content(True)
|
|
35
|
+
~~~
|
|
36
|
+
|
|
37
|
+
## Using httplint from the Command Line
|
|
38
|
+
|
|
39
|
+
httplint can also be used from the command line. For example:
|
|
40
|
+
|
|
41
|
+
~~~
|
|
42
|
+
> curl -s -i --raw https://www.mnot.net/ | httplint -n
|
|
43
|
+
* The Content-Length header is correct.
|
|
44
|
+
* The resource last changed 8 days 6 hr ago.
|
|
45
|
+
* This response allows all caches to store it.
|
|
46
|
+
* The server's clock is correct.
|
|
47
|
+
* This response is fresh until 3 hr from now.
|
|
48
|
+
* This response may still be served by a cache once it becomes stale.
|
|
49
|
+
~~~
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
### Interpreting Notes
|
|
53
|
+
|
|
54
|
+
Once a message has been linted, the results will appear on the `notes` property. This is a list of `Note` objects, each having the following attributes:
|
|
55
|
+
|
|
56
|
+
* `category` - the Note's category; see `note.categories`
|
|
57
|
+
* `level` - see `note.levels`
|
|
58
|
+
* `summary` - a brief, one-line description of the note
|
|
59
|
+
* `detail` - a longer explanation
|
|
60
|
+
* `subnotes` - a list of child `Note` objects
|
|
61
|
+
|
|
62
|
+
Note that `summary` is textual, and needs to be escaped in a markup environment; `detail`, however, is already escaped HTML.
|
|
63
|
+
|
|
64
|
+
Continuing our example:
|
|
65
|
+
|
|
66
|
+
~~~ python
|
|
67
|
+
for note in linter.notes:
|
|
68
|
+
print(note.summary)
|
|
69
|
+
~~~
|
|
70
|
+
|
|
71
|
+
and the output should be:
|
|
72
|
+
|
|
73
|
+
~~~
|
|
74
|
+
The Content-Length header is correct.
|
|
75
|
+
This response allows all caches to store it.
|
|
76
|
+
This response doesn't have a Date header.
|
|
77
|
+
This response is fresh until 1 min from now.
|
|
78
|
+
This response may still be served by a cache once it becomes stale.
|
|
79
|
+
~~~
|
|
80
|
+
|
|
81
|
+
### Field Descriptions
|
|
82
|
+
|
|
83
|
+
The description of any field can be found by calling `get_field_description`. For example:
|
|
84
|
+
|
|
85
|
+
~~~ python
|
|
86
|
+
>>> from httplint import get_field_description
|
|
87
|
+
>>> get_field_description("Allow")
|
|
88
|
+
'The `Allow` response header advertises the set of methods that are supported by the resource.'
|
|
89
|
+
~~~
|
|
90
|
+
|
|
91
|
+
If a description cannot be found it will return `None`.
|