How to disable Transfer-Encoding: chunked?

1,110 views
Skip to first unread message

Sorin Stefan Nicolin

unread,
Sep 27, 2016, 4:35:34 AM9/27/16
to Falcon Framework

This is a repost of the Github question I posted here:

So far I tried the following:
  • set resp.stream to the length of the file I am returning (it is a get request)
  • don't set resp.stream
  • set resp.body instead "resp.body = open(my_file, encoding="utf-8").read()"
  • set resp.stream_len to the file size
  • don't set resp.stream_len
  • set the Content-Length header myself "resp.set_header("Content-Length""{}".format(statinfo.st_size))"

And for every combination of the above Transfer-Encoding is set to chunked. What am I doing wrong?
I am using Gunicorn as my WSGI server and have Nginx proxying requests to it.

Thanks.

Sorin Stefan Nicolin

unread,
Sep 27, 2016, 10:08:37 AM9/27/16
to Falcon Framework
Ok found the problem. It is not related to Falcon or Gunicorn. Nginx drops the Content-Length header if gzip is enabled because it compresses on the fly and thus can't know the file size beforehand. It then automatically adds Transfer-Encoding: chunked.
Reply all
Reply to author
Forward
0 new messages