the keepalive problem when using redirection in code

wangbin579 nginx-forum at nginx.us
Thu Oct 22 13:30:47 MSD 2009


the code is as the following:
       header->hash = 1;
	header->key.len = sizeof("Location") - 1;
	header->key.data=(u_char *) "Location";
	header->value.len = strlen(param->redirectUrl);
	header->value.data=(u_char*)param->redirectUrl;
	r->header_only=1;
	r->headers_out.content_length_n=0;
	r->headers_out.content_type.len = sizeof("text/html") - 1;
	r->headers_out.content_type.data = (u_char *) "text/html";
	r->headers_out.status = NGX_HTTP_OK;
	
	return NGX_HTTP_MOVED_TEMPORARILY;

when using keepalive (65s),the http responce will return in more than  65s .

I use two methods
1. if I send some contents back(so r->header_only=0),the phenomena is gone,the http responce return normally.
2. If I set r->keepalive=0,the phenomena is also gone,the http responce return normally.

Are the  above methods right?
thanks

Posted at Nginx Forum: http://forum.nginx.org/read.php?2,15805,15805#msg-15805






More information about the nginx mailing list