1Protocol::WebSocket::ReUqsueerstC(o3nptmr)ibuted Perl DoPcruomteonctoalt:i:oWnebSocket::Request(3pm)
2
3
4

NAME

6       Protocol::WebSocket::Request - WebSocket Request
7

SYNOPSIS

9           # Constructor
10           my $req = Protocol::WebSocket::Request->new(
11               host          => 'example.com',
12               resource_name => '/demo'
13           );
14           $req->to_string; # GET /demo HTTP/1.1
15                            # Upgrade: WebSocket
16                            # Connection: Upgrade
17                            # Host: example.com
18                            # Origin: http://example.com
19                            # Sec-WebSocket-Key1: 32 0  3lD& 24+<    i u4  8! -6/4
20                            # Sec-WebSocket-Key2: 2q 4  2  54 09064
21                            #
22                            # x#####
23
24           # Parser
25           my $req = Protocol::WebSocket::Request->new;
26           $req->parse("GET /demo HTTP/1.1\x0d\x0a");
27           $req->parse("Upgrade: WebSocket\x0d\x0a");
28           $req->parse("Connection: Upgrade\x0d\x0a");
29           $req->parse("Host: example.com\x0d\x0a");
30           $req->parse("Origin: http://example.com\x0d\x0a");
31           $req->parse(
32               "Sec-WebSocket-Key1: 18x 6]8vM;54 *(5:  {   U1]8  z [  8\x0d\x0a");
33           $req->parse(
34               "Sec-WebSocket-Key2: 1_ tx7X d  <  nw  334J702) 7]o}` 0\x0d\x0a");
35           $req->parse("\x0d\x0aTm[K T2u");
36

DESCRIPTION

38       Construct or parse a WebSocket request.
39

ATTRIBUTES

41   "host"
42   "key1"
43   "key2"
44   "number1"
45   "number2"
46   "origin"
47   "resource_name"

METHODS

49   "new"
50       Create a new Protocol::WebSocket::Request instance.
51
52   "new_from_psgi"
53           my $env = {
54               HTTP_HOST => 'example.com',
55               HTTP_CONNECTION => 'Upgrade',
56               ...
57           };
58           my $req = Protocol::WebSocket::Request->new_from_psgi($env);
59
60       Create a new Protocol::WebSocket::Request instance from PSGI
61       environment.
62
63   "parse"
64           $req->parse($buffer);
65           $req->parse($handle);
66
67       Parse a WebSocket request. Incoming buffer is modified.
68
69   "to_string"
70       Construct a WebSocket request.
71
72   "connection"
73           $self->connection;
74
75       A shortcut for "$self-"field('Connection')>.
76
77   "cookies"
78   "upgrade"
79           $self->upgrade;
80
81       A shortcut for "$self-"field('Upgrade')>.
82
83
84
85perl v5.34.0                      2022-01-21 Protocol::WebSocket::Request(3pm)
Impressum