Refactor stats generation code

Signed-off-by: John Else <john.else@citrix.com>
CA-137766: Add GC stats reporting

rrdd was erronously reporting its own GC stats as xapi's - this code is
adapted from the code removed from rrdd.

Signed-off-by: John Else <john.else@citrix.com>
Whitespace: Fix indentation of Xapi_services.fix_cookie

$ camlp4o -printer o -no_comments ocaml/xapi/xapi_services.ml | md5sum
1bd6d207550eaf578eec4fe996447924  -
$ git checkout HEAD^
$ camlp4o -printer o -no_comments ocaml/xapi/xapi_services.ml | md5sum
1bd6d207550eaf578eec4fe996447924  -

Signed-off-by: John Else <john.else@citrix.com>
CA-140037: Fix handling of HTTP with an empty cookie

If the cookie is empty, don't attempt to do anything to it.

Code change just adds a pattern match for the empty list; apart from
that it's just indentation.

Signed-off-by: John Else <john.else@citrix.com>
CA-140037: Add some tests for fix_cookie

Signed-off-by: John Else <john.else@citrix.com>
Merge pull request #1997 from johnelse/ca-137766

CA-137766: Add GC stats reporting
Merge pull request #1998 from johnelse/ca-140037

CA-140037: Fix handling of HTTP with an empty cookie