Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#70 /*.tcl files always returned w/ Transfer-Encoding: chunked?

Bug
closed-fixed
Stephen
5
2007-07-31
2007-02-19
No

AFAICT (with enabletclpages on), any *.tcl page under the documentroot will have its content returned to the user with a Transfer-Encoding: chunked, regardless of whether the request is HTTP/0.9, HTTP/1.0 or HTTP/1.1.

For modern browsers this isn't an issue as they'll generally always make (and understand a response in) HTTP/1.1 requests. But for some clients (i.e., Lynx, wget, etc.) that don't expect an HTTP/1.1 encoded reply the transfer-encoding byte ranges end up being interpreted as part of the request body.

For example, I have the following one line script in $NSHOME/pages/hello.tcl:

ns_return 200 text/plain "Hello World"

## HTTP/1.1 request (expected result)
michael@ned:/usr/local/ns/pages$ telnet localhost 80
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
GET /hello.tcl HTTP/1.1
Host: localhost
Connection: close

HTTP/1.1 200 OK
MIME-Version: 1.0
Accept-Ranges: bytes
Date: Mon, 19 Feb 2007 19:06:01 GMT
Server: NaviServer/4.99.2
Content-Type: text/plain; charset=utf-8
Transfer-Encoding: chunked
Connection: close

b
Hello World
0

Connection closed by foreign host.

## HTTP/1.0 request (unexpected result)
michael@ned:/usr/local/ns/pages$ telnet localhost 80
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
GET /hello.tcl HTTP/1.0
Connection: close

HTTP/1.1 200 OK
MIME-Version: 1.0
Accept-Ranges: bytes
Date: Mon, 19 Feb 2007 19:06:14 GMT
Server: NaviServer/4.99.2
Content-Type: text/plain; charset=utf-8
Transfer-Encoding: chunked
Connection: close

b
Hello World
0

Connection closed by foreign host.

## HTTP/0.9 request (unexpected result; do we need
## to even support HTTP/0.9 really?)
michael@ned:/usr/local/ns/pages$ telnet localhost 80
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
GET /hello.tcl
b
Hello World
0

Connection closed by foreign host.

## From Lynx (unexpected result)
michael@ned:/usr/local/ns/pages$ lynx -dump http://localhost/hello.tcl
b
Hello World
0

(All of the above tested with Naviserver compiled from CVS HEAD as of Feb 7th, 2007 & Tcl 8.4.14 under Debian.)

Discussion

  • Stephen
    Stephen
    2007-02-23

    • assigned_to: nobody --> sdeasey
     
  • Stephen
    Stephen
    2007-02-23

    Logged In: YES
    user_id=87254
    Originator: NO

    Current status:

    All responses from Tcl/ADP scripts to HTTP/1.1 clients will be sent in the chunked transfer encoding.

    All responses from Tcl/ADP scripts to HTTP/1.0 clients will have their connections close. No keep-alives.

    Static pages work as expected.

     
  • Stephen
    Stephen
    2007-07-31

    • status: open --> closed-fixed