Welcome! Log In Create A New Profile

Advanced

Re: the keepalive problem when using redirection in code

Maxim Dounin
October 22, 2009 06:08AM
Hello!

On Thu, Oct 22, 2009 at 05:30:47AM -0400, wangbin579 wrote:

> 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?

No, the above code breaks http standard as it returns response
without message body with 302 code to arbitrary requests. And
this is why it breaks keepalive connections.

Consult RFC 2616 for details.

Maxim Dounin
Subject Author Posted

the keepalive problem when using redirection in code

wangbin579 October 22, 2009 05:30AM

Re: the keepalive problem when using redirection in code

wangbin579 October 22, 2009 05:40AM

Re: the keepalive problem when using redirection in code

wangbin579 October 22, 2009 05:52AM

Re: the keepalive problem when using redirection in code

Maxim Dounin October 22, 2009 06:08AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 293
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready