You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Impact of the new feature
Currently, our HTTP clients (WMCore and elsewhere) do not use gzip encoding neither when they send or request data from DBS. Due to increasing size of our data in DBS, e.g. bulkblock API can post 180MB in one call, it is desired to use gzip Content-Encoding which can reduce this size by factor of 25 !!!
Is your feature request related to a problem? Please describe.
Not necessary, but it is desired to add such support to reduce HTTP request time and network bandwidth
Describe the solution you'd like
Here is a fully working example how to achieve gzip encoding with HTTP request with CherryPy server:
#!/usr/bin/env python
#-*- coding: utf-8 -*-
# CherryPy server to support gzip Encoding
"""
File : cpy_gzip.py
Author : Valentin Kuznetsov <vkuznet AT gmail dot com>
Description: CherryPy server for POST gzipped requests
"""
# system modules
import os
import sys
import json
import cherrypy
try:
import cStringIO as StringIO
except ImportError: # python3
import io
except:
import StringIO
def decompress(body):
import gzip
if sys.version.startswith('3.'):
zbuf = io.BytesIO()
else:
zbuf = StringIO.StringIO()
zbuf.write(body)
zbuf.seek(0)
zfile = gzip.GzipFile(mode='rb', fileobj=zbuf)
data = zfile.read()
zfile.close()
return data
class Test(object):
@cherrypy.expose
@cherrypy.tools.accept(media='application/json')
def index(self):
raw = cherrypy.request.body.read(int(cherrypy.request.headers['Content-Length']))
if cherrypy.request.headers['Content-Encoding'] == 'gzip':
raw = decompress(raw)
return raw
b = json.loads(raw)
return json.dumps(b)
if __name__ == '__main__':
cherrypy.quickstart(Test())
If you can run this code it will provide CherryPy server which supports gzip encoding.
Now, the client only needs to add appropriate gzip HTTP header as follows:
Additional context
New dbs2go support this encoding and clients can take advantage of it, i.e. clients can supply Content-Encoding: gzip and results from dbs2go will be gzip'ed and returned to the client. Of course, client should take care how to unzip them and this can be implemented via decompress function shown above.
The text was updated successfully, but these errors were encountered:
@vkuznet Valentin, we already have such issue opened, see: #10451
I'm going to make a reference to this issue over there and close this one as duplicate. If I'm wrong, please re-open it.
Thanks for creating it though and providing some extra examples.
Impact of the new feature
Currently, our HTTP clients (WMCore and elsewhere) do not use gzip encoding neither when they send or request data from DBS. Due to increasing size of our data in DBS, e.g. bulkblock API can post 180MB in one call, it is desired to use gzip Content-Encoding which can reduce this size by factor of 25 !!!
Is your feature request related to a problem? Please describe.
Not necessary, but it is desired to add such support to reduce HTTP request time and network bandwidth
Describe the solution you'd like
Here is a fully working example how to achieve gzip encoding with HTTP request with CherryPy server:
If you can run this code it will provide CherryPy server which supports gzip encoding.
Now, the client only needs to add appropriate gzip HTTP header as follows:
Describe alternatives you've considered
None
Additional context
New
dbs2go
support this encoding and clients can take advantage of it, i.e. clients can supplyContent-Encoding: gzip
and results fromdbs2go
will be gzip'ed and returned to the client. Of course, client should take care how to unzip them and this can be implemented viadecompress
function shown above.The text was updated successfully, but these errors were encountered: