From 91d481cfb23c54c68888aee4f8da2e544675670f Mon Sep 17 00:00:00 2001 From: Luxferre Date: Sat, 23 Nov 2024 08:37:11 +0200 Subject: [PATCH] fixed compression hdrs --- tiid.tcl | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tiid.tcl b/tiid.tcl index 14d428e..cb98ba5 100755 --- 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