Good point, should not use chunked if not HTTP/1.1

i will take a look

Michael A. Cleverly wrote:
Is there a way to disable using chunked encoding to reply to a
particular request?

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
response 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)
[EMAIL PROTECTED]:/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)
[EMAIL PROTECTED]:/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?)
[EMAIL PROTECTED]:/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)
[EMAIL PROTECTED]:/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.)

Thanks,

Michael

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
naviserver-devel mailing list
naviserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/naviserver-devel



--
Vlad Seryakov
571 262-8608 office
[EMAIL PROTECTED]
http://www.crystalballinc.com/vlad/

Reply via email to