httoop 0.2.0__tar.gz → 0.2.1__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.
- {httoop-0.2.0 → httoop-0.2.1}/PKG-INFO +43 -16
- {httoop-0.2.0 → httoop-0.2.1}/README.md +42 -15
- {httoop-0.2.0 → httoop-0.2.1}/httoop/__init__.py +2 -2
- {httoop-0.2.0 → httoop-0.2.1}/httoop/authentication/__init__.py +6 -2
- {httoop-0.2.0 → httoop-0.2.1}/httoop/authentication/basic.py +5 -6
- {httoop-0.2.0 → httoop-0.2.1}/httoop/authentication/digest.py +53 -29
- httoop-0.2.1/httoop/client/__init__.py +35 -0
- httoop-0.2.1/httoop/codecs/application/gzip.py +69 -0
- {httoop-0.2.0 → httoop-0.2.1}/httoop/codecs/application/xml.py +1 -1
- httoop-0.2.1/httoop/codecs/application/zlib.py +56 -0
- {httoop-0.2.0 → httoop-0.2.1}/httoop/codecs/codec.py +5 -3
- {httoop-0.2.0 → httoop-0.2.1}/httoop/date.py +6 -28
- {httoop-0.2.0 → httoop-0.2.1}/httoop/exceptions.py +8 -0
- {httoop-0.2.0 → httoop-0.2.1}/httoop/gateway/wsgi.py +4 -1
- {httoop-0.2.0 → httoop-0.2.1}/httoop/header/__init__.py +0 -2
- {httoop-0.2.0 → httoop-0.2.1}/httoop/header/element.py +3 -4
- {httoop-0.2.0 → httoop-0.2.1}/httoop/header/headers.py +25 -6
- {httoop-0.2.0 → httoop-0.2.1}/httoop/header/messaging.py +19 -2
- {httoop-0.2.0 → httoop-0.2.1}/httoop/messages/body.py +10 -5
- {httoop-0.2.0 → httoop-0.2.1}/httoop/messages/method.py +3 -3
- {httoop-0.2.0 → httoop-0.2.1}/httoop/messages/protocol.py +7 -4
- {httoop-0.2.0 → httoop-0.2.1}/httoop/parser.py +63 -18
- {httoop-0.2.0 → httoop-0.2.1}/httoop/server/__init__.py +8 -8
- {httoop-0.2.0 → httoop-0.2.1}/httoop/status/client_error.py +1 -1
- {httoop-0.2.0 → httoop-0.2.1}/httoop/status/status.py +2 -2
- {httoop-0.2.0 → httoop-0.2.1}/httoop/uri/uri.py +1 -1
- {httoop-0.2.0 → httoop-0.2.1}/httoop/util.py +65 -7
- {httoop-0.2.0 → httoop-0.2.1}/httoop/version.py +1 -1
- {httoop-0.2.0 → httoop-0.2.1}/httoop.egg-info/PKG-INFO +43 -16
- {httoop-0.2.0 → httoop-0.2.1}/pyproject.toml +89 -1
- httoop-0.2.0/httoop/client/__init__.py +0 -16
- httoop-0.2.0/httoop/codecs/application/gzip.py +0 -65
- httoop-0.2.0/httoop/codecs/application/zlib.py +0 -26
- {httoop-0.2.0 → httoop-0.2.1}/LICENSE +0 -0
- {httoop-0.2.0 → httoop-0.2.1}/httoop/__main__.py +0 -0
- {httoop-0.2.0 → httoop-0.2.1}/httoop/cache/__init__.py +0 -0
- {httoop-0.2.0 → httoop-0.2.1}/httoop/codecs/__init__.py +0 -0
- {httoop-0.2.0 → httoop-0.2.1}/httoop/codecs/application/__init__.py +0 -0
- {httoop-0.2.0 → httoop-0.2.1}/httoop/codecs/application/hal_json.py +0 -0
- {httoop-0.2.0 → httoop-0.2.1}/httoop/codecs/application/json.py +0 -0
- {httoop-0.2.0 → httoop-0.2.1}/httoop/codecs/application/x_www_form_urlencoded.py +0 -0
- {httoop-0.2.0 → httoop-0.2.1}/httoop/codecs/audio/__init__.py +0 -0
- {httoop-0.2.0 → httoop-0.2.1}/httoop/codecs/example/__init__.py +0 -0
- {httoop-0.2.0 → httoop-0.2.1}/httoop/codecs/image/__init__.py +0 -0
- {httoop-0.2.0 → httoop-0.2.1}/httoop/codecs/message/__init__.py +0 -0
- {httoop-0.2.0 → httoop-0.2.1}/httoop/codecs/message/http.py +0 -0
- {httoop-0.2.0 → httoop-0.2.1}/httoop/codecs/model/__init__.py +0 -0
- {httoop-0.2.0 → httoop-0.2.1}/httoop/codecs/multipart/__init__.py +0 -0
- {httoop-0.2.0 → httoop-0.2.1}/httoop/codecs/multipart/multipart.py +0 -0
- {httoop-0.2.0 → httoop-0.2.1}/httoop/codecs/text/__init__.py +0 -0
- {httoop-0.2.0 → httoop-0.2.1}/httoop/codecs/text/html.py +0 -0
- {httoop-0.2.0 → httoop-0.2.1}/httoop/codecs/text/plain.py +0 -0
- {httoop-0.2.0 → httoop-0.2.1}/httoop/codecs/video/__init__.py +0 -0
- {httoop-0.2.0 → httoop-0.2.1}/httoop/gateway/__init__.py +0 -0
- {httoop-0.2.0 → httoop-0.2.1}/httoop/header/auth.py +0 -0
- {httoop-0.2.0 → httoop-0.2.1}/httoop/header/cache.py +0 -0
- {httoop-0.2.0 → httoop-0.2.1}/httoop/header/conditional.py +0 -0
- {httoop-0.2.0 → httoop-0.2.1}/httoop/header/ranges.py +0 -0
- {httoop-0.2.0 → httoop-0.2.1}/httoop/header/security.py +0 -0
- {httoop-0.2.0 → httoop-0.2.1}/httoop/messages/__init__.py +0 -0
- {httoop-0.2.0 → httoop-0.2.1}/httoop/messages/message.py +0 -0
- {httoop-0.2.0 → httoop-0.2.1}/httoop/messages/request.py +0 -0
- {httoop-0.2.0 → httoop-0.2.1}/httoop/messages/response.py +0 -0
- {httoop-0.2.0 → httoop-0.2.1}/httoop/meta.py +0 -0
- {httoop-0.2.0 → httoop-0.2.1}/httoop/proxy/__init__.py +0 -0
- {httoop-0.2.0 → httoop-0.2.1}/httoop/semantic/__init__.py +0 -0
- {httoop-0.2.0 → httoop-0.2.1}/httoop/semantic/message.py +0 -0
- {httoop-0.2.0 → httoop-0.2.1}/httoop/semantic/request.py +0 -0
- {httoop-0.2.0 → httoop-0.2.1}/httoop/semantic/response.py +0 -0
- {httoop-0.2.0 → httoop-0.2.1}/httoop/status/__init__.py +0 -0
- {httoop-0.2.0 → httoop-0.2.1}/httoop/status/informational.py +0 -0
- {httoop-0.2.0 → httoop-0.2.1}/httoop/status/redirect.py +0 -0
- {httoop-0.2.0 → httoop-0.2.1}/httoop/status/server_error.py +0 -0
- {httoop-0.2.0 → httoop-0.2.1}/httoop/status/success.py +0 -0
- {httoop-0.2.0 → httoop-0.2.1}/httoop/status/types.py +0 -0
- {httoop-0.2.0 → httoop-0.2.1}/httoop/uri/__init__.py +0 -0
- {httoop-0.2.0 → httoop-0.2.1}/httoop/uri/http.py +0 -0
- {httoop-0.2.0 → httoop-0.2.1}/httoop/uri/percent_encoding.py +0 -0
- {httoop-0.2.0 → httoop-0.2.1}/httoop/uri/query_string.py +0 -0
- {httoop-0.2.0 → httoop-0.2.1}/httoop/uri/schemes.py +0 -0
- {httoop-0.2.0 → httoop-0.2.1}/httoop.egg-info/SOURCES.txt +0 -0
- {httoop-0.2.0 → httoop-0.2.1}/httoop.egg-info/dependency_links.txt +0 -0
- {httoop-0.2.0 → httoop-0.2.1}/httoop.egg-info/requires.txt +0 -0
- {httoop-0.2.0 → httoop-0.2.1}/httoop.egg-info/top_level.txt +0 -0
- {httoop-0.2.0 → httoop-0.2.1}/httoop.egg-info/zip-safe +0 -0
- {httoop-0.2.0 → httoop-0.2.1}/setup.cfg +0 -0
- {httoop-0.2.0 → httoop-0.2.1}/tests/test_cli.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: httoop
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.1
|
|
4
4
|
Summary: object oriented HTTP protocol library
|
|
5
5
|
Author-email: SpaceOne <space@wechall.net>
|
|
6
6
|
License: MIT
|
|
@@ -65,20 +65,10 @@ On top of the object oriented abstraction of HTTP httoop provides an easy way to
|
|
|
65
65
|
|
|
66
66
|
HTTP and extensions are defined in the following RFC's:
|
|
67
67
|
|
|
68
|
-
*
|
|
69
|
-
|
|
70
|
-
* HTTP/1.1 RFC 7231 [Semantics and Content](https://datatracker.ietf.org/doc/html/rfc7231)
|
|
71
|
-
|
|
72
|
-
* HTTP/1.1 RFC 7232 [Conditional Requests](https://datatracker.ietf.org/doc/html/rfc7232)
|
|
73
|
-
|
|
74
|
-
* HTTP/1.1 RFC 7233 [Range Requests](https://datatracker.ietf.org/doc/html/rfc7233)
|
|
68
|
+
* [RFC 9110 HTTP Semantics](https://datatracker.ietf.org/doc/html/rfc9110)
|
|
75
69
|
|
|
76
70
|
* HTTP/1.1 RFC 7234 [Caching](https://datatracker.ietf.org/doc/html/rfc7234)
|
|
77
71
|
|
|
78
|
-
* HTTP/1.1 RFC 7235 [Authentication](https://datatracker.ietf.org/doc/html/rfc7235)
|
|
79
|
-
|
|
80
|
-
* <s>Hypertext Transfer Protocol -- HTTP/1.1 ([RFC 2616](https://datatracker.ietf.org/doc/html/rfc2616)) </s>
|
|
81
|
-
|
|
82
72
|
* HTTP/2 RFC 7540 [Hypertext Transfer Protocol Version 2](https://datatracker.ietf.org/doc/html/rfc7540)
|
|
83
73
|
|
|
84
74
|
* HTTP/2 RFC 7541 [HPACK: Header Compression for HTTP/2](https://datatracker.ietf.org/doc/html/rfc7541)
|
|
@@ -101,10 +91,6 @@ HTTP and extensions are defined in the following RFC's:
|
|
|
101
91
|
|
|
102
92
|
* Internet Message Format ([RFC 822](https://datatracker.ietf.org/doc/html/rfc822), [2822](https://datatracker.ietf.org/doc/html/rfc2822), [5322](https://datatracker.ietf.org/doc/html/rfc5322))
|
|
103
93
|
|
|
104
|
-
* <s>HTTP Authentication: Basic and Digest Access Authentication ([RFC 2617](https://datatracker.ietf.org/doc/html/rfc2617))</s>
|
|
105
|
-
|
|
106
|
-
* HTTP Authentication-Info and Proxy-Authentication-Info Response Header Fields ([RFC 7615](https://datatracker.ietf.org/doc/html/rfc7615))
|
|
107
|
-
|
|
108
94
|
* HTTP Digest Access Authentication ([RFC 7616](https://datatracker.ietf.org/doc/html/rfc7616))
|
|
109
95
|
|
|
110
96
|
* The 'Basic' HTTP Authentication Scheme ([RFC 7617](https://datatracker.ietf.org/doc/html/rfc7617))
|
|
@@ -119,6 +105,8 @@ HTTP and extensions are defined in the following RFC's:
|
|
|
119
105
|
|
|
120
106
|
* JavaScript Object Notation (JSON) Patch ([RFC 6902](https://datatracker.ietf.org/doc/html/rfc6902))
|
|
121
107
|
|
|
108
|
+
* The HTTP QUERY Method ([RFC 10008](https://datatracker.ietf.org/doc/html/rfc10008))
|
|
109
|
+
|
|
122
110
|
* Use of the Content-Disposition Header Field in the Hypertext Transfer Protocol (HTTP) ([RFC 6266](https://datatracker.ietf.org/doc/html/rfc6266))
|
|
123
111
|
|
|
124
112
|
* Upgrading to TLS Within HTTP/1.1 ([RFC 2817](https://datatracker.ietf.org/doc/html/rfc2817))
|
|
@@ -155,6 +143,34 @@ Extended information about hypermedia, WWW and how HTTP is meant to be used:
|
|
|
155
143
|
|
|
156
144
|
* [Economies of scale](https://roy.gbiv.com/untangled/2008/economies-of-scale)
|
|
157
145
|
|
|
146
|
+
* Clarifications of misconceptions people have about REST:
|
|
147
|
+
|
|
148
|
+
* [Do You Really Understand the REST?](https://t-code.pl/blog/2016/02/rest-misconceptions-0/)
|
|
149
|
+
|
|
150
|
+
* [the URI Confusion](https://t-code.pl/blog/2016/02/rest-misconceptions-1/)
|
|
151
|
+
|
|
152
|
+
* [(Not) Linking Data (Enough)](https://t-code.pl/blog/2016/02/rest-misconceptions-2/)
|
|
153
|
+
|
|
154
|
+
* [More Than Links](https://t-code.pl/blog/2016/03/rest-misconceptions-3/)
|
|
155
|
+
|
|
156
|
+
* [Resources Are Application State](https://t-code.pl/blog/2016/03/rest-misconceptions-4/)
|
|
157
|
+
|
|
158
|
+
* [REST "Documentation"](https://t-code.pl/blog/2016/03/rest-misconceptions-5/)
|
|
159
|
+
|
|
160
|
+
* [Versioning and Hypermedia](https://t-code.pl/blog/2016/03/rest-misconceptions-6/)
|
|
161
|
+
|
|
162
|
+
* [HATEOAS as if You Meant It](https://t-code.pl/blog/2015/01/hateoas-as-if-you-meant-it/)
|
|
163
|
+
|
|
164
|
+
* [The Labours of Hypermedia](https://t-code.pl/blog/2016/04/labours-of-hypermedia/)
|
|
165
|
+
|
|
166
|
+
* [Hypermedia must be extensible - Extensible Media Types](https://t-code.pl/blog/2016/04/hypermedia-must-be-extensible/)
|
|
167
|
+
|
|
168
|
+
* [Consuming Hypermedia - Declarative UI](https://t-code.pl/blog/2016/04/hypermedia-driven-ui/)
|
|
169
|
+
|
|
170
|
+
* [Towards Server-side Routing With URI Templates (RFC 6570)](https://t-code.pl/blog/2016/11/towards-server-side-routing-with-uri-templates/)
|
|
171
|
+
|
|
172
|
+
* [Testing APIs Hypermedia-style](https://t-code.pl/blog/2019/06/testing-hypermedia-api/)
|
|
173
|
+
|
|
158
174
|
* [Richardson Maturity Model](https://martinfowler.com/articles/richardsonMaturityModel.html)
|
|
159
175
|
|
|
160
176
|
* [Test Cases for HTTP Content-Disposition header field](http://greenbytes.de/tech/tc2231/)
|
|
@@ -172,3 +188,14 @@ OAuth 2.0:
|
|
|
172
188
|
* [JSON Web Token (JWT)](https://datatracker.ietf.org/doc/html/rfc7519)
|
|
173
189
|
* [JSON Web Token (JWT) Profile for OAuth 2.0 Access Tokens](https://datatracker.ietf.org/doc/html/rfc9068)
|
|
174
190
|
* [Resource Indicators for OAuth 2.0](https://datatracker.ietf.org/doc/html/rfc8707)
|
|
191
|
+
|
|
192
|
+
Obsolete:
|
|
193
|
+
|
|
194
|
+
* <s>HTTP/1.1 RFC 7230 [Message Syntax and Routing](https://datatracker.ietf.org/doc/html/rfc7230)</s>
|
|
195
|
+
* <s>HTTP/1.1 RFC 7231 [Semantics and Content](https://datatracker.ietf.org/doc/html/rfc7231)</s>
|
|
196
|
+
* <s>HTTP/1.1 RFC 7232 [Conditional Requests](https://datatracker.ietf.org/doc/html/rfc7232)</s>
|
|
197
|
+
* <s>HTTP/1.1 RFC 7233 [Range Requests](https://datatracker.ietf.org/doc/html/rfc7233)</s>
|
|
198
|
+
* <s>HTTP/1.1 RFC 7235 [Authentication](https://datatracker.ietf.org/doc/html/rfc7235)</s>
|
|
199
|
+
* <s>Hypertext Transfer Protocol -- HTTP/1.1 ([RFC 2616](https://datatracker.ietf.org/doc/html/rfc2616)) </s>
|
|
200
|
+
* <s>HTTP Authentication: Basic and Digest Access Authentication ([RFC 2617](https://datatracker.ietf.org/doc/html/rfc2617))</s>
|
|
201
|
+
* <s>HTTP Authentication-Info and Proxy-Authentication-Info Response Header Fields ([RFC 7615](https://datatracker.ietf.org/doc/html/rfc7615))</s>
|
|
@@ -22,20 +22,10 @@ On top of the object oriented abstraction of HTTP httoop provides an easy way to
|
|
|
22
22
|
|
|
23
23
|
HTTP and extensions are defined in the following RFC's:
|
|
24
24
|
|
|
25
|
-
*
|
|
26
|
-
|
|
27
|
-
* HTTP/1.1 RFC 7231 [Semantics and Content](https://datatracker.ietf.org/doc/html/rfc7231)
|
|
28
|
-
|
|
29
|
-
* HTTP/1.1 RFC 7232 [Conditional Requests](https://datatracker.ietf.org/doc/html/rfc7232)
|
|
30
|
-
|
|
31
|
-
* HTTP/1.1 RFC 7233 [Range Requests](https://datatracker.ietf.org/doc/html/rfc7233)
|
|
25
|
+
* [RFC 9110 HTTP Semantics](https://datatracker.ietf.org/doc/html/rfc9110)
|
|
32
26
|
|
|
33
27
|
* HTTP/1.1 RFC 7234 [Caching](https://datatracker.ietf.org/doc/html/rfc7234)
|
|
34
28
|
|
|
35
|
-
* HTTP/1.1 RFC 7235 [Authentication](https://datatracker.ietf.org/doc/html/rfc7235)
|
|
36
|
-
|
|
37
|
-
* <s>Hypertext Transfer Protocol -- HTTP/1.1 ([RFC 2616](https://datatracker.ietf.org/doc/html/rfc2616)) </s>
|
|
38
|
-
|
|
39
29
|
* HTTP/2 RFC 7540 [Hypertext Transfer Protocol Version 2](https://datatracker.ietf.org/doc/html/rfc7540)
|
|
40
30
|
|
|
41
31
|
* HTTP/2 RFC 7541 [HPACK: Header Compression for HTTP/2](https://datatracker.ietf.org/doc/html/rfc7541)
|
|
@@ -58,10 +48,6 @@ HTTP and extensions are defined in the following RFC's:
|
|
|
58
48
|
|
|
59
49
|
* Internet Message Format ([RFC 822](https://datatracker.ietf.org/doc/html/rfc822), [2822](https://datatracker.ietf.org/doc/html/rfc2822), [5322](https://datatracker.ietf.org/doc/html/rfc5322))
|
|
60
50
|
|
|
61
|
-
* <s>HTTP Authentication: Basic and Digest Access Authentication ([RFC 2617](https://datatracker.ietf.org/doc/html/rfc2617))</s>
|
|
62
|
-
|
|
63
|
-
* HTTP Authentication-Info and Proxy-Authentication-Info Response Header Fields ([RFC 7615](https://datatracker.ietf.org/doc/html/rfc7615))
|
|
64
|
-
|
|
65
51
|
* HTTP Digest Access Authentication ([RFC 7616](https://datatracker.ietf.org/doc/html/rfc7616))
|
|
66
52
|
|
|
67
53
|
* The 'Basic' HTTP Authentication Scheme ([RFC 7617](https://datatracker.ietf.org/doc/html/rfc7617))
|
|
@@ -76,6 +62,8 @@ HTTP and extensions are defined in the following RFC's:
|
|
|
76
62
|
|
|
77
63
|
* JavaScript Object Notation (JSON) Patch ([RFC 6902](https://datatracker.ietf.org/doc/html/rfc6902))
|
|
78
64
|
|
|
65
|
+
* The HTTP QUERY Method ([RFC 10008](https://datatracker.ietf.org/doc/html/rfc10008))
|
|
66
|
+
|
|
79
67
|
* Use of the Content-Disposition Header Field in the Hypertext Transfer Protocol (HTTP) ([RFC 6266](https://datatracker.ietf.org/doc/html/rfc6266))
|
|
80
68
|
|
|
81
69
|
* Upgrading to TLS Within HTTP/1.1 ([RFC 2817](https://datatracker.ietf.org/doc/html/rfc2817))
|
|
@@ -112,6 +100,34 @@ Extended information about hypermedia, WWW and how HTTP is meant to be used:
|
|
|
112
100
|
|
|
113
101
|
* [Economies of scale](https://roy.gbiv.com/untangled/2008/economies-of-scale)
|
|
114
102
|
|
|
103
|
+
* Clarifications of misconceptions people have about REST:
|
|
104
|
+
|
|
105
|
+
* [Do You Really Understand the REST?](https://t-code.pl/blog/2016/02/rest-misconceptions-0/)
|
|
106
|
+
|
|
107
|
+
* [the URI Confusion](https://t-code.pl/blog/2016/02/rest-misconceptions-1/)
|
|
108
|
+
|
|
109
|
+
* [(Not) Linking Data (Enough)](https://t-code.pl/blog/2016/02/rest-misconceptions-2/)
|
|
110
|
+
|
|
111
|
+
* [More Than Links](https://t-code.pl/blog/2016/03/rest-misconceptions-3/)
|
|
112
|
+
|
|
113
|
+
* [Resources Are Application State](https://t-code.pl/blog/2016/03/rest-misconceptions-4/)
|
|
114
|
+
|
|
115
|
+
* [REST "Documentation"](https://t-code.pl/blog/2016/03/rest-misconceptions-5/)
|
|
116
|
+
|
|
117
|
+
* [Versioning and Hypermedia](https://t-code.pl/blog/2016/03/rest-misconceptions-6/)
|
|
118
|
+
|
|
119
|
+
* [HATEOAS as if You Meant It](https://t-code.pl/blog/2015/01/hateoas-as-if-you-meant-it/)
|
|
120
|
+
|
|
121
|
+
* [The Labours of Hypermedia](https://t-code.pl/blog/2016/04/labours-of-hypermedia/)
|
|
122
|
+
|
|
123
|
+
* [Hypermedia must be extensible - Extensible Media Types](https://t-code.pl/blog/2016/04/hypermedia-must-be-extensible/)
|
|
124
|
+
|
|
125
|
+
* [Consuming Hypermedia - Declarative UI](https://t-code.pl/blog/2016/04/hypermedia-driven-ui/)
|
|
126
|
+
|
|
127
|
+
* [Towards Server-side Routing With URI Templates (RFC 6570)](https://t-code.pl/blog/2016/11/towards-server-side-routing-with-uri-templates/)
|
|
128
|
+
|
|
129
|
+
* [Testing APIs Hypermedia-style](https://t-code.pl/blog/2019/06/testing-hypermedia-api/)
|
|
130
|
+
|
|
115
131
|
* [Richardson Maturity Model](https://martinfowler.com/articles/richardsonMaturityModel.html)
|
|
116
132
|
|
|
117
133
|
* [Test Cases for HTTP Content-Disposition header field](http://greenbytes.de/tech/tc2231/)
|
|
@@ -129,3 +145,14 @@ OAuth 2.0:
|
|
|
129
145
|
* [JSON Web Token (JWT)](https://datatracker.ietf.org/doc/html/rfc7519)
|
|
130
146
|
* [JSON Web Token (JWT) Profile for OAuth 2.0 Access Tokens](https://datatracker.ietf.org/doc/html/rfc9068)
|
|
131
147
|
* [Resource Indicators for OAuth 2.0](https://datatracker.ietf.org/doc/html/rfc8707)
|
|
148
|
+
|
|
149
|
+
Obsolete:
|
|
150
|
+
|
|
151
|
+
* <s>HTTP/1.1 RFC 7230 [Message Syntax and Routing](https://datatracker.ietf.org/doc/html/rfc7230)</s>
|
|
152
|
+
* <s>HTTP/1.1 RFC 7231 [Semantics and Content](https://datatracker.ietf.org/doc/html/rfc7231)</s>
|
|
153
|
+
* <s>HTTP/1.1 RFC 7232 [Conditional Requests](https://datatracker.ietf.org/doc/html/rfc7232)</s>
|
|
154
|
+
* <s>HTTP/1.1 RFC 7233 [Range Requests](https://datatracker.ietf.org/doc/html/rfc7233)</s>
|
|
155
|
+
* <s>HTTP/1.1 RFC 7235 [Authentication](https://datatracker.ietf.org/doc/html/rfc7235)</s>
|
|
156
|
+
* <s>Hypertext Transfer Protocol -- HTTP/1.1 ([RFC 2616](https://datatracker.ietf.org/doc/html/rfc2616)) </s>
|
|
157
|
+
* <s>HTTP Authentication: Basic and Digest Access Authentication ([RFC 2617](https://datatracker.ietf.org/doc/html/rfc2617))</s>
|
|
158
|
+
* <s>HTTP Authentication-Info and Proxy-Authentication-Info Response Header Fields ([RFC 7615](https://datatracker.ietf.org/doc/html/rfc7615))</s>
|
|
@@ -18,6 +18,7 @@ from httoop.status import (
|
|
|
18
18
|
BAD_GATEWAY,
|
|
19
19
|
BAD_REQUEST,
|
|
20
20
|
CONFLICT,
|
|
21
|
+
CONTENT_TOO_LARGE,
|
|
21
22
|
CONTINUE,
|
|
22
23
|
CREATED,
|
|
23
24
|
EXPECTATION_FAILED,
|
|
@@ -40,7 +41,6 @@ from httoop.status import (
|
|
|
40
41
|
NOT_MODIFIED,
|
|
41
42
|
OK,
|
|
42
43
|
PARTIAL_CONTENT,
|
|
43
|
-
PAYLOAD_TOO_LARGE,
|
|
44
44
|
PAYMENT_REQUIRED,
|
|
45
45
|
PRECONDITION_FAILED,
|
|
46
46
|
PROXY_AUTHENTICATION_REQUIRED,
|
|
@@ -67,7 +67,7 @@ __all__ = [
|
|
|
67
67
|
'ACCEPTED', 'BAD_GATEWAY', 'BAD_REQUEST', 'CONFLICT', 'CONTINUE', 'CREATED', 'EXPECTATION_FAILED', 'FORBIDDEN', 'FOUND', 'GATEWAY_TIMEOUT',
|
|
68
68
|
'GONE', 'HTTP_VERSION_NOT_SUPPORTED', 'INTERNAL_SERVER_ERROR', 'I_AM_A_TEAPOT', 'LENGTH_REQUIRED', 'METHOD_NOT_ALLOWED', 'MOVED_PERMANENTLY',
|
|
69
69
|
'MULTIPLE_CHOICES', 'NON_AUTHORITATIVE_INFORMATION', 'NOT_ACCEPTABLE', 'NOT_FOUND', 'NOT_IMPLEMENTED', 'NOT_MODIFIED', 'NO_CONTENT', 'OK',
|
|
70
|
-
'PARTIAL_CONTENT', '
|
|
70
|
+
'PARTIAL_CONTENT', 'CONTENT_TOO_LARGE', 'PAYMENT_REQUIRED', 'PRECONDITION_FAILED', 'PROXY_AUTHENTICATION_REQUIRED', 'RANGE_NOT_SATISFIABLE',
|
|
71
71
|
'REQUEST_TIMEOUT', 'RESET_CONTENT', 'SEE_OTHER', 'SERVICE_UNAVAILABLE', 'SWITCHING_PROTOCOLS', 'TEMPORARY_REDIRECT', 'UNAUTHORIZED',
|
|
72
72
|
'UNPROCESSABLE_ENTITY', 'UNSUPPORTED_MEDIA_TYPE', 'URI', 'URI_TOO_LONG', 'USE_PROXY',
|
|
73
73
|
'Body', 'ClientStateMachine', 'ComposedRequest', 'ComposedResponse', 'Date', 'DecodeError', 'EncodeError', 'Headers',
|
|
@@ -4,7 +4,7 @@ import re
|
|
|
4
4
|
from typing import TYPE_CHECKING, Any
|
|
5
5
|
|
|
6
6
|
from httoop.authentication.basic import BasicAuthRequestScheme, BasicAuthResponseScheme
|
|
7
|
-
from httoop.authentication.digest import DigestAuthRequestScheme, DigestAuthResponseScheme
|
|
7
|
+
from httoop.authentication.digest import DigestAuthRequestScheme, DigestAuthResponseScheme, SecureDigestAuthRequestScheme
|
|
8
8
|
from httoop.exceptions import InvalidHeader
|
|
9
9
|
from httoop.header.element import HeaderElement
|
|
10
10
|
from httoop.util import _
|
|
@@ -70,9 +70,13 @@ class AuthRequestElement(AuthElement):
|
|
|
70
70
|
|
|
71
71
|
schemes = {
|
|
72
72
|
'basic': BasicAuthRequestScheme,
|
|
73
|
-
'digest':
|
|
73
|
+
'digest': SecureDigestAuthRequestScheme,
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
+
@classmethod
|
|
77
|
+
def allow_insecure_digest_algorithms(cls, *, allow=False):
|
|
78
|
+
cls.schemes['digest'] = DigestAuthRequestScheme if allow else SecureDigestAuthRequestScheme
|
|
79
|
+
|
|
76
80
|
@property
|
|
77
81
|
def scheme(self):
|
|
78
82
|
return self.value.lower()
|
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
|
-
import base64
|
|
4
|
-
from binascii import Error as Base64Error
|
|
5
|
-
|
|
6
3
|
from httoop.exceptions import InvalidHeader
|
|
7
4
|
from httoop.header.element import HeaderElement
|
|
8
|
-
from httoop.util import ByteUnicodeDict, _
|
|
5
|
+
from httoop.util import Base64Error, ByteUnicodeDict, _, base64, base64_decode
|
|
9
6
|
|
|
10
7
|
|
|
11
8
|
class BasicAuthRequestScheme:
|
|
@@ -18,7 +15,9 @@ class BasicAuthRequestScheme:
|
|
|
18
15
|
# raise InvalidHeader(_(u'Invalid base64 in basic authentication'))
|
|
19
16
|
|
|
20
17
|
try:
|
|
21
|
-
username, password =
|
|
18
|
+
username, password = base64_decode(authinfo.strip()).split(b':', 1)
|
|
19
|
+
if not username:
|
|
20
|
+
raise ValueError()
|
|
22
21
|
except Base64Error:
|
|
23
22
|
raise InvalidHeader(_('Basic authentication contains invalid base64'))
|
|
24
23
|
except ValueError:
|
|
@@ -37,7 +36,7 @@ class BasicAuthRequestScheme:
|
|
|
37
36
|
password = authinfo['password']
|
|
38
37
|
# username = username.encode('ISO8859-1')
|
|
39
38
|
# password = password.encode('ISO8859-1')
|
|
40
|
-
return base64
|
|
39
|
+
return base64(b'%s:%s' % (username, password))
|
|
41
40
|
|
|
42
41
|
|
|
43
42
|
class BasicAuthResponseScheme:
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
|
-
from hashlib import md5, sha256
|
|
3
|
+
from hashlib import md5, new, sha256
|
|
4
|
+
from hmac import compare_digest
|
|
5
|
+
from secrets import token_bytes
|
|
4
6
|
from typing import Callable
|
|
5
7
|
|
|
6
8
|
from httoop.exceptions import InvalidHeader
|
|
@@ -9,36 +11,49 @@ from httoop.util import ByteUnicodeDict, _
|
|
|
9
11
|
|
|
10
12
|
|
|
11
13
|
class DigestAuthScheme:
|
|
12
|
-
|
|
13
14
|
algorithms = {
|
|
14
|
-
'MD5': lambda
|
|
15
|
-
'MD5-sess': lambda
|
|
16
|
-
'SHA-256': lambda
|
|
17
|
-
'SHA-256-sess': lambda
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
15
|
+
'MD5': lambda: md5(), # noqa: S324
|
|
16
|
+
'MD5-sess': lambda: md5(), # noqa: S324
|
|
17
|
+
'SHA-256': lambda: sha256(),
|
|
18
|
+
'SHA-256-sess': lambda: sha256(),
|
|
19
|
+
'SHA-512-256': lambda: new('sha512_256'),
|
|
20
|
+
'SHA-512-256-sess': lambda: new('sha512_256'),
|
|
21
|
+
} # not case insensitive per RFC
|
|
22
|
+
|
|
23
|
+
allowed_algorithms = frozenset(algorithms)
|
|
21
24
|
qops = (b'auth', b'auth-int') # quality of protection
|
|
22
25
|
|
|
23
26
|
@classmethod
|
|
24
|
-
def get_algorithm(cls, algorithm: bytes | str) -> Callable:
|
|
27
|
+
def get_algorithm(cls, algorithm: bytes | str) -> Callable[[bytes], bytes]:
|
|
28
|
+
if not isinstance(algorithm, str):
|
|
29
|
+
algorithm = algorithm.decode('ASCII')
|
|
30
|
+
|
|
31
|
+
if algorithm not in cls.allowed_algorithms:
|
|
32
|
+
raise InvalidHeader(_('Digest algorithm not allowed: %r'), algorithm)
|
|
33
|
+
|
|
25
34
|
try:
|
|
26
|
-
|
|
35
|
+
H = cls.algorithms[algorithm]
|
|
27
36
|
except KeyError:
|
|
28
|
-
raise InvalidHeader(_('Unknown digest authentication algorithm: %r'), algorithm)
|
|
37
|
+
raise InvalidHeader(_('Unknown digest authentication algorithm: %r'), algorithm) from None
|
|
38
|
+
|
|
39
|
+
def _algo(value: bytes) -> bytes:
|
|
40
|
+
h = H()
|
|
41
|
+
h.update(value)
|
|
42
|
+
return h.hexdigest().encode('ASCII')
|
|
43
|
+
|
|
44
|
+
return _algo
|
|
29
45
|
|
|
30
46
|
@classmethod
|
|
31
47
|
def generate_nonce(cls, authinfo: ByteUnicodeDict) -> bytes:
|
|
32
|
-
from time import time
|
|
33
|
-
from uuid import uuid4
|
|
34
|
-
|
|
35
|
-
nonce = b'%d:%s:%s' % (
|
|
36
|
-
time(),
|
|
37
|
-
authinfo.get('etag', authinfo.get('realm', b'')),
|
|
38
|
-
str(uuid4()).encode('ASCII'),
|
|
39
|
-
)
|
|
40
48
|
algorithm = authinfo.get('algorithm', b'MD5').decode('ASCII', 'replace')
|
|
41
49
|
H = cls.get_algorithm(algorithm)
|
|
50
|
+
|
|
51
|
+
# nonce = b'%d:%s:%s' % (
|
|
52
|
+
# time(),
|
|
53
|
+
# authinfo.get('etag', authinfo.get('realm', b'')),
|
|
54
|
+
# str(uuid4()).encode('ASCII'),
|
|
55
|
+
# )
|
|
56
|
+
nonce = token_bytes(32)
|
|
42
57
|
return H(nonce)
|
|
43
58
|
|
|
44
59
|
@classmethod
|
|
@@ -94,6 +109,7 @@ class DigestAuthResponseScheme(DigestAuthScheme): # WWW-Authenticate
|
|
|
94
109
|
params = super(cls, cls).parse(authinfo)
|
|
95
110
|
if b'"' in params['nonce']:
|
|
96
111
|
raise InvalidHeader(_('Nonce must not contain double quote'))
|
|
112
|
+
|
|
97
113
|
stale = params.get('stale')
|
|
98
114
|
if stale:
|
|
99
115
|
stale = {b'false': False, b'true': True}.get(stale.lower())
|
|
@@ -168,14 +184,14 @@ class DigestAuthRequestScheme(DigestAuthScheme): # Authorization
|
|
|
168
184
|
if authinfo['realm'] != request_params['realm']:
|
|
169
185
|
return False
|
|
170
186
|
response = cls.calculate_request_digest(authinfo)
|
|
171
|
-
return response == request_params['response']
|
|
187
|
+
return len(response) == len(request_params['response']) and compare_digest(response, request_params['response'])
|
|
172
188
|
|
|
173
189
|
@classmethod
|
|
174
190
|
def calculate_request_digest(cls, authinfo: ByteUnicodeDict) -> bytes:
|
|
175
191
|
algorithm = authinfo.get('algorithm', b'MD5').decode('ASCII', 'replace')
|
|
176
192
|
H = cls.get_algorithm(algorithm)
|
|
177
193
|
|
|
178
|
-
if algorithm
|
|
194
|
+
if algorithm.endswith('-sess') and authinfo.get('A1'): # noqa: SIM108
|
|
179
195
|
secret = H(authinfo['A1'])
|
|
180
196
|
else:
|
|
181
197
|
secret = H(cls.A1(authinfo))
|
|
@@ -197,7 +213,7 @@ class DigestAuthRequestScheme(DigestAuthScheme): # Authorization
|
|
|
197
213
|
if not qop or qop == b'auth':
|
|
198
214
|
return b'%s:%s' % (params['method'], params['uri'])
|
|
199
215
|
if qop == b'auth-int':
|
|
200
|
-
H = cls.get_algorithm(params
|
|
216
|
+
H = cls.get_algorithm(params.get('algorithm', b'MD5'))
|
|
201
217
|
return b'%s:%s:%s' % (params['method'], params['uri'], H(params['entity_body']))
|
|
202
218
|
raise NotImplementedError(f'Unknown quality of protection: {qop!r}') # pragma: no cover
|
|
203
219
|
|
|
@@ -205,10 +221,18 @@ class DigestAuthRequestScheme(DigestAuthScheme): # Authorization
|
|
|
205
221
|
def A1(cls, params: ByteUnicodeDict) -> bytes:
|
|
206
222
|
algorithm = params.get('algorithm', b'')
|
|
207
223
|
|
|
208
|
-
if not algorithm or algorithm
|
|
224
|
+
if not algorithm or not algorithm.endswith(b'-sess'):
|
|
209
225
|
return b'%s:%s:%s' % (params['username'], params['realm'], params['password'])
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
226
|
+
|
|
227
|
+
H = cls.get_algorithm(algorithm)
|
|
228
|
+
s = b'%s:%s:%s' % (params['username'], params['realm'], params['password'])
|
|
229
|
+
return b'%s:%s:%s' % (H(s), params['nonce'], params['cnonce'])
|
|
230
|
+
|
|
231
|
+
|
|
232
|
+
class SecureDigestAuthRequestScheme(DigestAuthRequestScheme):
|
|
233
|
+
allowed_algorithms = frozenset({
|
|
234
|
+
'SHA-256',
|
|
235
|
+
'SHA-256-sess',
|
|
236
|
+
'SHA-512-256',
|
|
237
|
+
'SHA-512-256-sess',
|
|
238
|
+
})
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from httoop.exceptions import InvalidLine
|
|
4
|
+
from httoop.messages import Request, Response
|
|
5
|
+
from httoop.parser import NOT_RECEIVED_YET, StateMachine
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class ClientStateMachine(StateMachine):
|
|
9
|
+
|
|
10
|
+
Message = Response
|
|
11
|
+
request: Request
|
|
12
|
+
message: Response
|
|
13
|
+
|
|
14
|
+
def __init__(self, *, strict: bool = True, max_status_line_length: float = 256, **kwargs) -> None:
|
|
15
|
+
super().__init__(strict=strict, **kwargs)
|
|
16
|
+
self.max_status_line_length = max_status_line_length
|
|
17
|
+
|
|
18
|
+
def parse_startline(self) -> bool | None:
|
|
19
|
+
state = super().parse_startline()
|
|
20
|
+
if state is NOT_RECEIVED_YET:
|
|
21
|
+
self._check_status_line_max_length(self.buffer)
|
|
22
|
+
return state
|
|
23
|
+
|
|
24
|
+
def _check_status_line_max_length(self, response_line: bytearray | bytes) -> None:
|
|
25
|
+
if len(response_line) > self.max_status_line_length:
|
|
26
|
+
raise InvalidLine('The maximum length of the response status line is %d' % self.max_status_line_length)
|
|
27
|
+
|
|
28
|
+
def on_headers_complete(self) -> None:
|
|
29
|
+
super().on_headers_complete()
|
|
30
|
+
self.remove_invalid_headers()
|
|
31
|
+
|
|
32
|
+
def remove_invalid_headers(self) -> None:
|
|
33
|
+
if self.request.method == 'CONNECT':
|
|
34
|
+
self.message.headers.pop('Transfer-Encoding', None)
|
|
35
|
+
self.message.headers.pop('Content-Length', None)
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import gzip
|
|
4
|
+
import io
|
|
5
|
+
import zlib
|
|
6
|
+
|
|
7
|
+
from httoop.codecs.codec import Codec
|
|
8
|
+
from httoop.exceptions import DecodeError, EncodeError, InvalidBodySize
|
|
9
|
+
from httoop.util import _
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class GZip(Codec):
|
|
13
|
+
mimetype = 'application/gzip'
|
|
14
|
+
|
|
15
|
+
compression_level = 6
|
|
16
|
+
|
|
17
|
+
@classmethod
|
|
18
|
+
def encode(cls, data: bytes, charset: None = None, mimetype: None = None) -> bytes:
|
|
19
|
+
try:
|
|
20
|
+
out = io.BytesIO()
|
|
21
|
+
with gzip.GzipFile(fileobj=out, mode='w', compresslevel=cls.compression_level) as fd:
|
|
22
|
+
fd.write(Codec.encode(data, charset))
|
|
23
|
+
return out.getvalue()
|
|
24
|
+
except zlib.error: # pragma: no cover
|
|
25
|
+
raise EncodeError(_('Invalid gzip data.')) from None
|
|
26
|
+
|
|
27
|
+
@classmethod
|
|
28
|
+
def decode(cls, data: bytes, charset: str | None = None, mimetype: None = None, max_size: int = -1) -> str:
|
|
29
|
+
with gzip.GzipFile(fileobj=io.BytesIO(data)) as fd:
|
|
30
|
+
try:
|
|
31
|
+
result = fd.read(max_size + 1 if max_size > 0 else -1)
|
|
32
|
+
if max_size > 0 and len(result) > max_size:
|
|
33
|
+
raise InvalidBodySize(_('Maximum content size (%d) reached'), max_size)
|
|
34
|
+
except (zlib.error, OSError, EOFError):
|
|
35
|
+
raise DecodeError(_('Invalid gzip data.')) from None
|
|
36
|
+
return Codec.decode(result, charset)
|
|
37
|
+
|
|
38
|
+
@classmethod
|
|
39
|
+
def iterencode(cls, data, charset=None, mimetype=None):
|
|
40
|
+
out = io.BytesIO()
|
|
41
|
+
try:
|
|
42
|
+
with gzip.GzipFile(fileobj=out, mode='w', compresslevel=cls.compression_level) as fd:
|
|
43
|
+
for part in data:
|
|
44
|
+
fd.write(Codec.encode(part, charset))
|
|
45
|
+
yield out.getvalue()
|
|
46
|
+
out.seek(0)
|
|
47
|
+
out.truncate()
|
|
48
|
+
except zlib.error: # pragma: no cover
|
|
49
|
+
raise EncodeError(_('Invalid gzip data.')) from None
|
|
50
|
+
yield out.getvalue()
|
|
51
|
+
|
|
52
|
+
# @classmethod
|
|
53
|
+
# def iterdecode(cls, data, charset=None, mimetype=None):
|
|
54
|
+
# try:
|
|
55
|
+
# fd = io.BytesIO()
|
|
56
|
+
# with gzip.GzipFile(fileobj=fd) as gzfd:
|
|
57
|
+
# # FIXME: the gzip module cannot handle partial data
|
|
58
|
+
# # for part in data:
|
|
59
|
+
# # fd.write(part)
|
|
60
|
+
# # fd.seek(fd.tell() - length)
|
|
61
|
+
# # fd.seek(fd.tell() - length)
|
|
62
|
+
# # yield Codec.decode(gzfd.read(), charset)
|
|
63
|
+
# # yield Codec.decode(gzfd.read(), charset)
|
|
64
|
+
# for part in data:
|
|
65
|
+
# fd.write(part)
|
|
66
|
+
# fd.seek(0)
|
|
67
|
+
# yield Codec.decode(gzfd.read(), charset)
|
|
68
|
+
# except (zlib.error, OSError, EOFError):
|
|
69
|
+
# raise DecodeError(_('Invalid gzip data.')) from None
|
|
@@ -15,7 +15,7 @@ try:
|
|
|
15
15
|
from defusedxml.ElementTree import ParseError, fromstring, tostring
|
|
16
16
|
except ImportError: # pragma: no cover
|
|
17
17
|
# TODO: emit a warning
|
|
18
|
-
from xml.etree.ElementTree import ParseError, tostring
|
|
18
|
+
from xml.etree.ElementTree import ParseError, tostring # noqa: S405
|
|
19
19
|
|
|
20
20
|
def fromstring(data) -> NoReturn:
|
|
21
21
|
raise ParseError('Will not parse without defusedxml!')
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import zlib
|
|
4
|
+
|
|
5
|
+
from httoop.codecs.codec import Codec
|
|
6
|
+
from httoop.exceptions import DecodeError, EncodeError, InvalidBodySize
|
|
7
|
+
from httoop.util import _
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class Deflate(Codec):
|
|
11
|
+
mimetype = 'application/zlib'
|
|
12
|
+
|
|
13
|
+
@classmethod
|
|
14
|
+
def encode(cls, data: bytes, charset: None = None, mimetype: None = None) -> bytes:
|
|
15
|
+
try:
|
|
16
|
+
return zlib.compress(Codec.encode(data, charset))
|
|
17
|
+
except zlib.error: # pragma: no cover
|
|
18
|
+
raise EncodeError(_('Invalid zlib/deflate data.')) from None
|
|
19
|
+
|
|
20
|
+
@classmethod
|
|
21
|
+
def decode(cls, data: bytes, charset: str | None = None, mimetype: None = None, max_size: int = -1) -> str:
|
|
22
|
+
try:
|
|
23
|
+
result = _decompress_limited(data, max_size) if max_size > 0 else zlib.decompress(data)
|
|
24
|
+
except zlib.error:
|
|
25
|
+
raise DecodeError(_('Invalid zlib/deflate data.')) from None
|
|
26
|
+
|
|
27
|
+
return Codec.decode(result, charset)
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def _decompress_limited(data: bytes, max_size: int) -> bytes:
|
|
31
|
+
decompressor = zlib.decompressobj()
|
|
32
|
+
chunks = []
|
|
33
|
+
size = 0
|
|
34
|
+
pending = data
|
|
35
|
+
|
|
36
|
+
while True:
|
|
37
|
+
remaining = max_size - size
|
|
38
|
+
|
|
39
|
+
chunk = decompressor.decompress(pending, remaining + 1)
|
|
40
|
+
size += len(chunk)
|
|
41
|
+
|
|
42
|
+
if size > max_size:
|
|
43
|
+
raise InvalidBodySize(_('Maximum content size (%d) reached'), max_size)
|
|
44
|
+
|
|
45
|
+
chunks.append(chunk)
|
|
46
|
+
|
|
47
|
+
if decompressor.eof:
|
|
48
|
+
break
|
|
49
|
+
|
|
50
|
+
pending = decompressor.unconsumed_tail
|
|
51
|
+
|
|
52
|
+
if not pending:
|
|
53
|
+
# if zlib still hasn't reached EOF the compressed representation is truncated
|
|
54
|
+
raise zlib.error()
|
|
55
|
+
|
|
56
|
+
return b''.join(chunks)
|
|
@@ -9,14 +9,16 @@ if TYPE_CHECKING:
|
|
|
9
9
|
|
|
10
10
|
class Codec:
|
|
11
11
|
|
|
12
|
+
mimetype: str
|
|
13
|
+
|
|
12
14
|
@classmethod
|
|
13
|
-
def decode(cls, data: bytes, charset: str | None = None, mimetype: None = None) -> str: # pragma: no cover
|
|
15
|
+
def decode(cls, data: bytes, charset: str | None = None, mimetype: ContentType | None = None, **kwargs) -> str: # pragma: no cover
|
|
14
16
|
if isinstance(data, bytes):
|
|
15
17
|
data = data.decode(charset or 'ascii')
|
|
16
18
|
return data
|
|
17
19
|
|
|
18
20
|
@classmethod
|
|
19
|
-
def encode(cls, data: bytes, charset: None = None, mimetype: None = None) -> bytes: # pragma: no cover
|
|
21
|
+
def encode(cls, data: bytes, charset: None = None, mimetype: ContentType | None = None) -> bytes: # pragma: no cover
|
|
20
22
|
if isinstance(data, str):
|
|
21
23
|
data = data.encode(charset or 'ascii')
|
|
22
24
|
return data
|
|
@@ -26,5 +28,5 @@ class Codec:
|
|
|
26
28
|
yield cls.encode(data, charset, mimetype)
|
|
27
29
|
|
|
28
30
|
@classmethod
|
|
29
|
-
def iterdecode(cls, data: Any, charset=None, mimetype=None): # pragma: no cover
|
|
31
|
+
def iterdecode(cls, data: Any, charset=None, mimetype: ContentType | None = None): # pragma: no cover
|
|
30
32
|
yield cls.decode(data, charset, mimetype)
|