cookies
parent
a638d0fcda
commit
4afeb73732
|
@ -1,4 +1,4 @@
|
|||
USING: kernel http http.client http.server io.pathnames io.encodings.string io.encodings.utf8 io.launcher accessors urls parser effects.parser words arrays sequences quotations json.reader json.writer formatting assocs namespaces present hashtables words.symbol combinators lexer calendar ;
|
||||
USING: kernel http http.client http.server io.pathnames io.encodings.string io.encodings.utf8 io.launcher accessors urls parser effects.parser words arrays sequences quotations json.reader json.writer formatting assocs namespaces present hashtables words.symbol combinators lexer calendar prettyprint.backend ;
|
||||
USING: prettyprint ;
|
||||
|
||||
IN: web-driver
|
||||
|
@ -229,14 +229,33 @@ TUPLE: rect x y width height ;
|
|||
|
||||
! TODO: samesite?
|
||||
|
||||
: web-driver-cookie>cookie ( hashtable -- cookie )
|
||||
{
|
||||
[ "name" of ] [ "value" of f f ] [ "path" of ] [ "domain" of ]
|
||||
[ "expiry" of f swap unix-time>timestamp ] [ "httpOnly" of ] [ "secure" of ]
|
||||
} cleave cookie boa ;
|
||||
|
||||
: cookie>web-driver-cookie ( cookie -- hashtable )
|
||||
tuple>assoc >hashtable [
|
||||
[ "httpOnly" "http-only" rot rename-at ]
|
||||
[ "expiry" "max-age" rot rename-at ] bi
|
||||
] keep ;
|
||||
|
||||
: get-all-cookies ( -- cookies )
|
||||
"cookie" <session-get-request> http-web-driver-request
|
||||
[
|
||||
{
|
||||
[ "name" of ] [ "value" of f f ] [ "path" of ] [ "domain" of ]
|
||||
[ "expiry" of f swap unix-time>timestamp ] [ "httpOnly" of ] [ "secure" of ]
|
||||
} cleave cookie boa
|
||||
] map ;
|
||||
[ web-driver-cookie>cookie ] map ;
|
||||
|
||||
: get-named-cookie ( name -- value )
|
||||
"cookie" prepend-path <session-get-request> http-web-driver-request web-driver-cookie>cookie ;
|
||||
|
||||
: add-cookie ( cookie -- )
|
||||
cookie>web-driver-cookie "cookie" <session-post-request> http-web-driver-request drop ;
|
||||
|
||||
: delete-cookie ( name -- )
|
||||
"cookie" prepend-path <session-delete-request> http-web-driver-request drop ;
|
||||
|
||||
: delete-all-cookies ( -- )
|
||||
"cookie" <session-delete-request> http-web-driver-request drop ;
|
||||
|
||||
! TODO: handle driver processes better
|
||||
|
||||
|
|
Loading…
Reference in New Issue