@@ -54,8 +54,9 @@ a generic HTTP Request: :class:`~.HttpRequest`. Here's an example:
54
54
).encode(" utf-8" ),
55
55
)
56
56
57
- print (request.url) # https://www.api.example.com/product-pagination/
58
- print (request.method) # POST
57
+ print (request.url) # https://www.api.example.com/product-pagination/
58
+ print (type (request.url)) # <class 'web_poet.page_inputs.http.RequestUrl'>
59
+ print (request.method) # POST
59
60
60
61
print (type (request.headers) # <class 'web_poet.page_inputs.HttpRequestHeaders'>
61
62
print (request.headers) # <HttpRequestHeaders('Content-Type': 'application/json;charset=UTF-8')>
@@ -67,7 +68,8 @@ a generic HTTP Request: :class:`~.HttpRequest`. Here's an example:
67
68
68
69
There are a few things to take note here:
69
70
70
- * `` url`` and `` method`` are simply ** strings** .
71
+ * `` method`` is simply a ** string** .
72
+ * `` url`` is represented by the :class :`~ .RequestUrl` class .
71
73
* `` headers`` is represented by the :class :`~ .HttpRequestHeaders` class which
72
74
resembles a `` dict `` - like interface. It supports case- insensitive header- key
73
75
lookups as well as multi- key storage.
@@ -90,8 +92,9 @@ it's perfectly fine to define them as:
90
92
91
93
request = web_poet.HttpRequest(" https://api.example.com/product-info?id=123" )
92
94
93
- print (request.url) # https://api.example.com/product-info?id=123
94
- print (request.method) # GET
95
+ print (request.url) # https://api.example.com/product-info?id=123
96
+ print (type (request.url)) # <class 'web_poet.page_inputs.http.RequestUrl'>
97
+ print (request.method) # GET
95
98
96
99
print (type (request.headers) # <class 'web_poet.page_inputs.HttpRequestHeaders'>
97
100
print (request.headers) # <HttpRequestHeaders()>
@@ -141,8 +144,8 @@ Let's check out an example to see its internals:
141
144
headers = {" Content-Type" : " application/json;charset=UTF-8" }
142
145
)
143
146
144
- print (response.url) # https://www.api.example.com/product-pagination/
145
- print (type (response.url)) # <class 'str '>
147
+ print (response.url) # https://www.api.example.com/product-pagination/
148
+ print (type (response.url)) # <class 'web_poet.page_inputs.http.ResponseUrl '>
146
149
147
150
print (response.body) # b'{"data": "value \xf0\x9f\x91\x8d"}'
148
151
print (type (response.body)) # <class 'web_poet.page_inputs.HttpResponseBody'>
@@ -174,7 +177,8 @@ methods.
174
177
175
178
Here are the key take aways from the example above:
176
179
177
- * The ``url `` and ``status `` are simply **string ** and **int ** respectively.
180
+ * ``status `` is simply an **int **.
181
+ * ``url `` is represented by the :class: `~.ResponseUrl ` class.
178
182
* ``headers `` is represented by the :class: `~.HttpResponseHeaders ` class.
179
183
It's similar to :class: `~.HttpRequestHeaders ` where it inherits from
180
184
:external:py:class: `multidict.CIMultiDict `, granting it case-insensitive
0 commit comments