[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: patch adding logging of virtual servername



I improved it some.

Ok, at the cost of moving 2 if's out of their enclosing if's it is now so
that a request that had no host in the request will allways start with a
/. The difference between a request to a virtual host and one without a
virtual host can be decided by checking the leading /

Note this patch does alter how requests are logged as you obviously lose
the difference between wether somebody did in fact put a leading / there
or not. There is not much reason for one to know though and knowing what
virtual server got used is far more interesting.

Dirk Moerenhout ///// System Administrator ///// Planet Internet NV

On Fri, 24 Aug 2001, Dirk Moerenhout wrote:

> Note, the patch is quite trivial and should maybe be enhanced to allow for
> easier parsing of certain cases but it should work for those who need it.
> Basically instead of logging /index.html it 'll just log the servername in
> front of it.
>
> It does cover cases where people request something in the rootdir without
> leading slash. So a GET index.html gets correctly logged as
> virtualservername/index.html.
>
> Parsing might be somewhat hard if people also do requests with no hostname
> given though it sure beats having no idea what virtualserver the
> /index.html refers to ;-)
>
> Dirk Moerenhout ///// System Administrator ///// Planet Internet NV
>
--- linuxprev/net/tux/logger.c	Fri Aug 24 22:59:16 2001
+++ linux/net/tux/logger.c	Fri Aug 24 23:45:40 2001
@@ -134,6 +134,16 @@
 	uri_len = req->uri_len;
 	len = uri_len + 1;
 
+        if (req->uri_str[0] != '/')
+        {
+          len++;
+        }
+
+	if (virtual_server && req->host_len)
+        {
+          len += req->host_len;
+        }
+
 	Dprintk("method_str: {%s} [%d]\n", req->method_str, req->method_len);
 	len += req->method_len + 1;
 
@@ -246,6 +256,18 @@
 		CHECK_LOGPTR(str);
 	}
 	*str++ = 0;
+
+        if (virtual_server && req->host_len)
+        {
+          memcpy(str, req->host, req->host_len);
+          str += req->host_len;
+          CHECK_LOGPTR(str);
+        }
+
+        if (req->uri_str[0] != '/')
+        {
+          *str++ = '/';
+        }
 
 	strncpy(str, req->uri_str, req->uri_len);
 	str += uri_len;

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index] []