nginx对keepalive和pipeline请求处理分析
2011年2月17日
4 条评论
原创文章,转载请注明: 转载自pagefault
本文链接地址: nginx对keepalive和pipeline请求处理分析
这次主要来看nginx中对keepalive和pipeline的处理,这里概念就不用介绍了。直接来看nginx是如何来做的。
首先来看keepalive的处理。我们知道http 1.1中keepalive是默认的,除非客户端显式的指定connect头为close。下面就是nginx判断是否需要keepalive的代码。
void
ngx_http_handler(ngx_http_request_t *r)
{
.........................................
switch (r->headers_in.connection_type) {
case 0:
//如果版本大于1.0则默认是keepalive
r->keepalive = (r->http_version > NGX_HTTP_VERSION_10);
break;
case NGX_HTTP_CONNECTION_CLOSE:
//如果指定connection头为close则不需要keepalive
r->keepalive = 0;
break;
case NGX_HTTP_CONNECTION_KEEP_ALIVE:
r->keepalive = 1;
break;
}
..................................
}
近期评论