Hey, I’m making a custom module and need to send back the redirect
response to the client. It should behave like the “sendRedirect” in java
servlet programming. So which function is that API?
Thanks.
Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,200929,200929#msg-200929
is this OK?
r->headers_out.status = NGX_HTTP_REDIRECT;
r->headers_out.content_length_n = 0;
… // the code set “Location” header
ngx_http_send_header®;
Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,200929,200937#msg-200937
Hello!
On Wed, May 25, 2011 at 06:41:46PM -0400, speedfirst wrote:
Hey, I’m making a custom module and need to send back the redirect
response to the client. It should behave like the “sendRedirect” in java
servlet programming. So which function is that API?
Thanks.
r->headers_out.location = ngx_palloc(r->pool,
sizeof(ngx_table_elt_t));
if (r->headers_out.location == NULL) {
return NGX_HTTP_INTERNAL_SERVER_ERROR;
}
r->headers_out.location->value.len = sizeof("http://example.com/") -
1;
r->headers_out.location->value.data = “http://example.com/”;
return NGX_HTTP_MOVED_PERMANENTLY;
Maxim D.