diff options
author | adamw <adam@warski.org> | 2017-10-17 17:28:50 +0200 |
---|---|---|
committer | adamw <adam@warski.org> | 2017-10-17 17:28:50 +0200 |
commit | 6e109a964383bfe5e2be04f65fa7cc1356a97cbe (patch) | |
tree | 7764ff94d72e0ffbf1e593fb8c5886562dc57f33 /docs/requests/cookies.rst | |
parent | 06bd5c95d04dd57e1b6c2572b94336b8fdb68bfa (diff) | |
download | sttp-6e109a964383bfe5e2be04f65fa7cc1356a97cbe.tar.gz sttp-6e109a964383bfe5e2be04f65fa7cc1356a97cbe.tar.bz2 sttp-6e109a964383bfe5e2be04f65fa7cc1356a97cbe.zip |
More docs
Diffstat (limited to 'docs/requests/cookies.rst')
-rw-r--r-- | docs/requests/cookies.rst | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/docs/requests/cookies.rst b/docs/requests/cookies.rst new file mode 100644 index 0000000..0645316 --- /dev/null +++ b/docs/requests/cookies.rst @@ -0,0 +1,28 @@ +.. _cookies: + +Cookies +======= + +Cookies sent in requests are key-value pairs contained in the ``Cookie`` header. They can be set on a request in a couple of ways. The first is using the ``.cookie(name: String, value: String)`` method. This will yield a new request definition which, when sent, will contain the given cookie. + +Cookies can also be set using the following methods:: + + def cookie(nv: (String, String)) + def cookie(n: String, v: String) + def cookies(nvs: (String, String)*) + +Cookies from responses +---------------------- + +It is often necessary to copy cookies from a response, e.g. after a login request is sent, and a successful response with the authentication cookie received. Having an object ``response: Response[_]``, cookies on a request can be copied:: + + // Method signature + def cookies(r: Response[_]) + + // Usage + sttp.cookies(response) + +Or, it's also possible to store only the ``com.softwaremill.sttp.Cookie`` objects (a sequence of which can be obtained from a response), and set the on the request:: + + def cookies(cs: Seq[Cookie]) + |