equal
deleted
inserted
replaced
46 /* count lines in debugmode */ |
46 /* count lines in debugmode */ |
47 if ( v.debugmode > 2 ) v.timer.lines++; |
47 if ( v.debugmode > 2 ) v.timer.lines++; |
48 |
48 |
49 /* If request parsing failed, return a blank line to squid |
49 /* If request parsing failed, return a blank line to squid |
50 to allow the request to pass through unmolested. */ |
50 to allow the request to pass through unmolested. */ |
51 if ( p_request == NULL ) |
51 if ( p_request == NULL || p_request->valid == 0 ) |
52 return pass( p_request, rule ); |
52 return pass( p_request, rule ); |
53 |
53 |
54 /* |
54 /* |
55 * Main rewrite logic. |
55 * Main rewrite logic. |
56 * |
56 * |
100 /* the script returned nil, or otherwise had an error. */ |
100 /* the script returned nil, or otherwise had an error. */ |
101 if ( rewrite_string == NULL ) return pass( p_request, rule ); |
101 if ( rewrite_string == NULL ) return pass( p_request, rule ); |
102 |
102 |
103 /* send squid the lua return value. */ |
103 /* send squid the lua return value. */ |
104 if ( v.debugmode < 5 ) { |
104 if ( v.debugmode < 5 ) { |
|
105 if ( p_request->chid ) printf( "%s", p_request->chid ); |
105 puts( rewrite_string ); |
106 puts( rewrite_string ); |
106 fflush( stdout ); |
107 fflush( stdout ); |
107 } |
108 } |
108 } |
109 } |
109 |
110 |
123 * |
124 * |
124 */ |
125 */ |
125 void |
126 void |
126 pass( parsed *request, parsed *rule ) |
127 pass( parsed *request, parsed *rule ) |
127 { |
128 { |
|
129 if ( v.debugmode >= 5 ) { |
|
130 finish_parsed( rule ); |
|
131 finish_parsed( request ); |
|
132 return; |
|
133 } |
|
134 |
|
135 if ( request && request->chid ) printf( "%s", request->chid ); |
|
136 printf( "\n" ); |
|
137 fflush( stdout ); |
|
138 |
128 finish_parsed( rule ); |
139 finish_parsed( rule ); |
129 finish_parsed( request ); |
140 finish_parsed( request ); |
130 |
|
131 if ( v.debugmode >= 5 ) return; |
|
132 |
|
133 printf( "\n" ); |
|
134 fflush( stdout ); |
|
135 |
|
136 return; |
141 return; |
137 } |
142 } |
138 |
143 |
139 |
144 |
140 /* |
145 /* |
144 void |
149 void |
145 rewrite( parsed *request, parsed *rule ) |
150 rewrite( parsed *request, parsed *rule ) |
146 { |
151 { |
147 if ( rule == NULL || v.debugmode >= 5 ) return; |
152 if ( rule == NULL || v.debugmode >= 5 ) return; |
148 |
153 |
|
154 if ( request->chid ) printf( "%s", request->chid ); |
149 if ( rule->redir ) printf( "%s:", rule->redir ); |
155 if ( rule->redir ) printf( "%s:", rule->redir ); |
150 printf( "%s%s", (rule->scheme ? rule->scheme : request->scheme), rule->host ); |
156 printf( "%s%s", (rule->scheme ? rule->scheme : request->scheme), rule->host ); |
151 if ( rule->port ) printf( ":%s", rule->port ); |
157 if ( rule->port ) printf( ":%s", rule->port ); |
152 printf( "%s", rule->path ? rule->path : request->path ); |
158 printf( "%s", rule->path ? rule->path : request->path ); |
153 |
159 |