Skip to content

Commit 113d138

Browse files
moonmingagentzh
authored andcommitted
bugfix: lacking the fix from #936 in the C API for lua-resty-core. #1031
Signed-off-by: Yichun Zhang (agentzh) <yichun@openresty.com>
1 parent 6b01840 commit 113d138

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/ngx_http_lua_headers.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1298,13 +1298,29 @@ ngx_http_lua_ffi_get_resp_header(ngx_http_request_t *r,
12981298
ngx_uint_t i;
12991299
ngx_table_elt_t *h;
13001300
ngx_list_part_t *part;
1301+
ngx_http_lua_ctx_t *ctx;
13011302

13021303
ngx_http_lua_loc_conf_t *llcf;
13031304

13041305
if (r->connection->fd == (ngx_socket_t) -1) {
13051306
return NGX_HTTP_LUA_FFI_BAD_CONTEXT;
13061307
}
13071308

1309+
ctx = ngx_http_get_module_ctx(r, ngx_http_lua_module);
1310+
if (ctx == NULL) {
1311+
/* *errmsg = "no ctx found"; */
1312+
return NGX_ERROR;
1313+
}
1314+
1315+
if (!ctx->headers_set) {
1316+
if (ngx_http_lua_set_content_type(r) != NGX_OK) {
1317+
/* *errmsg = "failed to set default content type"; */
1318+
return NGX_ERROR;
1319+
}
1320+
1321+
ctx->headers_set = 1;
1322+
}
1323+
13081324
llcf = ngx_http_get_module_loc_conf(r, ngx_http_lua_module);
13091325
if (llcf->transform_underscores_in_resp_headers
13101326
&& memchr(key, '_', key_len) != NULL)

0 commit comments

Comments
 (0)