为了应对中兴的垃圾程序不支持 HTTP 1.0 的Content-Length 标签, 反而支持HTTP 1.1的 Chunk模式, 做了如下修改 :
修改的文件名 ngx_lua-0.7.5\src\ngx_http_lua_util.c 第500行左右
修改的函数名
ngx_int_t ngx_http_lua_send_chain_link(ngx_http_request_t *r, ngx_http_lua_ctx_t *ctx, ngx_chain_t *in)
修改的内容 llcf = ngx_http_get_module_loc_conf(r, ngx_http_lua_module);
if (llcf->http10_buffering
&& !ctx->buffering
&& !ctx->headers_sent
&& r->http_version < NGX_HTTP_VERSION_11
&& r->headers_out.content_length_n < 0)
{
ctx->buffering = 1;
}
if (llcf->http10_buffering
&& !ctx->buffering
&& !ctx->headers_sent
&& r->method & NGX_HTTP_POST
&& r->headers_out.content_length_n < 0)
{
ctx->buffering = 1;
}
if (llcf->http10_buffering
&& !ctx->buffering
&& !ctx->headers_sent
&& r->method & NGX_HTTP_GET)
//&& r->headers_out.content_length_n < 0)
{
ctx->buffering = 0;
}
下来在修改NGINX的源码
nginx-1.1.4\src\http\modules\ngx_http_chunked_filter_module.c 第69行的函数
函数名为
static ngx_int_t ngx_http_chunked_header_filter(ngx_http_request_t *r)
修改的内容如下:
static ngx_int_t
ngx_http_chunked_header_filter(ngx_http_request_t *r)
{
ngx_http_core_loc_conf_t *clcf;
ngx_http_chunked_filter_ctx_t *ctx;
if (r->headers_out.status == NGX_HTTP_NOT_MODIFIED
|| r->headers_out.status == NGX_HTTP_NO_CONTENT
|| r != r->main
|| (r->method & NGX_HTTP_HEAD))
{
return ngx_http_next_header_filter(r);
}
clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
if (r->headers_out.content_length_n == -1 || (r->method & NGX_HTTP_GET && clcf->chunked_transfer_encoding))
{
if (r->http_version < NGX_HTTP_VERSION_11) {
r->keepalive = 0;
} else {
clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);