SOURCES: lighttpd-proxy-fix-redirects.patch - better patch

aredridel aredridel at pld-linux.org
Tue Jan 10 10:14:35 CET 2006


Author: aredridel                    Date: Tue Jan 10 09:14:35 2006 GMT
Module: SOURCES                       Tag: HEAD
---- Log message:
- better patch

---- Files affected:
SOURCES:
   lighttpd-proxy-fix-redirects.patch (1.2 -> 1.3) 

---- Diffs:

================================================================
Index: SOURCES/lighttpd-proxy-fix-redirects.patch
diff -u SOURCES/lighttpd-proxy-fix-redirects.patch:1.2 SOURCES/lighttpd-proxy-fix-redirects.patch:1.3
--- SOURCES/lighttpd-proxy-fix-redirects.patch:1.2	Fri Dec 30 11:15:24 2005
+++ SOURCES/lighttpd-proxy-fix-redirects.patch	Tue Jan 10 10:14:29 2006
@@ -1,6 +1,18 @@
+diff -ur lighttpd-1.4.8-o/doc/proxy.txt lighttpd-1.4.8/doc/proxy.txt
+--- lighttpd-1.4.8-o/doc/proxy.txt	2005-08-10 16:26:16.000000000 -0600
++++ lighttpd-1.4.8/doc/proxy.txt	2006-01-10 01:55:04.000000000 -0700
+@@ -67,6 +67,8 @@
+   :"host":      is ip of the proxy server
+   :"port":      is tcp-port on the "host" used by the proxy
+                 server (default: 80)
++  :"fix-redirects":  rewrite redirects from proxied servers to reflect this
++										 server's hostname and port
+ 
+   e.g.: ::
+   
 diff -ur lighttpd-1.4.8-o/src/array.h lighttpd-1.4.8/src/array.h
 --- lighttpd-1.4.8-o/src/array.h	2005-09-23 12:24:18.000000000 -0600
-+++ lighttpd-1.4.8/src/array.h	2005-12-30 03:01:39.000000000 -0700
++++ lighttpd-1.4.8/src/array.h	2006-01-10 00:38:55.000000000 -0700
 @@ -129,6 +129,7 @@
  		
  	int usage; /* fair-balancing needs the no. of connections active on this host */
@@ -11,7 +23,7 @@
  data_fastcgi *data_fastcgi_init(void);
 diff -ur lighttpd-1.4.8-o/src/data_fastcgi.c lighttpd-1.4.8/src/data_fastcgi.c
 --- lighttpd-1.4.8-o/src/data_fastcgi.c	2005-08-23 08:36:12.000000000 -0600
-+++ lighttpd-1.4.8/src/data_fastcgi.c	2005-12-30 03:01:39.000000000 -0700
++++ lighttpd-1.4.8/src/data_fastcgi.c	2006-01-10 00:38:55.000000000 -0700
 @@ -57,6 +57,7 @@
  	ds->host = buffer_init();
  	ds->port = 0;
@@ -22,7 +34,7 @@
  	ds->free = data_fastcgi_free;
 diff -ur lighttpd-1.4.8-o/src/mod_proxy.c lighttpd-1.4.8/src/mod_proxy.c
 --- lighttpd-1.4.8-o/src/mod_proxy.c	2005-11-18 05:29:36.000000000 -0700
-+++ lighttpd-1.4.8/src/mod_proxy.c	2005-12-30 03:05:19.000000000 -0700
++++ lighttpd-1.4.8/src/mod_proxy.c	2006-01-10 00:58:18.000000000 -0700
 @@ -277,6 +277,7 @@
  						{ "host",              NULL, T_CONFIG_STRING, T_CONFIG_SCOPE_CONNECTION },      /* 0 */
  						{ "port",              NULL, T_CONFIG_SHORT, T_CONFIG_SCOPE_CONNECTION },       /* 1 */
@@ -48,24 +60,25 @@
  	char *s, *ns;
  	int http_response_status = -1;
  	
-@@ -586,7 +588,16 @@
+@@ -586,7 +588,17 @@
  			break;
  		case 8:
  			if (0 == strncasecmp(key, "Location", key_len)) {
-+				char *host;
++				buffer *host;
  				con->parsed_response |= HTTP_LOCATION;
 +
-+				host = strndup(con->request.http_host->ptr, strchr(con->request.http_host->ptr, ':') - con->request.http_host->ptr);
++				host = buffer_init();
++				buffer_copy_string_len(host, con->request.http_host, strchr(con->request.http_host->ptr, ':') - con->request.http_host->ptr);
 +
-+				if(hctx->host->fix_redirects && strncasecmp(value, "http://", 7) == 0 && strncasecmp(value + 7, host, strlen(host)) == 0 && *(value + 7 + strlen(host)) == ':' && atoi(value + 7 + strlen(host) + 1) == hctx->host->port) {
-+					value = strchr(value + 7 + strlen(host), '/');
++				if(hctx->host->fix_redirects && strncmp(value, "http://", 7) == 0 && strncasecmp(value + 7, host->ptr, host->used) == 0 && *(value + 7 + host->used) == ':' && atoi(value + 7 + host->used + 1) == hctx->host->port) {
++					value = strchr(value + 7 + host->used, '/');
 +				}
 +
-+				free(host);
++				buffer_free(host);
  			}
  			break;
  		case 10:
-@@ -688,7 +699,7 @@
+@@ -688,7 +700,7 @@
  				log_error_write(srv, __FILE__, __LINE__, "sb", "Header:", hctx->response_header);
  #endif
  				/* parse the response header */
================================================================

---- CVS-web:
    http://cvs.pld-linux.org/SOURCES/lighttpd-proxy-fix-redirects.patch?r1=1.2&r2=1.3&f=u



More information about the pld-cvs-commit mailing list