Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No Content-Length in headers via ngx_lua #34

Open
qiaoba opened this issue Nov 14, 2014 · 0 comments
Open

No Content-Length in headers via ngx_lua #34

qiaoba opened this issue Nov 14, 2014 · 0 comments
Labels

Comments

@qiaoba
Copy link

qiaoba commented Nov 14, 2014

Hi, headers are different between nginx+php and ngx_lua when I'm trying to zip files by mod_zip. Is there anything wrong in my code? Is anybody know the reason why dosen't 'content-length' exist in response headers by ngx_lua ? @evanmiller

code by nginx + php

header('X-Accel-Chareset: utf-8');
header('Content-Type: application/zip');
header('Content-Disposition: attachment; filename=test.zip');
header('X-Archive-Files: zip');

$crc32 = "-";
$downloadPath1 = 'http://fileserver/file1';
$downloadPath2 = 'http://fileserver/file2';

$fileSize1 = 32704424;
$fileSize2 = 4849469;

$str1 = sprintf("%s %d %s %s\n", $crc32, $fileSize1, $downloadPath1, 'file1');
$str2 = sprintf("%s %d %s %s\n", $crc32, $fileSize2, $downloadPath2, 'file2');
echo $str1;
echo $str2;

http response headers:

HTTP/1.1 200 OK
Server: nginx/1.2.9
Date: Fri, 14 Nov 2014 03:24:05 GMT
Content-Type: application/zip
Content-Length: 37554209
Connection: keep-alive
X-Accel-Chareset: utf-8
Content-Disposition: attachment; filename=test.zip
X-Archive-Files: zip

code by ngx_lua

ngx.header['X-Accel-Chareset'] = 'utf-8'
ngx.header['Content-Type'] = 'application/zip'
ngx.header['Content-Disposition'] = 'attachment; filename=test.zip'
ngx.header['X-Archive-Files'] = 'zip'

local crc32 = '-' 
local downloadPath1 = 'http://fileserver/file1'
local downloadPath2 = 'http://fileserver/file2'
local fileSize1 = 32704424
local fileSize2 = 4849469

ngx.print(crc32 .. ' ' .. fileSize1 .. ' ' .. downloadPath1 .. ' ' .. 'file1' .. '\r\n')
ngx.print(crc32 .. ' ' .. fileSize2 .. ' ' .. downloadPath2 .. ' ' .. 'file2' .. '\r\n')

http response headers

HTTP/1.1 200 OK
Server: nginx/1.2.9
Date: Fri, 14 Nov 2014 03:25:51 GMT
Content-Type: application/zip
Transfer-Encoding: chunked
Connection: keep-alive
X-Accel-Chareset: utf-8
Content-Disposition: attachment; filename=test.zip
Content-Encoding: none
X-Archive-Files: zip
@evanmiller evanmiller changed the title No Conent-Length in headers via ngx_lua No Content-Length in headers via ngx_lua Oct 7, 2017
@evanmiller evanmiller added the bug label Oct 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants