Skip to content

Explicit Framing Protocol Proposal

emdash edited this page Jun 1, 2019 · 5 revisions

Key idea: allow Oil / OSH to send records of arbitrary data over byte streams.

Internally uses framing format, Inspired by: https://tools.ietf.org/html/rfc6455#section-5. Interface is via primitives put, get, which write, read from streams, preserving message boundaries.

Message (a.k.a. "Record", a.k.a. "Packet") is a variable-length chunk of arbitrary bytes. Can contain newlines, nulls, etc. Quoting is not required for data sent in framed packets. Escaping is done through filters.

  • put operation writes a message with bytes of argument as payload to stdout
  • syntax? i.e. `put "${foo}" > socket'
  • get operation reads one message from stdin, copies bytes into argument.
  • escape filter reads one frame, outputs escaped version: escape --json < socket
  • unescape lifts from plaintext stream to framed channel: unescape -d',' --json > socket

Examples:

TBD

Questions:

  • can we use strings as byte buffers, or does there need to be a byte buffer type?
  • I.e. What happens if an oil string contains an embedded null?
  • Is it better if get put work more like read, and interpret their argument as the name of a var?
  • i.e. put foo > socket vs . put "${foo}" > socket.
Clone this wiki locally