> Is it safe to use a shared table for ngx.header.some_header = shared_table?
> or can a different request reuse this table while headers are beeing sent?
Yes. You can read the source code of this part,
either the new FFI-based API or the classic lua_CFunction.