Skip to content

Commit 551a9f8

Browse files
committed
bugfix: lacking the fix from openresty#936 in the C API for lua-resty-core openresty#1031.
1 parent 6b01840 commit 551a9f8

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/ngx_http_lua_headers.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1298,13 +1298,30 @@ 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;
1302+
ngx_int_t rc;
13011303

13021304
ngx_http_lua_loc_conf_t *llcf;
13031305

13041306
if (r->connection->fd == (ngx_socket_t) -1) {
13051307
return NGX_HTTP_LUA_FFI_BAD_CONTEXT;
13061308
}
13071309

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

0 commit comments

Comments
 (0)