lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

It might be an idea to explain what the purpose of text://protocol is to help others evaluate whether this is important to them. I found the description at to be ... opaque.

Something like this

text://protocol is a new URI scheme for HTTP-like client-server functionality, with a simpler client and server, and much reduced functionality.

A client connects to a text://protocol server at a specific network address (domain name or IP address and optional port).
  • eg., port 1961
The client sends a text://protocol request for a specific object. The request is always exactly 1 line, giving the full URI.
  • eg. text://
The server responds with a reponse-code line, then the data associated with the object. There are 3 types of response-code lines
  • '20', followed by content-type, indicates success
  • '30', followed by redirect destination, indicates a redirect
  • '40 NOK', perhaps followed description, indicates a failure
There is no blank line after the response-code line; the data starts on the next line (and can be binary data).

Normally, the content-type of the response is 'text/plain; charset=utf-8' but the example server also serves an icon as an 'image/png: charset=binary'. Presumably, a different server could send other content-types too.

A link within the text data is introduced using the character sequence '=>'. (See note [1].)

  • nc -C 1961 <<< 'text://'
    • Shows the full response at the 'home page'
  • nc -C 1961 <<< 'text://' | tail -n+2 | display
    • tail -n+2 strips off the first line (response-code line) of the response
    • display is part of the imagemagick suite, and automatically recognises the byte-stream as a PNG image

Note [1]: The home page suggests that there is a convention that a link within the text is indicated with the characters '=>'. This is a trivial amount of mark-up, but suggests that this is not actually Just Plain Text. The common content-types 'text/html', 'text/css', 'text/csv', 'text/xml' give a clue as to how to interpret the text. This suggests that the content type should not be 'text/plain', but rather something like 'text/x.textprotocol'

Hope this helps someone

Stephen Irons

On Fri, Apr 9, 2021 at 12:24, 🆃🆇🆃 <> wrote:
A smallish text://protocol client written in Lua, ~793 sloc:

Usage example:

# textprint() { public "$1" 2>/dev/null; }

# textprint text://
ℹ /IP/
ℹ ⧗ 15ms
✔ TEXT/PLAIN — 9 lines, 20 words, 251 characters, 262 bytes
ℹ UTF-8


geo:37.429167,-122.138056 PALO ALTO, CA 94301, USA,2021-03-07:~lablyd-dolben rel=me
text:// rel=icon
text:// rel=license CC0-1.0


ℹ 2021-04-09T12:22:53Z
ℹ 3DE5 488F 67AB F9CF
ℹ 19T0ANB