1Protocol::WebSocket::ReUsspeornsCeo(n3tprmi)buted Perl DPorcoutmoecnotla:t:iWoenbSocket::Response(3pm)
2
3
4
6 Protocol::WebSocket::Response - WebSocket Response
7
9 # Constructor
10 $res = Protocol::WebSocket::Response->new(
11 host => 'example.com',
12 resource_name => '/demo',
13 origin => 'file://',
14 number1 => 777_007_543,
15 number2 => 114_997_259,
16 challenge => "\x47\x30\x22\x2D\x5A\x3F\x47\x58"
17 );
18 $res->to_string; # HTTP/1.1 101 WebSocket Protocol Handshake
19 # Upgrade: WebSocket
20 # Connection: Upgrade
21 # Sec-WebSocket-Origin: file://
22 # Sec-WebSocket-Location: ws://example.com/demo
23 #
24 # 0st3Rl&q-2ZU^weu
25
26 # Parser
27 $res = Protocol::WebSocket::Response->new;
28 $res->parse("HTTP/1.1 101 WebSocket Protocol Handshake\x0d\x0a");
29 $res->parse("Upgrade: WebSocket\x0d\x0a");
30 $res->parse("Connection: Upgrade\x0d\x0a");
31 $res->parse("Sec-WebSocket-Origin: file://\x0d\x0a");
32 $res->parse("Sec-WebSocket-Location: ws://example.com/demo\x0d\x0a");
33 $res->parse("\x0d\x0a");
34 $res->parse("0st3Rl&q-2ZU^weu");
35
37 Construct or parse a WebSocket response.
38
40 "host"
41 "location"
42 "origin"
43 "resource_name"
44 "secure"
46 "new"
47 Create a new Protocol::WebSocket::Response instance.
48
49 "parse"
50 $res->parse($buffer);
51
52 Parse a WebSocket response. Incoming buffer is modified.
53
54 "to_string"
55 Construct a WebSocket response.
56
57 "cookie"
58 "cookies"
59 "key"
60 "key1"
61 $self->key1;
62
63 Set or get "Sec-WebSocket-Key1" field.
64
65 "key2"
66 $self->key2;
67
68 Set or get "Sec-WebSocket-Key2" field.
69
70 "number1"
71 $self->number1;
72 $self->number1(123456);
73
74 Set or extract from "Sec-WebSocket-Key1" generated "number" value.
75
76 "number2"
77 $self->number2;
78 $self->number2(123456);
79
80 Set or extract from "Sec-WebSocket-Key2" generated "number" value.
81
82 "status"
83 $self->status;
84
85 Get response status (101).
86
87 "body"
88 $self->body;
89
90 Get response body.
91
92 "headers"
93 my $arrayref = $self->headers;
94
95 Get response headers.
96
97
98
99perl v5.32.1 2021-01-27Protocol::WebSocket::Response(3pm)