<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<br>
<div class="moz-forward-container">
<meta name="Generator" content="Zarafa WebApp v7.1.10-44973">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>How to make a subrequest from content handler?</title>
<!-- begin sanitized html -->
<div class="bodyclass">
<p style="padding: 0; margin: 0;"><span style="font-family:
tahoma;"><span style="font-size: 13.3333330154419px;">Hi,</span></span></p>
<p style="padding: 0; margin: 0;"><span style="font-family:
tahoma;"><span style="font-size: 13.3333330154419px;"><br>
</span></span></p>
<p style="padding: 0; margin: 0;"><span style="font-family:
tahoma;"><span style="font-size: 13.3333330154419px;">I have
a problem when using subrequest in content handler. </span></span></p>
<p style="padding: 0; margin: 0;"><span style="font-family:
tahoma;"><span style="font-size: 13.3333330154419px;"><br>
</span></span></p>
<p style="padding: 0; margin: 0;"><span style="font-family:
tahoma;"><span style="font-size: 13.3333330154419px;">The
content handler (my_content_handler) calls
ngx_http_read_client_request_body with callback handler
(my_callback). my_callback() makes a subrequest:</span></span></p>
<p style="padding: 0; margin: 0;"><span style="font-family:
tahoma;"><span style="font-size: 13.3333330154419px;"><br>
</span></span></p>
<p style="padding: 0; margin: 0;"><span style="font-family:
tahoma;"><span style="font-size: 13.3333330154419px;">ngx_int_t
my_content_handler()</span></span></p>
<p style="padding: 0; margin: 0;"><span style="font-family:
tahoma;"><span style="font-size: 13.3333330154419px;">{</span></span></p>
<p style="padding: 0; margin: 0;"><span style="font-family:
tahoma;"><span style="font-size: 13.3333330154419px;"> rc
= ngx_http_read_client_request_body(r, my_callback);</span></span></p>
<p style="padding: 0; margin: 0;"><span style="font-family:
tahoma;"><span style="font-size: 13.3333330154419px;"><br>
</span></span></p>
<p style="padding: 0; margin: 0;"><span style="font-family:
tahoma;"><span style="font-size: 13.3333330154419px;">
return rc;</span></span></p>
<p style="padding: 0; margin: 0;"><span style="font-family:
tahoma;"><span style="font-size: 13.3333330154419px;">}</span></span></p>
<p style="padding: 0; margin: 0;"><span style="font-family:
tahoma;"><span style="font-size: 13.3333330154419px;"><br>
</span></span></p>
<p style="padding: 0; margin: 0;"><span style="font-family:
tahoma;"><span style="font-size: 13.3333330154419px;">void
my_callback()</span></span></p>
<p style="padding: 0; margin: 0;"><span style="font-family:
tahoma;"><span style="font-size: 13.3333330154419px;">{</span></span></p>
<p style="padding: 0; margin: 0;"><span style="font-family:
tahoma;"><span style="font-size: 13.3333330154419px;">
ps->handler = my_post_subrequest;</span></span></p>
<p style="padding: 0; margin: 0;"><span style="font-family:
tahoma;"><span style="font-size: 13.3333330154419px;">
ps->data = ctx;</span></span></p>
<p style="padding: 0; margin: 0;"><span style="font-family:
tahoma;"><span style="font-size: 13.3333330154419px;"><br>
</span></span></p>
<p style="padding: 0; margin: 0;"><span style="font-family:
tahoma;"><span style="font-size: 13.3333330154419px;">
ngx_http_subrequest(r, ..., ps);</span></span></p>
<p style="padding: 0; margin: 0;"><span style="font-family:
tahoma;"><span style="font-size: 13.3333330154419px;">}</span></span></p>
<p style="padding: 0; margin: 0;"><span style="font-family:
tahoma;"><span style="font-size: 13.3333330154419px;"><br>
</span></span></p>
<p style="padding: 0; margin: 0;"><span style="font-family:
tahoma;"><span style="font-size: 13.3333330154419px;">void
my_post_subrequest()</span></span></p>
<p style="padding: 0; margin: 0;"><span style="font-family:
tahoma;"><span style="font-size: 13.3333330154419px;">{</span></span></p>
<p style="padding: 0; margin: 0;"><span style="font-family:
tahoma;"><span style="font-size: 13.3333330154419px;"> /*
required to return back to my_content_handler after
completion of subrequest in order to be able to handle
resulting response of subrequest */</span></span></p>
<p style="padding: 0; margin: 0;"><span style="font-family:
tahoma;"><span style="font-size: 13.3333330154419px;">}</span></span></p>
<p style="padding: 0; margin: 0;"><span style="font-family:
tahoma;"><span style="font-size: 13.3333330154419px;"><br>
</span></span></p>
<p style="padding: 0; margin: 0;"><span style="font-family:
tahoma;"><span style="font-size: 13.3333330154419px;">I have
2 questions:</span></span></p>
<p style="padding: 0; margin: 0;"><span style="font-family:
tahoma;"><span style="font-size: 13.3333330154419px;">1. how
to return back to my_content_handler, if it invokes a
subrequest?</span></span></p>
<p style="padding: 0; margin: 0;"><span style="font-family:
tahoma;"><span style="font-size: 13.3333330154419px;">2. how
to proxy subrequest's response to client?</span></span></p>
<p style="padding: 0; margin: 0;"><span style="font-family:
tahoma;"><span style="font-size: 13.3333330154419px;"><br>
</span></span></p>
<p style="padding: 0; margin: 0;"><span style="font-family:
tahoma;"><span style="font-size: 13.3333330154419px;">Thanks
in advance!</span></span></p>
<p style="padding: 0; margin: 0;"><span style="font-family:
tahoma;"><span style="font-size: 13.3333330154419px;"><br>
</span></span></p>
<p style="padding: 0; margin: 0;"><span style="font-family:
tahoma;"><span style="font-size: 13.3333330154419px;">Best
regards,</span></span></p>
<p style="padding: 0; margin: 0;"> </p>
<p style="padding: 0; margin: 0;"><span style="font-family:
tahoma;"><span style="font-size: 13.3333330154419px;">Kabirova
Nailya.</span></span></p>
</div>
<!-- end sanitized html --> <br>
</div>
<br>
</body>
</html>