Let webapp compress status.json if client supports it

Currently status.json is about 1.5 Mb. It can easily be compressed down
to ~115Kb which will make clients' life easier.
Also changed webapp to be a proper WebOb app to remove new wheels in
code.

Change-Id: I400c6133627a82af1c702df78ae688ed89fff0bb
diff --git a/tests/test_scheduler.py b/tests/test_scheduler.py
index 7cfea1c..4ef1790 100755
--- a/tests/test_scheduler.py
+++ b/tests/test_scheduler.py
@@ -17,6 +17,7 @@
 import ConfigParser
 from cStringIO import StringIO
 import gc
+import gzip
 import hashlib
 import json
 import logging
@@ -842,9 +843,12 @@
         self.swift = zuul.lib.swift.Swift(self.config)
 
         def URLOpenerFactory(*args, **kw):
+            if isinstance(args[0], urllib2.Request):
+                return old_urlopen(*args, **kw)
             args = [self.fake_gerrit] + list(args)
             return FakeURLOpener(self.upstream_root, *args, **kw)
 
+        old_urlopen = urllib2.urlopen
         urllib2.urlopen = URLOpenerFactory
 
         self.launcher = zuul.launcher.gearman.Gearman(self.config, self.sched,
@@ -2989,7 +2993,7 @@
         self.assertEqual(self.history[4].pipeline, 'check')
         self.assertEqual(self.history[5].pipeline, 'check')
 
-    def test_json_status(self):
+    def test_json_status(self, compressed=False):
         "Test that we can retrieve JSON status info"
         self.worker.hold_jobs_in_build = True
         A = self.fake_gerrit.addFakeChange('org/project', 'master', 'A')
@@ -2999,8 +3003,14 @@
 
         port = self.webapp.server.socket.getsockname()[1]
 
-        f = urllib.urlopen("http://localhost:%s/status.json" % port)
+        req = urllib2.Request("http://localhost:%s/status.json" % port)
+        if compressed:
+            req.add_header("accept-encoding", "gzip")
+        f = urllib2.urlopen(req)
         data = f.read()
+        if compressed:
+            gz = gzip.GzipFile(fileobj=StringIO(data))
+            data = gz.read()
 
         self.worker.hold_jobs_in_build = False
         self.worker.release()
@@ -3024,6 +3034,9 @@
         self.assertIn('project-test1', status_jobs)
         self.assertIn('project-test2', status_jobs)
 
+    def test_json_status_gzip(self):
+        self.test_json_status(True)
+
     def test_merging_queues(self):
         "Test that transitively-connected change queues are merged"
         self.config.set('zuul', 'layout_config',