Skip to content

Commit 64edc0e

Browse files
Onvemberlenkis
authored andcommitted
Add detailed info about cookies and example (#1057)
* fixes gh-1021 update replication_timeout description * fixes gh-559 add more info about cookies (cherry picked from commit d6d834f)
1 parent 5372ccd commit 64edc0e

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

doc/reference/reference_lua/http.rst

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,49 @@ Below is a list of all ``http`` functions.
169169

170170
:rtype: table
171171

172+
The ``cookies`` component contains a Lua table where the key is a cookie
173+
name. The value is an array of two elements where the first one is the
174+
cookie value and the second one is an array with the cookie’s options.
175+
Possible options are: "Expires", "Max-Age", "Domain", "Path", "Secure",
176+
"HttpOnly", "SameSite". Note that an option is a string with '='
177+
splitting the option's name and its value.
178+
`Here <https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies>`_
179+
you can find more info.
180+
181+
**Example**
182+
183+
You can use cookies information like this:
184+
185+
.. code-block:: tarantoolsession
186+
187+
tarantool> require('http.client').get('https://www.tarantool.io/en/').cookies
188+
---
189+
- csrftoken:
190+
- bWJVkBybvX9LdJ8uLPOTVrit5P3VbRjE3potYVOuUnsSjYT5ahghDV06tXRkfnOl
191+
- - Max-Age=31449600
192+
- Path=/
193+
...
194+
195+
tarantool> cookies = require('http.client').get('https://www.tarantool.io/en/').cookies
196+
---
197+
...
198+
199+
tarantool> options = cookies['csrftoken'][2]
200+
---
201+
...
202+
203+
tarantool> for _, option in ipairs(options) do
204+
> if option:startswith('csrftoken cookie's Max-Age = ') then
205+
> print(option)
206+
> end
207+
> end
208+
209+
csrftoken cookie's Max-Age = 31449600
210+
---
211+
...
212+
213+
tarantool>
214+
172215
The following "shortcuts" exist for requests:
173216

174217
* ``http_client:get(url, options)`` - shortcut for

0 commit comments

Comments
 (0)