Chunked_transfer_encoding seems doesn't work as expected

Hi All,

When i try to use the directive “chunked_transfer_encoding” to control
the encoding type of output data, it failed to output the chunked data
even thougth i turned on the directive as “chunked_transfer_encoding
on;”.

Here is the simple example of my config==>
location /chunked {
root /;
chunked_transfer_encoding on;
return 200 “hello\n”;
}

location /unchunked {
root /;
chunked_transfer_encoding off;
return 200 “world\n”;
}

And here is the results of the test bu curl.

curl -i “localhost:8345/chunked”

HTTP/1.1 200 OK
Server: nginx/1.7.7
Date: Wed, 19 Nov 2014 02:26:14 GMT
Content-Type: application/octet-stream
Content-Length: 6
Connection: keep-alive

hello

curl -i “localhost:8345/unchunked”

HTTP/1.1 200 OK
Server: nginx/1.7.7
Date: Wed, 19 Nov 2014 02:26:59 GMT
Content-Type: application/octet-stream
Content-Length: 6
Connection: keep-alive

world

======================
i am expecting that chunked data will be obtained when the request goes
into the chunked location, however, the directive seems doesn’t work as
expected.

We are using nginx as web server, so could anyone explain that and
suggest solution to resolve this issue?

Best regards,

2014-11-19

weiyuefei

Hello!

On Wed, Nov 19, 2014 at 08:49:33PM +0800, weiyuefei wrote:

When i try to use the directive “chunked_transfer_encoding” to
control the encoding type of output data, it failed to output
the chunked data even thougth i turned on the directive as
“chunked_transfer_encoding on;”.

The “chunked_transfer_encoding” directive allows to disable use of
chunked transfer encoding if Content-Length isn’t known. It
defaults to “on” and can be switched off as a workaround for
broken clients which claim HTTP/1.1 support but doesn’t understand
chunked transfer encoding. It is not expected to change handling
of requests with known Content-Length.


Maxim D.
http://nginx.org/