master
Steve Ayerhart 2021-08-23 22:44:45 -04:00
parent a638d0fcda
commit 4afeb73732
No known key found for this signature in database
GPG Key ID: 5C815FDF3A00B8BA
1 changed files with 26 additions and 7 deletions

View File

@ -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?
: get-all-cookies ( -- cookies )
"cookie" <session-get-request> http-web-driver-request
[
: 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
] map ;
} 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
[ 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