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:
hostlocationoriginresource_namesecure
π¦ 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. π
πͺ cookie, cookies, key πͺ
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
- opensuse-leap 16.0: perl-Protocol-WebSocket 0.26-bp160.1.11 Β· Artistic-1.0 OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms