tii

Tcl-based suite for working with ii/idec protocol
git clone git://git.luxferre.top/tii.git
Log | Files | Refs | README

commit 91d481cfb23c54c68888aee4f8da2e544675670f
parent 203f6a30ca7b6661830f8d61c61d1cf755f35395
Author: Luxferre <lux@ferre>
Date:   Sat, 23 Nov 2024 08:37:11 +0200

fixed compression hdrs

Diffstat:
Mtiid.tcl | 10++++++----
1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/tiid.tcl b/tiid.tcl @@ -270,12 +270,13 @@ proc repcompress {compfunc data} { proc reperror {sock ishttp errmsg compfunc} { set errmsg "error: $errmsg\n" if {$ishttp eq 1} { - set msglen [string length $errmsg] - set hdrs "Content-Type: text/plain;charset=utf-8\r\nContent-Length: $msglen\r\nConnection: close\r\n" + set hdrs "Content-Type: text/plain;charset=utf-8\r\n" if {$compfunc ne {none}} { set hdrs [string cat $hdrs "Content-Encoding: $compfunc\r\n"] set errmsg [repcompress $compfunc $errmsg] } + set msglen [string length $errmsg] + set hdrs [string cat $hdrs "Content-Length: $msglen\r\nConnection: close\r\n"] puts -nonewline $sock "HTTP/1.0 400 Bad Request\r\n$hdrs\r\n$errmsg" } else { puts -nonewline $sock "$errmsg" @@ -286,12 +287,13 @@ proc reperror {sock ishttp errmsg compfunc} { # successful reply with data proc repdata {sock ishttp data compfunc} { if {$ishttp eq 1} { - set msglen [string length $data] - set hdrs "Content-Type: text/plain;charset=utf-8\r\nContent-Length: $msglen\r\nConnection: close\r\n" + set hdrs "Content-Type: text/plain;charset=utf-8\r\n" if {$compfunc ne {none}} { set hdrs [string cat $hdrs "Content-Encoding: $compfunc\r\n"] set data [repcompress $compfunc $data] } + set msglen [string length $data] + set hdrs [string cat $hdrs "Content-Length: $msglen\r\nConnection: close\r\n"] puts -nonewline $sock "HTTP/1.0 200 OK\r\n$hdrs\r\n$data" } else { puts -nonewline $sock $data