@@ -54,8 +54,9 @@ a generic HTTP Request: :class:`~.HttpRequest`. Here's an example:
5454 ).encode(" utf-8" ),
5555 )
5656
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
5960
6061 print (type (request.headers) # <class 'web_poet.page_inputs.HttpRequestHeaders'>
6162 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:
6768
6869There are a few things to take note here:
6970
70- * `` url`` and `` method`` are simply ** strings** .
71+ * `` method`` is simply a ** string** .
72+ * `` url`` is represented by the :class :`~ .RequestUrl` class .
7173 * `` headers`` is represented by the :class :`~ .HttpRequestHeaders` class which
7274 resembles a `` dict `` - like interface. It supports case- insensitive header- key
7375 lookups as well as multi- key storage.
@@ -90,8 +92,9 @@ it's perfectly fine to define them as:
9092
9193 request = web_poet.HttpRequest(" https://api.example.com/product-info?id=123" )
9294
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
9598
9699 print (type (request.headers) # <class 'web_poet.page_inputs.HttpRequestHeaders'>
97100 print (request.headers) # <HttpRequestHeaders()>
@@ -141,8 +144,8 @@ Let's check out an example to see its internals:
141144 headers = {" Content-Type" : " application/json;charset=UTF-8" }
142145 )
143146
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 '>
146149
147150 print (response.body) # b'{"data": "value \xf0\x9f\x91\x8d"}'
148151 print (type (response.body)) # <class 'web_poet.page_inputs.HttpResponseBody'>
@@ -174,7 +177,8 @@ methods.
174177
175178Here are the key take aways from the example above:
176179
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.
178182 * ``headers `` is represented by the :class: `~.HttpResponseHeaders ` class.
179183 It's similar to :class: `~.HttpRequestHeaders ` where it inherits from
180184 :external:py:class: `multidict.CIMultiDict `, granting it case-insensitive
0 commit comments