@@ -475,7 +475,7 @@ ngx_http_lua_send_header_if_needed(ngx_http_request_t *r,
475475{
476476 ngx_int_t rc ;
477477
478- if (!ctx -> headers_sent ) {
478+ if (!r -> header_sent ) {
479479 if (r -> headers_out .status == 0 ) {
480480 r -> headers_out .status = NGX_HTTP_OK ;
481481 }
@@ -492,7 +492,6 @@ ngx_http_lua_send_header_if_needed(ngx_http_request_t *r,
492492 if (!ctx -> buffering ) {
493493 dd ("sending headers" );
494494 rc = ngx_http_send_header (r );
495- ctx -> headers_sent = 1 ;
496495 return rc ;
497496 }
498497 }
@@ -525,7 +524,7 @@ ngx_http_lua_send_chain_link(ngx_http_request_t *r, ngx_http_lua_ctx_t *ctx,
525524
526525 if (llcf -> http10_buffering
527526 && !ctx -> buffering
528- && !ctx -> headers_sent
527+ && !r -> header_sent
529528 && r -> http_version < NGX_HTTP_VERSION_11
530529 && r -> headers_out .content_length_n < 0 )
531530 {
@@ -662,7 +661,7 @@ ngx_http_lua_send_http10_headers(ngx_http_request_t *r,
662661 ngx_chain_t * cl ;
663662 ngx_int_t rc ;
664663
665- if (ctx -> headers_sent ) {
664+ if (r -> header_sent ) {
666665 return NGX_OK ;
667666 }
668667
@@ -687,7 +686,6 @@ ngx_http_lua_send_http10_headers(ngx_http_request_t *r,
687686
688687send :
689688 rc = ngx_http_send_header (r );
690- ctx -> headers_sent = 1 ;
691689 return rc ;
692690}
693691
@@ -1436,15 +1434,15 @@ ngx_http_lua_run_thread(lua_State *L, ngx_http_request_t *r,
14361434
14371435 ngx_http_lua_request_cleanup (ctx , 0 );
14381436
1439- dd ("headers sent? %d" , ctx -> headers_sent ? 1 : 0 );
1437+ dd ("headers sent? %d" , r -> header_sent ? 1 : 0 );
14401438
14411439 if (ctx -> no_abort ) {
14421440 ctx -> no_abort = 0 ;
14431441 return NGX_ERROR ;
14441442 }
14451443
1446- return ctx -> headers_sent ? NGX_ERROR :
1447- NGX_HTTP_INTERNAL_SERVER_ERROR ;
1444+ return r -> header_sent ? NGX_ERROR :
1445+ NGX_HTTP_INTERNAL_SERVER_ERROR ;
14481446 }
14491447
14501448 /* being a user coroutine that has a parent */
@@ -1497,7 +1495,7 @@ ngx_http_lua_run_thread(lua_State *L, ngx_http_request_t *r,
14971495 ngx_log_error (NGX_LOG_ERR , r -> connection -> log , 0 , "lua handler aborted: "
14981496 "user coroutine has no parent" );
14991497
1500- return ctx -> headers_sent ? NGX_ERROR : NGX_HTTP_INTERNAL_SERVER_ERROR ;
1498+ return r -> header_sent ? NGX_ERROR : NGX_HTTP_INTERNAL_SERVER_ERROR ;
15011499
15021500done :
15031501 if (ctx -> entered_content_phase && r -> connection -> fd != -1 ) {
@@ -2212,7 +2210,7 @@ ngx_http_lua_handle_exit(lua_State *L, ngx_http_request_t *r,
22122210 ctx -> exit_code );
22132211
22142212#if 1
2215- if (!ctx -> headers_sent
2213+ if (!r -> header_sent
22162214 && r -> headers_out .status == 0
22172215 && ctx -> exit_code >= NGX_HTTP_OK )
22182216 {
0 commit comments