Re: Who maintains Tclhttpd?
- From: George Peter Staplin <georgepsSPAMMENOT@xxxxxxxxxxxx>
- Date: Mon, 5 May 2008 12:58:27 +0000 (UTC)
Jan Kandziora wrote:
Alexandre Ferrieux schrieb:
Yes. Damn' brain-typo.
Maybe you mean "Content-Length" ?
If yes, it is traced to tracker id 1929403:https://sourceforge.net/tracker/index.php?func=detail&aid=1929403&group_id=10894&atid=110894
I get truncation-errors only with error and authentication pages.
in this case, it is rather the http package's fault, doing a simple
[tell] on the channel after writing (hence subject to CRLF stuff)
instead of keeping track of actual counts. Thanks for adding any
insight there, I've gotten no answer to the questino "why" ?
The culprit is (in version 3.5.1, around line 1560 in httpd.tcl)
---------
if [catch {
HdRespondHeader $sock text/html 1 [expr {[string length $message] + 4}]
$code
puts $sock ""
puts $sock $message
} err] {
Log $sock LostSocket $data(url) $err
}
Httpd_SockClose $sock $close
---------
This is clearly wrong, as it implies <puts $sock $message>, which is part of
the HTTP *data* will insert *exactly one* CRLF into the output. For the
above case, this is only true if $message has no \n (which is then
translated to CRLF!) inside. Second, it must be "string bytelength" instead
of "string length", as the output page may be encoded in utf-8 or other
multi-byte encoding.
Instead, it should read
---------
if [catch {
HttpdRespondHeader $sock text/html 1 [string bytelength $message] $code
puts $sock ""
fconfigure $sock -translation lf
puts -nonewline $sock $message
} err] {
Log $sock LostSocket $data(url) $err
}
Httpd_SockClose $sock $close
---------
It sounds like the fconfigure probably is right.
I wonder if this is any better:
set utf8msg [encoding convertto utf-8 $message]
HttpdRespondHeader $sock text/html 1 [string length $utf8msg] $code
...
puts -nonewline $sock $utf8msg
The [string length $utf8msg] should be the same as [string bytelength
$message] as I understand it, and my testing confirms that with
multibyte characters.
With Tcl's internal encoding being very similar to utf-8 it may
not matter though.
George
.
- Follow-Ups:
- Re: Who maintains Tclhttpd?
- From: vitic
- Re: Who maintains Tclhttpd?
- References:
- Who maintains Tclhttpd?
- From: EL
- Re: Who maintains Tclhttpd?
- From: George Peter Staplin
- Re: Who maintains Tclhttpd?
- From: Jan Kandziora
- Re: Who maintains Tclhttpd?
- From: EL
- Re: Who maintains Tclhttpd?
- From: Alexandre Ferrieux
- Re: Who maintains Tclhttpd?
- From: Jan Kandziora
- Who maintains Tclhttpd?
- Prev by Date: Re: ANN: SQLiteStudio 1.0.0 final
- Next by Date: Re: ANN: SQLiteStudio 1.0.0 final
- Previous by thread: Re: Who maintains Tclhttpd?
- Next by thread: Re: Who maintains Tclhttpd?
- Index(es):
Relevant Pages
|
|