Skip to content

Commit 3394c39

Browse files
bugfix: ngx.req.is_internal is ONLY supported in http.
1 parent daa2c14 commit 3394c39

File tree

1 file changed

+19
-18
lines changed

1 file changed

+19
-18
lines changed

lib/resty/core/misc.lua

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,25 @@ if subsystem == "http" then
165165
end
166166
register_getter("headers_sent", headers_sent)
167167

168+
169+
-- ngx.req.is_internal
170+
171+
172+
function ngx.req.is_internal()
173+
local r = get_request()
174+
if not r then
175+
error("no request found")
176+
end
177+
178+
local rc = C.ngx_http_lua_ffi_req_is_internal(r)
179+
180+
if rc == FFI_BAD_CONTEXT then
181+
error("API disabled in the current context")
182+
end
183+
184+
return rc == 1
185+
end
186+
168187
elseif subsystem == "stream" then
169188
ffi.cdef[[
170189
int ngx_stream_lua_ffi_get_resp_status(ngx_stream_lua_request_t *r);
@@ -236,22 +255,4 @@ end
236255
_M._VERSION = base.version
237256

238257

239-
-- ngx.req.is_internal
240-
241-
function ngx.req.is_internal()
242-
local r = get_request()
243-
if not r then
244-
error("no request found")
245-
end
246-
247-
local rc = C.ngx_http_lua_ffi_req_is_internal(r)
248-
249-
if rc == FFI_BAD_CONTEXT then
250-
error("API disabled in the current context")
251-
end
252-
253-
return rc == 1
254-
end
255-
256-
257258
return _M

0 commit comments

Comments
 (0)