Module: Conduit::Defaults

Defined in:
lib/conduit/defaults.rb

Overview

Default configurations for Conduit::Stream

Constant Summary collapse

PING_PATTERN =
":"
FRAME_SEPARATOR =
"\n\n"
PAYLOAD_START =
"data:"
SANITIZE_PATTERN =
->(frame) { to_utf8(frame).strip }
CHUNK_NORMALIZER =
->(chunk) { to_utf8(chunk) }

Class Method Summary collapse

Class Method Details

.to_utf8(string) ⇒ Object



12
13
14
15
16
17
# File 'lib/conduit/defaults.rb', line 12

def to_utf8(string)
  string.dup
        .force_encoding("UTF-8")
        .encode("UTF-8", invalid: :replace, undef: :replace)
        .gsub("\r\n", "\n")
end