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

Tollef Fog Heen tfheen at varnish-cache.org
Wed Oct 26 14:58:52 CEST 2011


commit d18336e59ed66512f5af2f2d26bb0a7261d012c8
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 7c35c3e..ad9249d 100644
--- a/bin/varnishncsa/varnishncsa.c
+++ b/bin/varnishncsa/varnishncsa.c
@@ -600,7 +600,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':
@@ -614,7 +614,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':
@@ -626,24 +626,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':
@@ -658,7 +653,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