httoop 0.1.1__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.
Files changed (156) hide show
  1. httoop-0.2.1/LICENSE +19 -0
  2. httoop-0.2.1/PKG-INFO +201 -0
  3. {httoop-0.1.1 → httoop-0.2.1}/README.md +44 -17
  4. httoop-0.2.1/httoop/__init__.py +77 -0
  5. httoop-0.2.1/httoop/__main__.py +150 -0
  6. httoop-0.2.1/httoop/authentication/__init__.py +129 -0
  7. httoop-0.2.1/httoop/authentication/basic.py +52 -0
  8. httoop-0.2.1/httoop/authentication/digest.py +238 -0
  9. httoop-0.2.1/httoop/client/__init__.py +35 -0
  10. httoop-0.2.1/httoop/codecs/__init__.py +32 -0
  11. {httoop-0.1.1 → httoop-0.2.1}/httoop/codecs/application/__init__.py +2 -2
  12. httoop-0.2.1/httoop/codecs/application/gzip.py +69 -0
  13. httoop-0.2.1/httoop/codecs/application/hal_json.py +143 -0
  14. httoop-0.2.1/httoop/codecs/application/json.py +25 -0
  15. httoop-0.2.1/httoop/codecs/application/x_www_form_urlencoded.py +43 -0
  16. httoop-0.2.1/httoop/codecs/application/xml.py +40 -0
  17. httoop-0.2.1/httoop/codecs/application/zlib.py +56 -0
  18. httoop-0.2.1/httoop/codecs/audio/__init__.py +0 -0
  19. httoop-0.2.1/httoop/codecs/codec.py +32 -0
  20. httoop-0.2.1/httoop/codecs/example/__init__.py +0 -0
  21. httoop-0.2.1/httoop/codecs/image/__init__.py +0 -0
  22. {httoop-0.1.1 → httoop-0.2.1}/httoop/codecs/message/__init__.py +2 -3
  23. httoop-0.2.1/httoop/codecs/message/http.py +36 -0
  24. httoop-0.2.1/httoop/codecs/model/__init__.py +0 -0
  25. httoop-0.2.1/httoop/codecs/multipart/__init__.py +40 -0
  26. httoop-0.2.1/httoop/codecs/multipart/multipart.py +59 -0
  27. {httoop-0.1.1 → httoop-0.2.1}/httoop/codecs/text/__init__.py +2 -2
  28. {httoop-0.1.1 → httoop-0.2.1}/httoop/codecs/text/html.py +1 -2
  29. httoop-0.2.1/httoop/codecs/text/plain.py +31 -0
  30. httoop-0.2.1/httoop/codecs/video/__init__.py +0 -0
  31. httoop-0.2.1/httoop/date.py +164 -0
  32. httoop-0.2.1/httoop/exceptions.py +43 -0
  33. httoop-0.2.1/httoop/gateway/__init__.py +0 -0
  34. httoop-0.2.1/httoop/gateway/wsgi.py +192 -0
  35. httoop-0.2.1/httoop/header/__init__.py +21 -0
  36. httoop-0.2.1/httoop/header/auth.py +34 -0
  37. httoop-0.2.1/httoop/header/cache.py +32 -0
  38. httoop-0.2.1/httoop/header/conditional.py +86 -0
  39. httoop-0.2.1/httoop/header/element.py +411 -0
  40. httoop-0.2.1/httoop/header/headers.py +187 -0
  41. httoop-0.2.1/httoop/header/messaging.py +487 -0
  42. httoop-0.2.1/httoop/header/ranges.py +144 -0
  43. httoop-0.2.1/httoop/header/security.py +130 -0
  44. {httoop-0.1.1 → httoop-0.2.1}/httoop/messages/__init__.py +4 -3
  45. httoop-0.2.1/httoop/messages/body.py +311 -0
  46. httoop-0.2.1/httoop/messages/message.py +91 -0
  47. httoop-0.2.1/httoop/messages/method.py +53 -0
  48. httoop-0.2.1/httoop/messages/protocol.py +96 -0
  49. httoop-0.2.1/httoop/messages/request.py +102 -0
  50. httoop-0.2.1/httoop/messages/response.py +65 -0
  51. httoop-0.2.1/httoop/meta.py +44 -0
  52. httoop-0.2.1/httoop/parser.py +355 -0
  53. {httoop-0.1.1 → httoop-0.2.1}/httoop/proxy/__init__.py +1 -3
  54. {httoop-0.1.1 → httoop-0.2.1}/httoop/semantic/__init__.py +1 -1
  55. httoop-0.2.1/httoop/semantic/message.py +56 -0
  56. httoop-0.2.1/httoop/semantic/request.py +80 -0
  57. httoop-0.2.1/httoop/semantic/response.py +147 -0
  58. httoop-0.2.1/httoop/server/__init__.py +156 -0
  59. httoop-0.2.1/httoop/status/__init__.py +21 -0
  60. httoop-0.2.1/httoop/status/client_error.py +216 -0
  61. httoop-0.2.1/httoop/status/informational.py +32 -0
  62. httoop-0.2.1/httoop/status/redirect.py +109 -0
  63. httoop-0.2.1/httoop/status/server_error.py +90 -0
  64. httoop-0.2.1/httoop/status/status.py +235 -0
  65. httoop-0.2.1/httoop/status/success.py +114 -0
  66. httoop-0.2.1/httoop/status/types.py +103 -0
  67. httoop-0.2.1/httoop/uri/__init__.py +12 -0
  68. httoop-0.2.1/httoop/uri/http.py +18 -0
  69. httoop-0.2.1/httoop/uri/percent_encoding.py +52 -0
  70. httoop-0.2.1/httoop/uri/query_string.py +20 -0
  71. httoop-0.2.1/httoop/uri/schemes.py +36 -0
  72. httoop-0.2.1/httoop/uri/uri.py +387 -0
  73. httoop-0.2.1/httoop/util.py +268 -0
  74. httoop-0.2.1/httoop/version.py +8 -0
  75. httoop-0.2.1/httoop.egg-info/PKG-INFO +201 -0
  76. {httoop-0.1.1 → httoop-0.2.1}/httoop.egg-info/SOURCES.txt +5 -7
  77. httoop-0.2.1/httoop.egg-info/requires.txt +12 -0
  78. httoop-0.2.1/pyproject.toml +264 -0
  79. httoop-0.2.1/tests/test_cli.py +38 -0
  80. httoop-0.1.1/PKG-INFO +0 -164
  81. httoop-0.1.1/httoop/__init__.py +0 -58
  82. httoop-0.1.1/httoop/__main__.py +0 -150
  83. httoop-0.1.1/httoop/authentication/__init__.py +0 -118
  84. httoop-0.1.1/httoop/authentication/basic.py +0 -53
  85. httoop-0.1.1/httoop/authentication/digest.py +0 -210
  86. httoop-0.1.1/httoop/cache/__init__.py +0 -1
  87. httoop-0.1.1/httoop/client/__init__.py +0 -17
  88. httoop-0.1.1/httoop/codecs/__init__.py +0 -32
  89. httoop-0.1.1/httoop/codecs/application/gzip.py +0 -69
  90. httoop-0.1.1/httoop/codecs/application/hal_json.py +0 -138
  91. httoop-0.1.1/httoop/codecs/application/json.py +0 -21
  92. httoop-0.1.1/httoop/codecs/application/x_www_form_urlencoded.py +0 -38
  93. httoop-0.1.1/httoop/codecs/application/xml.py +0 -33
  94. httoop-0.1.1/httoop/codecs/application/zlib.py +0 -28
  95. httoop-0.1.1/httoop/codecs/audio/__init__.py +0 -1
  96. httoop-0.1.1/httoop/codecs/codec.py +0 -28
  97. httoop-0.1.1/httoop/codecs/example/__init__.py +0 -1
  98. httoop-0.1.1/httoop/codecs/image/__init__.py +0 -1
  99. httoop-0.1.1/httoop/codecs/message/http.py +0 -28
  100. httoop-0.1.1/httoop/codecs/model/__init__.py +0 -1
  101. httoop-0.1.1/httoop/codecs/multipart/__init__.py +0 -40
  102. httoop-0.1.1/httoop/codecs/multipart/multipart.py +0 -51
  103. httoop-0.1.1/httoop/codecs/text/plain.py +0 -24
  104. httoop-0.1.1/httoop/codecs/video/__init__.py +0 -1
  105. httoop-0.1.1/httoop/date.py +0 -179
  106. httoop-0.1.1/httoop/exceptions.py +0 -38
  107. httoop-0.1.1/httoop/gateway/wsgi.py +0 -181
  108. httoop-0.1.1/httoop/header/__init__.py +0 -30
  109. httoop-0.1.1/httoop/header/auth.py +0 -36
  110. httoop-0.1.1/httoop/header/cache.py +0 -35
  111. httoop-0.1.1/httoop/header/conditional.py +0 -68
  112. httoop-0.1.1/httoop/header/element.py +0 -415
  113. httoop-0.1.1/httoop/header/headers.py +0 -166
  114. httoop-0.1.1/httoop/header/messaging.py +0 -475
  115. httoop-0.1.1/httoop/header/range.py +0 -140
  116. httoop-0.1.1/httoop/header/security.py +0 -122
  117. httoop-0.1.1/httoop/header/semantics.py +0 -1
  118. httoop-0.1.1/httoop/messages/body.py +0 -302
  119. httoop-0.1.1/httoop/messages/message.py +0 -87
  120. httoop-0.1.1/httoop/messages/method.py +0 -50
  121. httoop-0.1.1/httoop/messages/protocol.py +0 -90
  122. httoop-0.1.1/httoop/messages/request.py +0 -98
  123. httoop-0.1.1/httoop/messages/response.py +0 -63
  124. httoop-0.1.1/httoop/meta.py +0 -66
  125. httoop-0.1.1/httoop/parser.py +0 -300
  126. httoop-0.1.1/httoop/semantic/message.py +0 -58
  127. httoop-0.1.1/httoop/semantic/request.py +0 -80
  128. httoop-0.1.1/httoop/semantic/response.py +0 -140
  129. httoop-0.1.1/httoop/server/__init__.py +0 -153
  130. httoop-0.1.1/httoop/six.py +0 -5
  131. httoop-0.1.1/httoop/status/__init__.py +0 -24
  132. httoop-0.1.1/httoop/status/client_error.py +0 -245
  133. httoop-0.1.1/httoop/status/informational.py +0 -30
  134. httoop-0.1.1/httoop/status/redirect.py +0 -109
  135. httoop-0.1.1/httoop/status/server_error.py +0 -100
  136. httoop-0.1.1/httoop/status/status.py +0 -195
  137. httoop-0.1.1/httoop/status/success.py +0 -113
  138. httoop-0.1.1/httoop/status/types.py +0 -123
  139. httoop-0.1.1/httoop/test.py +0 -11
  140. httoop-0.1.1/httoop/uri/__init__.py +0 -11
  141. httoop-0.1.1/httoop/uri/http.py +0 -20
  142. httoop-0.1.1/httoop/uri/percent_encoding.py +0 -53
  143. httoop-0.1.1/httoop/uri/query_string.py +0 -20
  144. httoop-0.1.1/httoop/uri/schemes.py +0 -45
  145. httoop-0.1.1/httoop/uri/type.py +0 -13
  146. httoop-0.1.1/httoop/uri/uri.py +0 -376
  147. httoop-0.1.1/httoop/util.py +0 -243
  148. httoop-0.1.1/httoop/version.py +0 -14
  149. httoop-0.1.1/httoop.egg-info/PKG-INFO +0 -164
  150. httoop-0.1.1/httoop.egg-info/requires.txt +0 -1
  151. httoop-0.1.1/setup.py +0 -50
  152. {httoop-0.1.1/httoop/gateway → httoop-0.2.1/httoop/cache}/__init__.py +0 -0
  153. {httoop-0.1.1 → httoop-0.2.1}/httoop.egg-info/dependency_links.txt +0 -0
  154. {httoop-0.1.1 → httoop-0.2.1}/httoop.egg-info/top_level.txt +0 -0
  155. {httoop-0.1.1 → httoop-0.2.1}/httoop.egg-info/zip-safe +0 -0
  156. {httoop-0.1.1 → httoop-0.2.1}/setup.cfg +0 -0
