Subrequest without returning to nginx

Alfred Sawaya alfred at huji.fr
Tue May 4 14:59:46 UTC 2021


ngx_http_internal_redirect ultimatly calls ngx_http_handler, which I
tried by calling subrequest->write_event_handler after ngx_http_request.


Actually I don't want to redirect the current request, juste do a
subrequest, collects the response status, body and headers, and continue
the processing of the module without returning to nginx.


The usual way is :

  * call ngx_http_subrequest
  * return NGX_AGAIN (so it stops ngx_http_core_run_phases until the
    subrequest reactive the request)
  * When the subrequest is completed, it reactive the main request,
    which makes r->write_event_handle (ie ngx_http_core_run_phases) to
    be triggered
  * Get the subrequest from the main request, and process the response.


The way I am trying to achieve is :

  * call ngx_http_subrequest
  * wait or call some functions in order to complete the subrequest
  * collects the response and continue the processing

without returning from the function that create the subrequest.


Thank you for your help


On 04/05/2021 16:35, Ranier Vilela wrote:
> Em ter., 4 de mai. de 2021 às 11:11, Alfred Sawaya <alfred at huji.fr
> <mailto:alfred at huji.fr>> escreveu:
>
>     Hello,
>
>
>     I am currently converting an Apache module to Nginx. This module uses
>     subrequests and needs (for now) to execute the subrequest without
>     unwinding the stack (ie without returning to nginx).
>
>     I tried to call ngx_http_run_posted_requests by hand, but it does not
>     work as the upstream socket needs to get polled some time.
>
>
>     So I wonder, is there any way to do this ?
>
> You can try: ngx_http_internal_redirect
> ngx_http_internal_redirect(r, &uri, NULL);
>
> regards,
> Ranier Vilela
>
> _______________________________________________
> nginx-devel mailing list
> nginx-devel at nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx-devel/attachments/20210504/23e7b52b/attachment.htm>


More information about the nginx-devel mailing list