[master] 7a0dc3f Add default values for some fields when logging imcomplete records. Allow %r format to log incomplete records too. Update docs to reflect new defaults

Andreas Plesner Jacobsen apj at varnish-cache.org
Mon Oct 10 14:57:11 CEST 2011


commit 7a0dc3f78987b37edc927c231a42879915e9f2ac
Author: Andreas Plesner Jacobsen <apj at mutt.dk>
Date:   Mon Oct 10 14:55:55 2011 +0200

    Add default values for some fields when logging imcomplete records.
    Allow %r format to log incomplete records too.
    Update docs to reflect new defaults
    
    Fixes #1028

diff --git a/bin/varnishncsa/varnishncsa.c b/bin/varnishncsa/varnishncsa.c
index 26ede48..47e5e2a 100644
--- a/bin/varnishncsa/varnishncsa.c
+++ b/bin/varnishncsa/varnishncsa.c
@@ -603,7 +603,7 @@ h_ncsa(void *priv, enum VSL_tag_e tag, unsigned fd,
 			break;
 
 		case 'H':
-			VSB_cat(os, lp->df_H);
+			VSB_cat(os, lp->df_H ? lp->df_H : "HTTP/1.0");
 			break;
 
 		case 'h':
@@ -617,7 +617,7 @@ h_ncsa(void *priv, enum VSL_tag_e tag, unsigned fd,
 			break;
 
 		case 'm':
-			VSB_cat(os, lp->df_m);
+			VSB_cat(os, lp->df_m ? lp->df_m : "-");
 			break;
 
 		case 'q':
@@ -629,24 +629,19 @@ h_ncsa(void *priv, enum VSL_tag_e tag, unsigned fd,
 			 * Fake "%r".  This would be a lot easier if Varnish
 			 * normalized the request URL.
 			 */
-			if (!lp->df_m ||
-			    !req_header(lp, "Host") ||
-			    !lp->df_U ||
-			    !lp->df_H) {
-				clean_logline(lp);
-				return (reopen);
-			}
-			VSB_cat(os, lp->df_m);
+			VSB_cat(os, lp->df_m ? lp->df_m : "-");
 			VSB_putc(os, ' ');
 			if (req_header(lp, "Host")) {
 				if (strncmp(req_header(lp, "Host"), "http://", 7) != 0)
 					VSB_cat(os, "http://");
 				VSB_cat(os, req_header(lp, "Host"));
+			} else {
+				VSB_cat(os, "http://localhost");
 			}
-			VSB_cat(os, lp->df_U);
+			VSB_cat(os, lp->df_U ? lp->df_U : "-");
 			VSB_cat(os, lp->df_q ? lp->df_q : "");
 			VSB_putc(os, ' ');
-			VSB_cat(os, lp->df_H);
+			VSB_cat(os, lp->df_H ? lp->df_H : "HTTP/1.0");
 			break;
 
 		case 's':
@@ -661,7 +656,7 @@ h_ncsa(void *priv, enum VSL_tag_e tag, unsigned fd,
 			break;
 
 		case 'U':
-			VSB_cat(os, lp->df_U);
+			VSB_cat(os, lp->df_U ? lp->df_U : "-");
 			break;
 
 		case 'u':
diff --git a/doc/sphinx/reference/varnishncsa.rst b/doc/sphinx/reference/varnishncsa.rst
index a4bac0a..e654e37 100644
--- a/doc/sphinx/reference/varnishncsa.rst
+++ b/doc/sphinx/reference/varnishncsa.rst
@@ -62,10 +62,12 @@ The following options are available:
    	         bytes are sent.
 
 	      %H 
-	         The request protocol
+	         The request protocol. Defaults to HTTP/1.0 if not
+                 known.
 
               %h
-	         Remote host
+	         Remote host. Defaults to '-' if not known.
+                 Defaults to 127.0.0.1 for backend requests.
 
 	      %{X}i
 	         The contents of request header line X.
@@ -74,16 +76,18 @@ The following options are available:
 	         Remote logname (always '-')
 
 	      %m
-	         Request method
+	         Request method. Defaults to '-' if not known.
 
 	      %q
-	         The query string, if no query string exists, an empty string.
+	         The query string, if no query string exists, an
+                 empty string.
 
 	      %{X}o
 	         The contents of response header line X.
 
 	      %r
-	         The first line of the request
+	         The first line of the request. Synthesized from other
+                 fields, so it may not be the request verbatim.
 
 	      %s
 	         Status sent to the client
@@ -93,7 +97,8 @@ The following options are available:
 	         format.
 
 	      %U
-	         The request URL without any query string.
+	         The request URL without any query string. Defaults to
+                 '-' if not known.
 
 	      %u
 	         Remote user from auth



More information about the varnish-commit mailing list