httoop-0.2.1/LICENSE ADDED
@@ -0,0 +1,19 @@
1
+ Copyright (c) 2013-2020 SpaceOne <space@wechall.net>
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
4
+ this software and associated documentation files (the "Software"), to deal in
5
+ the Software without restriction, including without limitation the rights to
6
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
7
+ of the Software, and to permit persons to whom the Software is furnished to do
8
+ so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in all
11
+ 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 THE
19
+ SOFTWARE.
httoop-0.2.1/PKG-INFO ADDED
@@ -0,0 +1,201 @@
1
+ Metadata-Version: 2.4
2
+ Name: httoop
3
+ Version: 0.2.1
4
+ Summary: object oriented HTTP protocol library
5
+ Author-email: SpaceOne <space@wechall.net>
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/spaceone/httoop
8
+ Keywords: HTTP,web,proxy,cache,client,server,library
9
+ Classifier: Environment :: Web Environment
10
+ Classifier: Intended Audience :: Developers
11
+ Classifier: Intended Audience :: Information Technology
12
+ Classifier: Natural Language :: English
13
+ Classifier: Operating System :: POSIX :: BSD
14
+ Classifier: Operating System :: POSIX :: Linux
15
+ Classifier: Operating System :: MacOS :: MacOS X
16
+ Classifier: Operating System :: Microsoft :: Windows
17
+ Classifier: Programming Language :: Python :: 3.8
18
+ Classifier: Programming Language :: Python :: 3.9
19
+ Classifier: Programming Language :: Python :: 3.10
20
+ Classifier: Programming Language :: Python :: 3.11
21
+ Classifier: Programming Language :: Python :: 3.12
22
+ Classifier: Programming Language :: Python :: 3.13
23
+ Classifier: Programming Language :: Python :: 3.14
24
+ Classifier: Topic :: Internet :: WWW/HTTP :: HTTP Servers
25
+ Classifier: Topic :: Internet :: WWW/HTTP :: WSGI :: Application
26
+ Classifier: Topic :: Internet :: WWW/HTTP :: WSGI :: Middleware
27
+ Classifier: Topic :: Internet :: WWW/HTTP :: WSGI :: Server
28
+ Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
29
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
30
+ Requires-Python: >=3.8
31
+ Description-Content-Type: text/markdown
32
+ License-File: LICENSE
33
+ Provides-Extra: xml
34
+ Requires-Dist: defusedxml; extra == "xml"
35
+ Provides-Extra: hal
36
+ Requires-Dist: uritemplate; extra == "hal"
37
+ Provides-Extra: test
38
+ Requires-Dist: pytest; extra == "test"
39
+ Requires-Dist: pytest-cov; extra == "test"
40
+ Requires-Dist: coveralls; extra == "test"
41
+ Requires-Dist: defusedxml; extra == "test"
42
+ Dynamic: license-file
43
+
44
+ [![Build Status](https://github.com/spaceone/httoop/actions/workflows/ci.yml/badge.svg)](https://github.com/spaceone/httoop/actions/workflows/ci.yml)
45
+ [![Coverage](https://codecov.io/gh/spaceone/httoop/branch/master/graph/badge.svg)](https://codecov.io/gh/spaceone/httoop)
46
+ [![Code Climate](https://codeclimate.com/github/spaceone/httoop/badges/gpa.svg)](https://codeclimate.com/github/spaceone/httoop)
47
+ [![MIT License](https://img.shields.io/badge/license-MIT-blue.svg?style=flat)](https://github.com/spaceone/httoop/raw/master/LICENSE)
48
+
49
+ httoop
50
+ ======
51
+
52
+ An object oriented HTTP/1.1 library. (HTTP/2 will probably follow in the future).
53
+
54
+ Httoop can be used to parse, compose and work with HTTP-Request- and Response-Messages.
55
+
56
+ It is an generic library for implementing HTTP servers, clients, caches and proxies.
57
+
58
+ Httoop provides an powerful interface using the vocabularity used in RFC 7230 - 7235 and focuses on implementing HTTP "compliant" as defined in [RFC 7230 Section 2.5](https://datatracker.ietf.org/doc/html/rfc7230#section-2.5).
59
+
60
+ "An implementation is not compliant if it fails to satisfy one or more of the MUST or REQUIRED level requirements for the protocols it implements."
61
+ [RFC 2616 Section 1.2](https://datatracker.ietf.org/doc/html/rfc2616#section-1.2)
62
+
63
+ On top of the object oriented abstraction of HTTP httoop provides an easy way to support WSGI.
64
+
65
+
66
+ HTTP and extensions are defined in the following RFC's:
67
+
68
+ * [RFC 9110 HTTP Semantics](https://datatracker.ietf.org/doc/html/rfc9110)
69
+
70
+ * HTTP/1.1 RFC 7234 [Caching](https://datatracker.ietf.org/doc/html/rfc7234)
71
+
72
+ * HTTP/2 RFC 7540 [Hypertext Transfer Protocol Version 2](https://datatracker.ietf.org/doc/html/rfc7540)
73
+
74
+ * HTTP/2 RFC 7541 [HPACK: Header Compression for HTTP/2](https://datatracker.ietf.org/doc/html/rfc7541)
75
+
76
+ * [IANA HTTP Status Codes](http://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml)
77
+
78
+ * [IANA HTTP Methods](http://www.iana.org/assignments/http-methods/http-methods.xhtml)
79
+
80
+ * [IANA Message Headers](http://www.iana.org/assignments/message-headers/message-headers.xhtml)
81
+
82
+ * [IANA URI Schemes](http://www.iana.org/assignments/uri-schemes/uri-schemes.xhtml)
83
+
84
+ * [IANA HTTP Authentication Schemes](http://www.iana.org/assignments/http-authschemes/http-authschemes.xhtml)
85
+
86
+ * [IANA HTTP Cache Directives](http://www.iana.org/assignments/http-cache-directives/http-cache-directives.xhtml)
87
+
88
+ * RFC 5987 [Character Set and Language Encoding for Hypertext Transfer Protocol (HTTP) Header Field Parameters](https://datatracker.ietf.org/doc/html/rfc5987)
89
+
90
+ * Uniform Resource Identifier (URI) ([RFC 3986](https://datatracker.ietf.org/doc/html/rfc3986))
91
+
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))
93
+
94
+ * HTTP Digest Access Authentication ([RFC 7616](https://datatracker.ietf.org/doc/html/rfc7616))
95
+
96
+ * The 'Basic' HTTP Authentication Scheme ([RFC 7617](https://datatracker.ietf.org/doc/html/rfc7617))
97
+
98
+ * Additional HTTP Status Codes ([RFC 6585](https://datatracker.ietf.org/doc/html/rfc6585))
99
+
100
+ * Forwarded HTTP Extension [RFC 7239](https://datatracker.ietf.org/doc/html/rfc7239)
101
+
102
+ * Prefer Header for HTTP [RFC 7240](https://datatracker.ietf.org/doc/html/rfc7240)
103
+
104
+ * PATCH Method for HTTP ([RFC 5789](https://datatracker.ietf.org/doc/html/rfc5789))
105
+
106
+ * JavaScript Object Notation (JSON) Patch ([RFC 6902](https://datatracker.ietf.org/doc/html/rfc6902))
107
+
108
+ * The HTTP QUERY Method ([RFC 10008](https://datatracker.ietf.org/doc/html/rfc10008))
109
+
110
+ * Use of the Content-Disposition Header Field in the Hypertext Transfer Protocol (HTTP) ([RFC 6266](https://datatracker.ietf.org/doc/html/rfc6266))
111
+
112
+ * Upgrading to TLS Within HTTP/1.1 ([RFC 2817](https://datatracker.ietf.org/doc/html/rfc2817))
113
+
114
+ * Transparent Content Negotiation in HTTP ([RFC 2295](https://datatracker.ietf.org/doc/html/rfc2295))
115
+
116
+ * HTTP Remote Variant Selection Algorithm -- RVSA/1.0 ([RFC 2296](https://datatracker.ietf.org/doc/html/rfc2296))
117
+
118
+ * HTTP State Management Mechanism ([RFC 6265](https://datatracker.ietf.org/doc/html/rfc6265))
119
+
120
+ * Same-site Cookies ([Draft 7](https://datatracker.ietf.org/doc/html/rfcdraft-west-first-party-cookies-07))
121
+
122
+ * HTTP Extensions for Web Distributed Authoring and Versioning (WebDAV) ([RFC 4918](https://datatracker.ietf.org/doc/html/rfc4918))
123
+
124
+ * Hyper Text Coffee Pot Control Protocol (HTCPCP/1.0) ([RFC 2324](https://datatracker.ietf.org/doc/html/rfc2324))
125
+
126
+ Extended information about hypermedia, WWW and how HTTP is meant to be used:
127
+
128
+ * Web Linking ([RFC 5988](https://datatracker.ietf.org/doc/html/rfc5988))
129
+
130
+ * Representational State Transfer [REST](http://www.ics.uci.edu/~fielding/pubs/dissertation/rest_arch_style.htm)
131
+
132
+ * [REST APIs must be hypertext-driven](https://roy.gbiv.com/untangled/2008/rest-apis-must-be-hypertext-driven)
133
+
134
+ * [Specialization](https://roy.gbiv.com/untangled/2008/specialization)
135
+
136
+ * [No REST in CMIS](https://roy.gbiv.com/untangled/2008/no-rest-in-cmis)
137
+
138
+ * [On software architecture](https://roy.gbiv.com/untangled/2008/on-software-architecture)
139
+
140
+ * [It is okay to use POST](https://roy.gbiv.com/untangled/2009/it-is-okay-to-use-post)
141
+
142
+ * [Paper tigers and hidden dragons](https://roy.gbiv.com/untangled/2008/paper-tigers-and-hidden-dragons)
143
+
144
+ * [Economies of scale](https://roy.gbiv.com/untangled/2008/economies-of-scale)
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
+
174
+ * [Richardson Maturity Model](https://martinfowler.com/articles/richardsonMaturityModel.html)
175
+
176
+ * [Test Cases for HTTP Content-Disposition header field](http://greenbytes.de/tech/tc2231/)
177
+
178
+ * [Cross-Origin Resource Sharing](http://www.w3.org/TR/cors/)
179
+
180
+ * [HTTP (HTML) Leaks](https://github.com/cure53/HTTPLeaks/blob/main/leak.html)
181
+
182
+ OAuth 2.0:
183
+
184
+ * [OAuth Working Group Specifications](https://oauth.net/specs/)
185
+ * [OAuth 2.0 Security Best Current Practice](https://datatracker.ietf.org/doc/html/draft-ietf-oauth-security-topics)
186
+ * [The OAuth 2.0 Authorization Framework](https://datatracker.ietf.org/doc/html/rfc6749)
187
+ * [Bearer Token Usage](https://datatracker.ietf.org/doc/html/rfc6750)
188
+ * [JSON Web Token (JWT)](https://datatracker.ietf.org/doc/html/rfc7519)
189
+ * [JSON Web Token (JWT) Profile for OAuth 2.0 Access Tokens](https://datatracker.ietf.org/doc/html/rfc9068)
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>
@@ -1,5 +1,5 @@
1
- [![Build Status](https://travis-ci.org/spaceone/httoop.svg)](https://travis-ci.org/spaceone/httoop)
2
- [![codecov](https://codecov.io/gh/spaceone/httoop/branch/master/graph/badge.svg)](https://codecov.io/gh/spaceone/httoop)
1
+ [![Build Status](https://github.com/spaceone/httoop/actions/workflows/ci.yml/badge.svg)](https://github.com/spaceone/httoop/actions/workflows/ci.yml)
2
+ [![Coverage](https://codecov.io/gh/spaceone/httoop/branch/master/graph/badge.svg)](https://codecov.io/gh/spaceone/httoop)
3
3
  [![Code Climate](https://codeclimate.com/github/spaceone/httoop/badges/gpa.svg)](https://codeclimate.com/github/spaceone/httoop)
4
4
  [![MIT License](https://img.shields.io/badge/license-MIT-blue.svg?style=flat)](https://github.com/spaceone/httoop/raw/master/LICENSE)
5
5
 
@@ -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
- * HTTP/1.1 RFC 7230 [Message Syntax and Routing](https://datatracker.ietf.org/doc/html/rfc7230)
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>
@@ -0,0 +1,77 @@
1
+ """
2
+ HTTPOOP - an OOP model of the HTTP protocol.
3
+
4
+ .. seealso:: :rfc:`2616`
5
+ """
6
+
7
+ from httoop import cache
8
+ from httoop.client import ClientStateMachine
9
+ from httoop.date import Date
10
+ from httoop.exceptions import DecodeError, EncodeError, InvalidBody, InvalidDate, InvalidHeader, InvalidLine, InvalidURI
11
+ from httoop.header import Headers
12
+ from httoop.messages import Body, Method, Protocol, Request, Response
13
+ from httoop.proxy import ProxyStateMachine
14
+ from httoop.semantic import ComposedRequest, ComposedResponse
15
+ from httoop.server import ServerStateMachine
16
+ from httoop.status import (
17
+ ACCEPTED,
18
+ BAD_GATEWAY,
19
+ BAD_REQUEST,
20
+ CONFLICT,
21
+ CONTENT_TOO_LARGE,
22
+ CONTINUE,
23
+ CREATED,
24
+ EXPECTATION_FAILED,
25
+ FORBIDDEN,
26
+ FOUND,
27
+ GATEWAY_TIMEOUT,
28
+ GONE,
29
+ HTTP_VERSION_NOT_SUPPORTED,
30
+ I_AM_A_TEAPOT,
31
+ INTERNAL_SERVER_ERROR,
32
+ LENGTH_REQUIRED,
33
+ METHOD_NOT_ALLOWED,
34
+ MOVED_PERMANENTLY,
35
+ MULTIPLE_CHOICES,
36
+ NO_CONTENT,
37
+ NON_AUTHORITATIVE_INFORMATION,
38
+ NOT_ACCEPTABLE,
39
+ NOT_FOUND,
40
+ NOT_IMPLEMENTED,
41
+ NOT_MODIFIED,
42
+ OK,
43
+ PARTIAL_CONTENT,
44
+ PAYMENT_REQUIRED,
45
+ PRECONDITION_FAILED,
46
+ PROXY_AUTHENTICATION_REQUIRED,
47
+ RANGE_NOT_SATISFIABLE,
48
+ REQUEST_TIMEOUT,
49
+ RESET_CONTENT,
50
+ SEE_OTHER,
51
+ SERVICE_UNAVAILABLE,
52
+ SWITCHING_PROTOCOLS,
53
+ TEMPORARY_REDIRECT,
54
+ UNAUTHORIZED,
55
+ UNPROCESSABLE_ENTITY,
56
+ UNSUPPORTED_MEDIA_TYPE,
57
+ URI_TOO_LONG,
58
+ USE_PROXY,
59
+ Status,
60
+ StatusException,
61
+ )
62
+ from httoop.uri import URI
63
+ from httoop.version import ServerHeader, ServerProtocol, UserAgentHeader, __version__
64
+
65
+
66
+ __all__ = [
67
+ 'ACCEPTED', 'BAD_GATEWAY', 'BAD_REQUEST', 'CONFLICT', 'CONTINUE', 'CREATED', 'EXPECTATION_FAILED', 'FORBIDDEN', 'FOUND', 'GATEWAY_TIMEOUT',
68
+ 'GONE', 'HTTP_VERSION_NOT_SUPPORTED', 'INTERNAL_SERVER_ERROR', 'I_AM_A_TEAPOT', 'LENGTH_REQUIRED', 'METHOD_NOT_ALLOWED', 'MOVED_PERMANENTLY',
69
+ 'MULTIPLE_CHOICES', 'NON_AUTHORITATIVE_INFORMATION', 'NOT_ACCEPTABLE', 'NOT_FOUND', 'NOT_IMPLEMENTED', 'NOT_MODIFIED', 'NO_CONTENT', 'OK',
70
+ 'PARTIAL_CONTENT', 'CONTENT_TOO_LARGE', 'PAYMENT_REQUIRED', 'PRECONDITION_FAILED', 'PROXY_AUTHENTICATION_REQUIRED', 'RANGE_NOT_SATISFIABLE',
71
+ 'REQUEST_TIMEOUT', 'RESET_CONTENT', 'SEE_OTHER', 'SERVICE_UNAVAILABLE', 'SWITCHING_PROTOCOLS', 'TEMPORARY_REDIRECT', 'UNAUTHORIZED',
72
+ 'UNPROCESSABLE_ENTITY', 'UNSUPPORTED_MEDIA_TYPE', 'URI', 'URI_TOO_LONG', 'USE_PROXY',
73
+ 'Body', 'ClientStateMachine', 'ComposedRequest', 'ComposedResponse', 'Date', 'DecodeError', 'EncodeError', 'Headers',
74
+ 'InvalidBody', 'InvalidDate', 'InvalidHeader', 'InvalidLine', 'InvalidURI',
75
+ 'Method', 'Protocol', 'ProxyStateMachine', 'Request', 'Response', 'ServerHeader', 'ServerProtocol', 'ServerStateMachine', 'Status',
76
+ 'StatusException', 'UserAgentHeader', '__version__', 'cache',
77
+ ]
@@ -0,0 +1,150 @@
1
+ """
2
+ httoop CLI tool.
3
+
4
+ Examples
5
+ --------
6
+ python3 -m httoop compose request -H 'Host: www.example.net' | python3 -m httoop parse request
7
+ python3 -m httoop compose response | python3 -m httoop parse response
8
+ """
9
+
10
+ import pathlib
11
+ import sys
12
+ from argparse import ArgumentParser, FileType
13
+
14
+ from httoop import Request, Response, __name__ as name, __version__ as version
15
+ from httoop.client import ClientStateMachine
16
+ from httoop.server import ServerStateMachine
17
+
18
+
19
+ class CLI:
20
+ """httoop CLI tool."""
21
+
22
+ def __init__(self) -> None:
23
+ self.message = None
24
+ self.parser = ArgumentParser(name, description=self.__doc__, epilog='https://github.com/spaceone/httoop/')
25
+ self.parent_parser = ArgumentParser(add_help=False)
26
+ self.parser.add_argument('-v', '--version', action='version', version=f'%(prog)s {version}')
27
+ self.add_subparsers()
28
+ self.parse_arguments()
29
+
30
+ def add_subparsers(self) -> None:
31
+ action_subparsers = self.parser.add_subparsers(title='action', dest='action', required=True)
32
+ parse_parser = action_subparsers.add_parser('parse', parents=[self.parent_parser])
33
+ compose_parser = action_subparsers.add_parser('compose', parents=[self.parent_parser])
34
+
35
+ compose_message_subparsers = compose_parser.add_subparsers(title='message', dest='message')
36
+ request = compose_message_subparsers.add_parser('request', parents=[self.parent_parser])
37
+ request.set_defaults(func=self.compose_request)
38
+ add = request.add_argument
39
+ add('-m', '--method')
40
+ add('-u', '--uri')
41
+ self.add_common_arguments(add)
42
+
43
+ response = compose_message_subparsers.add_parser('response', parents=[self.parent_parser])
44
+ response.set_defaults(func=self.compose_response)
45
+ add = response.add_argument
46
+ add('-s', '--status')
47
+ add('--reason')
48
+ self.add_common_arguments(add)
49
+
50
+ parse_message_subparsers = parse_parser.add_subparsers(title='message', dest='message')
51
+ request = parse_message_subparsers.add_parser('request', parents=[self.parent_parser])
52
+ request.set_defaults(func=self.parse_request)
53
+ add = request.add_argument
54
+ add('--file', default='-', type=FileType('rb'))
55
+ add('--scheme', default='http')
56
+ add('--host', default='www.example.net')
57
+ add('--port', default=80, type=int)
58
+
59
+ response = parse_message_subparsers.add_parser('response', parents=[self.parent_parser])
60
+ add = response.add_argument
61
+ response.set_defaults(func=self.parse_response)
62
+ add('--file', default='-', type=FileType('rb'))
63
+
64
+ def parse_arguments(self) -> None:
65
+ self.arguments = self.parser.parse_args()
66
+
67
+ if self.arguments.action == 'parse' and hasattr(self.arguments.file, 'buffer'):
68
+ # https://bugs.python.org/issue14156
69
+ self.arguments.file = self.arguments.file.buffer
70
+ self.arguments.func()
71
+
72
+ def add_common_arguments(self, add) -> None:
73
+ add('--protocol')
74
+ add('-H', '--header', action='append', default=[])
75
+ add('-b', '--body', default='')
76
+
77
+ def parse_request(self) -> None:
78
+ server = ServerStateMachine(self.arguments.scheme, self.arguments.host, self.arguments.port)
79
+ for _request, response in server.parse(self.arguments.file.read()):
80
+ print(repr(response))
81
+ print(repr(response.headers))
82
+ print(repr(response.body))
83
+
84
+ def parse_response(self) -> None:
85
+ client = ClientStateMachine()
86
+ client.request = Request()
87
+ for response in client.parse(self.arguments.file.read()):
88
+ print(repr(response))
89
+ print(repr(response.headers))
90
+ print(repr(response.body))
91
+ print(repr(bytes(response.body)))
92
+ if client.buffer:
93
+ print('WARNING: response not yet complete!:')
94
+ print(repr(client.message))
95
+ print(repr(client.message.headers))
96
+ print(repr(client.message.body))
97
+ print(repr(client.buffer))
98
+
99
+ def compose_request(self) -> None:
100
+ self.message = Request()
101
+ if self.arguments.method:
102
+ self.message.method = self.arguments.method
103
+ if self.arguments.uri:
104
+ self.message.uri = self.arguments.uri
105
+ self.common()
106
+
107
+ def compose_response(self) -> None:
108
+ self.message = Response()
109
+ status = self.message.status.code
110
+ if self.arguments.status:
111
+ status = int(self.arguments.status)
112
+ if self.arguments.reason:
113
+ status = (status, self.arguments.reason)
114
+ self.message.status = status
115
+ self.common()
116
+
117
+ def common(self) -> None:
118
+ if self.arguments.protocol:
119
+ protocol = self.arguments.protocol
120
+ try:
121
+ protocol = [int(x) for x in protocol.split('.', 1)]
122
+ except ValueError:
123
+ pass
124
+ else:
125
+ self.message.protocol = protocol
126
+ for header in self.arguments.header:
127
+ try:
128
+ key, value = header.split(':', 1)
129
+ except ValueError:
130
+ continue
131
+ self.message.headers[key.strip()] = value.strip()
132
+ body = self.arguments.body
133
+ if body == '-':
134
+ body = sys.stdin.read()
135
+ elif body.startswith('@'):
136
+ body = pathlib.Path(body[1:]).open('rb')
137
+ self.message.body = body
138
+
139
+ sys.stdout.write(self.decode(bytes(self.message)))
140
+ sys.stdout.write(self.decode(bytes(self.message.headers)))
141
+ sys.stdout.write(self.decode(bytes(self.message.body)))
142
+
143
+ def decode(self, data):
144
+ if str is not bytes:
145
+ data = data.decode('ISO8859-1')
146
+ return data
147
+
148
+
149
+ if __name__ == '__main__':
150
+ CLI()