process.c
changeset 29 c5d00a24af56
parent 22 822094314703
child 32 6dc2d52e4b13
--- a/process.c	Fri May 04 10:25:31 2012 -0700
+++ b/process.c	Tue Jul 24 12:12:07 2012 -0700
@@ -48,7 +48,7 @@
 
 	/* If request parsing failed, return a blank line to squid
 	   to allow the request to pass through unmolested. */
-	if ( p_request == NULL )
+	if ( p_request == NULL || p_request->valid == 0 )
 		return pass( p_request, rule );
 
 	/*
@@ -102,6 +102,7 @@
 
 		/* send squid the lua return value. */
 		if ( v.debugmode < 5 ) {
+			if ( p_request->chid ) printf( "%s", p_request->chid );
 			puts( rewrite_string );
 			fflush( stdout );
 		}
@@ -125,14 +126,18 @@
 void
 pass( parsed *request, parsed *rule )
 {
-	finish_parsed( rule );
-	finish_parsed( request );
+	if ( v.debugmode >= 5 ) {
+		finish_parsed( rule );
+		finish_parsed( request );
+		return;
+	}
 
-	if ( v.debugmode >= 5 ) return;
-
+	if ( request && request->chid ) printf( "%s", request->chid );
 	printf( "\n" );
 	fflush( stdout );
 
+	finish_parsed( rule );
+	finish_parsed( request );
 	return;
 }
 
@@ -146,6 +151,7 @@
 {
 	if ( rule == NULL || v.debugmode >= 5 ) return;
 
+	if ( request->chid ) printf( "%s", request->chid );
 	if ( rule->redir ) printf( "%s:", rule->redir );
 	printf( "%s%s", (rule->scheme ? rule->scheme : request->scheme), rule->host );
 	if ( rule->port ) printf( ":%s", rule->port );