Protoc...esponse(3pm)

✨ NAME ✨

Protocol::WebSocket::Response β€” WebSocket Response. That’s the name, bestie 🫢; this is the User Contributed Perl Documentation page for it, and it’s here to help you construct or parse a WebSocket response. πŸ’…

πŸ¦‹ SYNOPSIS πŸ¦‹

# Constructor
$res = Protocol::WebSocket::Response->new(
    host          => 'example.com',
    resource_name => '/demo',
    origin        => 'file://',
    number1       => 777_007_543,
    number2       => 114_997_259,
    challenge     => "\x47\x30\x22\x2D\x5A\x3F\x47\x58"
);
$res->to_string; # HTTP/1.1 101 WebSocket Protocol Handshake
                 # Upgrade: WebSocket
                 # Connection: Upgrade
                 # Sec-WebSocket-Origin: file://
                 # Sec-WebSocket-Location: ws://example.com/demo
                 #
                 # 0st3Rl&q-2ZU^weu

# Parser
$res = Protocol::WebSocket::Response->new;
$res->parse("HTTP/1.1 101 WebSocket Protocol Handshake\x0d\x0a");
$res->parse("Upgrade: WebSocket\x0d\x0a");
$res->parse("Connection: Upgrade\x0d\x0a");
$res->parse("Sec-WebSocket-Origin: file://\x0d\x0a");
$res->parse("Sec-WebSocket-Location: ws://example.com/demo\x0d\x0a");
$res->parse("\x0d\x0a");
$res->parse("0st3Rl&q-2ZU^weu");

πŸ’– DESCRIPTION πŸ’–

Construct or parse a WebSocket response. That’s the whole vibe: you’re either building one or reading one, no cap. ✨

🌸 ATTRIBUTES 🌸

These are the attributes living in this response’s main-character energy:

  • host
  • location
  • origin
  • resource_name
  • secure

πŸ¦‹ METHODS πŸ¦‹

✨ new ✨

Create a new Protocol::WebSocket::Response instance. Fresh instance, fresh vibes. πŸ‘‘

πŸ”₯ parse πŸ”₯

$res->parse($buffer);

Parse a WebSocket response. Heads up: the incoming buffer gets modified β€” yes, literally modified, so don’t act surprised. 😭

πŸŽ€ to_string πŸŽ€

Construct a WebSocket response. It’s giving output, bestie. πŸ’…

These are listed as methods, with no extra description on the page. 🫢

πŸ”‘ key1 πŸ”‘

$self->key1;

Set or get the "Sec-WebSocket-Key1" field. πŸ”

πŸ”‘ key2 πŸ”‘

$self->key2;

Set or get the "Sec-WebSocket-Key2" field. πŸ”

πŸ”’ number1 πŸ”’

$self->number1;
$self->number1(123456);

Set it, or extract the generated "number" value from "Sec-WebSocket-Key1". ✨

πŸ”’ number2 πŸ”’

$self->number2;
$self->number2(123456);

Set it, or extract the generated "number" value from "Sec-WebSocket-Key2". ✨

πŸ‘‘ status πŸ‘‘

$self->status;

Get the response status β€” it’s 101, bestie. 🌈

πŸ“¦ body πŸ“¦

$self->body;

Get the response body. πŸ“

πŸ“š headers πŸ“š

my $arrayref = $self->headers;

Get the response headers. πŸŽ€


Alright bestie, that’s the whole page. It’s from perl v5.42.0, dated 2019-03-13, with the footer name Protoc...esponse(3pm). Go build or parse that WebSocket response, slay, periodt. πŸ’–βœ¨

πŸ“¦ where this page comes from