# Chunked\_transfer\_encoding seems doesn't work as expected

**URL:** <https://www.ruby-forum.com/t/chunked-transfer-encoding-seems-doesnt-work-as-expected/233137>\
**Category:** NGINX\
**Created:** [November 19, 2014, 1:44pm UTC](https://www.ruby-forum.com/t/chunked-transfer-encoding-seems-doesnt-work-as-expected/233137 "2014-11-19T13:44:56Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![addis\_a](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/c4cdca/32.png) [@addis\_a](https://www.ruby-forum.com/u/addis_a)\
**Post date:** [November 19, 2014, 1:44pm UTC](https://www.ruby-forum.com/t/chunked-transfer-encoding-seems-doesnt-work-as-expected/233137/1 "2014-11-19T13:44:56Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![weiyuefei](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/e274bd/32.png) [@weiyuefei](https://www.ruby-forum.com/u/weiyuefei)\
**Post date:** [November 19, 2014, 2:14pm UTC](https://www.ruby-forum.com/t/chunked-transfer-encoding-seems-doesnt-work-as-expected/233137/2 "2014-11-19T14:14:01Z")

</div>

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.

> **[nginx](http://nginx.org/)**
