fixed compression hdrs

This commit is contained in:
Luxferre
2024-11-23 08:37:11 +02:00
parent 203f6a30ca
commit 91d481cfb2
+6 -4
View File
@@ -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