fixed compression hdrs
This commit is contained in:
@@ -270,12 +270,13 @@ proc repcompress {compfunc data} {
|
|||||||
proc reperror {sock ishttp errmsg compfunc} {
|
proc reperror {sock ishttp errmsg compfunc} {
|
||||||
set errmsg "error: $errmsg\n"
|
set errmsg "error: $errmsg\n"
|
||||||
if {$ishttp eq 1} {
|
if {$ishttp eq 1} {
|
||||||
set msglen [string length $errmsg]
|
set hdrs "Content-Type: text/plain;charset=utf-8\r\n"
|
||||||
set hdrs "Content-Type: text/plain;charset=utf-8\r\nContent-Length: $msglen\r\nConnection: close\r\n"
|
|
||||||
if {$compfunc ne {none}} {
|
if {$compfunc ne {none}} {
|
||||||
set hdrs [string cat $hdrs "Content-Encoding: $compfunc\r\n"]
|
set hdrs [string cat $hdrs "Content-Encoding: $compfunc\r\n"]
|
||||||
set errmsg [repcompress $compfunc $errmsg]
|
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"
|
puts -nonewline $sock "HTTP/1.0 400 Bad Request\r\n$hdrs\r\n$errmsg"
|
||||||
} else {
|
} else {
|
||||||
puts -nonewline $sock "$errmsg"
|
puts -nonewline $sock "$errmsg"
|
||||||
@@ -286,12 +287,13 @@ proc reperror {sock ishttp errmsg compfunc} {
|
|||||||
# successful reply with data
|
# successful reply with data
|
||||||
proc repdata {sock ishttp data compfunc} {
|
proc repdata {sock ishttp data compfunc} {
|
||||||
if {$ishttp eq 1} {
|
if {$ishttp eq 1} {
|
||||||
set msglen [string length $data]
|
set hdrs "Content-Type: text/plain;charset=utf-8\r\n"
|
||||||
set hdrs "Content-Type: text/plain;charset=utf-8\r\nContent-Length: $msglen\r\nConnection: close\r\n"
|
|
||||||
if {$compfunc ne {none}} {
|
if {$compfunc ne {none}} {
|
||||||
set hdrs [string cat $hdrs "Content-Encoding: $compfunc\r\n"]
|
set hdrs [string cat $hdrs "Content-Encoding: $compfunc\r\n"]
|
||||||
set data [repcompress $compfunc $data]
|
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"
|
puts -nonewline $sock "HTTP/1.0 200 OK\r\n$hdrs\r\n$data"
|
||||||
} else {
|
} else {
|
||||||
puts -nonewline $sock $data
|
puts -nonewline $sock $data
|
||||||
|
|||||||
Reference in New Issue
Block a user