]> git.pld-linux.org Git - packages/lighttpd.git/blob - lighttpd-proxy-fix-redirects.patch
- added
[packages/lighttpd.git] / lighttpd-proxy-fix-redirects.patch
1 diff -ur lighttpd-1.4.8-o/src/array.h lighttpd-1.4.8/src/array.h
2 --- lighttpd-1.4.8-o/src/array.h        2005-09-23 12:24:18.000000000 -0600
3 +++ lighttpd-1.4.8/src/array.h  2005-12-30 03:01:39.000000000 -0700
4 @@ -129,6 +129,7 @@
5                 
6         int usage; /* fair-balancing needs the no. of connections active on this host */
7         int last_used_ndx; /* round robin */
8 +       short fix_redirects;    
9  } data_fastcgi;
10  
11  data_fastcgi *data_fastcgi_init(void);
12 diff -ur lighttpd-1.4.8-o/src/data_fastcgi.c lighttpd-1.4.8/src/data_fastcgi.c
13 --- lighttpd-1.4.8-o/src/data_fastcgi.c 2005-08-23 08:36:12.000000000 -0600
14 +++ lighttpd-1.4.8/src/data_fastcgi.c   2005-12-30 03:01:39.000000000 -0700
15 @@ -57,6 +57,7 @@
16         ds->host = buffer_init();
17         ds->port = 0;
18         ds->is_disabled = 0;
19 +       ds->fix_redirects = 0;
20         
21         ds->copy = data_fastcgi_copy;
22         ds->free = data_fastcgi_free;
23 diff -ur lighttpd-1.4.8-o/src/mod_proxy.c lighttpd-1.4.8/src/mod_proxy.c
24 --- lighttpd-1.4.8-o/src/mod_proxy.c    2005-11-18 05:29:36.000000000 -0700
25 +++ lighttpd-1.4.8/src/mod_proxy.c      2005-12-30 03:01:51.000000000 -0700
26 @@ -277,6 +277,7 @@
27                                                 { "host",              NULL, T_CONFIG_STRING, T_CONFIG_SCOPE_CONNECTION },      /* 0 */
28                                                 { "port",              NULL, T_CONFIG_SHORT, T_CONFIG_SCOPE_CONNECTION },       /* 1 */
29                                                 { "balance",              NULL, T_CONFIG_STRING, T_CONFIG_SCOPE_CONNECTION },   /* 2 */
30 +                                               { "fix-redirects",     NULL, T_CONFIG_SHORT, T_CONFIG_SCOPE_CONNECTION },       /* 3 */
31                                                 { NULL,                NULL, T_CONFIG_UNSET, T_CONFIG_SCOPE_UNSET }
32                                         };
33                                         
34 @@ -297,6 +298,7 @@
35                                         
36                                         pcv[0].destination = df->host;
37                                         pcv[1].destination = &(df->port);
38 +                                       pcv[3].destination = &(df->fix_redirects);
39                                         
40                                         if (0 != config_insert_values_internal(srv, da_host->value, pcv)) {
41                                                 return HANDLER_ERROR;
42 @@ -527,7 +529,7 @@
43  }
44  
45  
46 -static int proxy_response_parse(server *srv, connection *con, plugin_data *p, buffer *in) {
47 +static int proxy_response_parse(server *srv, connection *con, plugin_data *p, buffer *in, handler_ctx *hctx) {
48         char *s, *ns;
49         int http_response_status = -1;
50         
51 @@ -586,7 +588,16 @@
52                         break;
53                 case 8:
54                         if (0 == strncasecmp(key, "Location", key_len)) {
55 +                               char *host;
56                                 con->parsed_response |= HTTP_LOCATION;
57 +
58 +                               host = strndup(con->request.http_host->ptr, strchr(con->request.http_host->ptr, ':') - con->request.http_host->ptr);
59 +
60 +                               if(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) {
61 +                                       value = strchr(value + 7 + strlen(host), '/');
62 +                               }
63 +
64 +                               free(host);
65                         }
66                         break;
67                 case 10:
68 @@ -688,7 +699,7 @@
69                                 log_error_write(srv, __FILE__, __LINE__, "sb", "Header:", hctx->response_header);
70  #endif
71                                 /* parse the response header */
72 -                               proxy_response_parse(srv, con, p, hctx->response_header);
73 +                               proxy_response_parse(srv, con, p, hctx->response_header, hctx);
74                                         
75                                 /* enable chunked-transfer-encoding */
76                                 if (con->request.http_version == HTTP_VERSION_1_1 &&
This page took 0.03765 seconds and 3 git commands to generate.