~/bend-docscommunity

websocket.bend checks

raw source on the hub · import element-http@0.1.0.0/websocket.bend as Websocket

5 imports
import Base
import element-crypto@0.1.0.0/sha1.bend as Sha1
import element-crypto@0.1.0.0/sha256.bend as Sha256
import element-text@0.1.0.0/base64.bend as B64
import element-text@0.1.0.0/utf8.bend as U

Types

type Frame source · line 51 · raw

Data

A frame read from the client, and the bytes after it.

type Read source · line 54 · raw

Data

Definitions

def guid source · line 13 · raw

String

def accept_key source · line 17 · raw

@+key:String -> String

Sec-WebSocket-Accept for a client's Sec-WebSocket-Key (4.2.2).

def handshake_response source · line 20 · raw

@+key:String -> String

def be16 source · line 25 · raw

@+n:U32 -> List<&2, U32>

def frame source · line 30 · raw

@+opcode:U32 -> @+payload:List<&2, U32> -> List<&2, U32>

A server frame (unmasked) with FIN set: opcode 1 text, 2 binary, 8 close, 9 ping, 10 pong.

def cp_bytes source · line 40 · raw

@+c:U32 -> List<&2, U32>

def utf8 source · line 44 · raw

@s:String -> List<&2, U32>

UTF-8 bytes of a String (code points to 1-4 bytes).

def text_frame source · line 47 · raw

@+s:String -> List<&2, U32>

def nth source · line 58 · raw

@xs:List<&2, U32> -> @n:Nat -> U32

def unmask source · line 62 · raw

@bs:List<&2, U32> -> @+m0:U32 -> @+m1:U32 -> @+m2:U32 -> @+m3:U32 -> List<&2, U32>

Unmask: payload[i] XOR mask[i mod 4].

def read_if source · line 69 · raw

@ok:Bool -> @+bs:List<&2, U32> -> @+head:Nat -> @+len:Nat -> @+masked:Bool -> Read

def read source · line 81 · raw

@+bs:List<&2, U32> -> Read

The first whole frame in bs, or RMore when bs does not hold one yet.

def payload_of source · line 94 · raw

@r:Read -> List<&2, U32>

The payload of the first whole frame ("" as Nil when none) — laws and tests.

def first_payload source · line 103 · raw

@+bs:List<&2, U32> -> List<&2, U32>