Skip to content

Instantly share code, notes, and snippets.

@JJ
Created November 30, 2022 17:07
Show Gist options
  • Select an option

  • Save JJ/e5e6c9789e6dd2c2221744339c0e0bc2 to your computer and use it in GitHub Desktop.

Select an option

Save JJ/e5e6c9789e6dd2c2221744339c0e0bc2 to your computer and use it in GitHub Desktop.

Revisions

  1. JJ created this gist Nov 30, 2022.
    25 changes: 25 additions & 0 deletions server-login-post-by-massa.raku
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,25 @@
    sub server-login() {
    my Lock \l .= new;
    our $cro;
    l.protect: {
    my $c = Cro::HTTP::Client.new:
    base-uri => SERVER-URL,
    content-type => JSON,
    user-agent => 'honking/2022.2.1',
    timeout => %(
    connection => 240,
    headers => 480,
    ),
    cookie-jar => Cro::HTTP::Client::CookieJar.new,
    ;
    await $c.post: "{SERVER-URI}/{SESSION-PATH}", body => CREDENTIALS
    $cro = $c
    }
    $cro
    }

    sub server-post($data) {
    our $cro;
    my $r = await $cro.post: "{SERVER-URI}/{DATA-PATH}", body => $data;
    await $r.body
    }