Am Mittwoch, 12. Juli 2006 15:23 schrieb Bernd Eidenschink:
> it looks like the mechanism of changing the encoding works as expected, but
> the computation of the correct contentlength not.

ok. I think this is going on:

1. NsTclReturnObjCmd
If ns_return is called _without_ -binary switch, Ns_ConnReturnCharData is 
called. The length is computed from the UTF-8 representation.

2. Ns_ConnReturnCharData
calls

3. ReturnCharData
Knows what output encoding to use. If not UTF-8, it will call
Ns_WriteCharConn

...BUT BEFORE...

4.
Ns_ConnSetRequiredHeaders
calls Ns_ConnSetLengthHeader
(Set the Content-Length output header)

for

5.
Ns_ConnQueueHeaders
calls NS_ConnConstructHeaders
where
"Update the response length value directly from the header to be sent, i.e., 
don't trust programmers"

So the content-length is set.

NOW:

7. Ns_WriteCharConn is called, calls
Ns_ConnWriteChars
that with the help of Ns_ConnWriteVChars encodes
with the help of "Tcl_UtfToExternal" to the final encoding.

I can be fundamentally wrong, but it seems to me like the 
whatever-it-will-become final encoding length should be computed earlier...

What do you think?

Bernd.

Reply via email to