Project

General

Profile

Feature #1284 ยป lighttpd-keepalive-header.patch

joungkyun, 2007-08-03 09:29

View differences:

lighttpd-1.4.16/src/request.c 2007-08-03 18:22:17.000000000 +0900
1021 1021
	/* do some post-processing */
1022 1022

  
1023 1023
	if (con->request.http_version == HTTP_VERSION_1_1) {
1024
		if (keep_alive_set != HTTP_CONNECTION_CLOSE) {
1025
			/* no Connection-Header sent */
1026

  
1027
			/* HTTP/1.1 -> keep-alive default TRUE */
1028
			con->keep_alive = 1;
1029
		} else {
1030
			con->keep_alive = 0;
1024
		switch (keep_alive_set) {
1025
			case HTTP_CONNECTION_UNSET :
1026
				/* no Connection-Header sent */
1027
				con->keep_alive = -1;
1028
				break;
1029
			case HTTP_CONNECTION_CLOSE :
1030
				con->keep_alive = 0;
1031
				break;
1032
			default :
1033
				con->keep_alive = 1;
1031 1034
		}
1032 1035

  
1033 1036
		/* RFC 2616, 14.23 */
lighttpd-1.4.16/src/response.c 2007-08-03 18:22:17.000000000 +0900
26 26
#include "sys-socket.h"
27 27

  
28 28
int http_response_write_header(server *srv, connection *con) {
29
	specific_config *sp = srv->config_storage[0];
29 30
	buffer *b;
30 31
	size_t i;
31 32
	int have_date = 0;
......
42 43
	BUFFER_APPEND_STRING_CONST(b, " ");
43 44
	buffer_append_string(b, get_http_status_name(con->http_status));
44 45

  
45
	if (con->request.http_version != HTTP_VERSION_1_1 || con->keep_alive == 0) {
46
	if ( con->keep_alive > -1 ) {
46 47
		BUFFER_APPEND_STRING_CONST(b, "\r\nConnection: ");
47
		buffer_append_string(b, con->keep_alive ? "keep-alive" : "close");
48
		//if ( con->request.http_version != HTTP_VERSION_1_0 && con->keep_alive == 1 ) {
49
		if ( con->keep_alive == 1 ) {
50
			BUFFER_APPEND_STRING_CONST(b, "Keep-Alive\r\nKeep-Alive: timeout=");
51
			buffer_append_long(b, sp->max_keep_alive_idle);
52
			BUFFER_APPEND_STRING_CONST(b, ", max=");
53
			buffer_append_long(b, sp->max_keep_alive_requests - con->request_count);
54
		} else
55
			buffer_append_string(b, "close");
48 56
	}
49 57

  
50 58
	if (con->response.transfer_encoding & HTTP_TRANSFER_ENCODING_CHUNKED) {
......
212 220

  
213 221
		/* disable keep-alive if requested */
214 222

  
215
		if (con->request_count > con->conf.max_keep_alive_requests) {
223
		if (con->request_count >= con->conf.max_keep_alive_requests) {
216 224
			con->keep_alive = 0;
217 225
		}
218 226

  
    (1-1/1)