Package: ucspi-tcp
Version: 1:0.88-3
Severity: wishlist
Tags: patch

Dear Maintainer,


today I wrote a simple HTTP server that utilizes tcpserver(1) from ucspi-tcp.
The server uses HTTP 1.1 chunking and is mainly useful for streaming logfiles.
I saw that no HTTP Server is included in ucspi-tcp. Would you include mine?

Plain text code: <http://news.dieweltistgarnichtso.net/bin/httptaild>
More information: <http://news.dieweltistgarnichtso.net/bin/httptaild.html>

-- System Information:
Debian Release: jessie/sid
  APT prefers testing
  APT policy: (500, 'testing')
Architecture: i386 (i686)

Kernel: Linux 3.13-1-686-pae (SMP w/1 CPU core)
Locale: LANG=de_DE.UTF-8, LC_CTYPE=de_DE.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages ucspi-tcp depends on:
ii  libc6  2.19-13

ucspi-tcp recommends no packages.

ucspi-tcp suggests no packages.

-- no debconf information
#!/bin/sh
# outputs a file over HTTP 1.1 and pushes updates when new lines are appended
# © 2014 Nils Dagsson Moskopp (erlehmann) – license: GPLv3+
# httptaild is intended for usage with tcpserver(1) from ucspi-tcp:
# "tcpserver 0 8008 httptaild log" serves log on http://localhost:8008

status () { printf '%s\r\n' "HTTP/1.1 200 Ok"; }
header () { printf '%s\r\n' "$1"; }
divide () { printf '%s\r\n' "$1"; }
length () { printf '%x\r\n' "$1"; }
body_n () { printf '%s\n\r\n' "$1"; }

status
header "Content-type: $(file --brief --mime "$1")"
header "Transfer-Encoding: chunked"
divide
length "$(wc -c <"$1")"
body_n "$(cat "$1")"

tail -n0 -f "$1" | while IFS=$(printf '\n') read -r line; do
  length "$(printf '%s\n' "$line" | wc -c)"
  body_n "$line"
done

Reply via email to