# Path: cherrypy/_cpcompat.py
#     def ntob(n, encoding='ISO-8859-1'):
#     def ntou(n, encoding='ISO-8859-1'):
#     def tonative(n, encoding='ISO-8859-1'):
#     def ntob(n, encoding='ISO-8859-1'):
#     def ntou(n, encoding='ISO-8859-1'):
#     def tonative(n, encoding='ISO-8859-1'):
# def assert_native(n):
# def base64_decode(n, encoding='ISO-8859-1'):
#     def sorted(i):
#     def reversed(x):
#     def get_daemon(t):
#     def set_daemon(t, val):
#     def get_daemon(t):
#     def set_daemon(t, val):
#     def HTTPDate(timeval=None):
#     def unquote_qs(atom, encoding, errors='strict'):
#     def unquote_qs(atom, encoding, errors='strict'):
#         def json_decode(s):
#         def _json_encode(s):
#         def json_encode(value):
#     def random20():
#     def random20():
#     def next(i):
#     def __get_daemon(self):
#     def __set_daemon(self, daemon):
# class SetDaemonProperty:


import struct
import time
import cherrypy
    import zlib
    import gzip
from cherrypy._cpcompat import basestring, BytesIO, ntob, set, unicodestr
from cherrypy.lib import file_generator
from cherrypy.lib import set_vary_header
                    do_find = False
            else:
                if self.debug:
                    cherrypy.log('Finding because not text_only', 'TOOLS.ENCODE')
                do_find = True

            if do_find:
                # Set "charset=..." param on response Content-Type header
                ct.params['charset'] = self.find_acceptable_charset()
                if self.debug:
                    cherrypy.log('Setting Content-Type %s' % ct,
                                 'TOOLS.ENCODE')
                response.headers["Content-Type"] = str(ct)

        return self.body

# GZIP

def compress(body, compress_level):
    """Compress 'body' at the given compress_level."""

    # See http://www.gzip.org/zlib/rfc-gzip.html
    yield ntob('\x1f\x8b')       # ID1 and ID2: gzip marker
    yield ntob('\x08')           # CM: compression method
    yield ntob('\x00')           # FLG: none set
    # MTIME: 4 bytes
    yield struct.pack("<L", int(time.time()) & int('FFFFFFFF', 16))
    yield ntob('\x02')           # XFL: max compression, slowest algo
    yield ntob('\xff')           # OS: unknown


# Path: cherrypy/_cpcompat.py
#     def ntob(n, encoding='ISO-8859-1'):
#     def ntou(n, encoding='ISO-8859-1'):
#     def tonative(n, encoding='ISO-8859-1'):
#     def ntob(n, encoding='ISO-8859-1'):
#     def ntou(n, encoding='ISO-8859-1'):
#     def tonative(n, encoding='ISO-8859-1'):
# def assert_native(n):
# def base64_decode(n, encoding='ISO-8859-1'):
#     def sorted(i):
#     def reversed(x):
#     def get_daemon(t):
#     def set_daemon(t, val):
#     def get_daemon(t):
#     def set_daemon(t, val):
#     def HTTPDate(timeval=None):
#     def unquote_qs(atom, encoding, errors='strict'):
#     def unquote_qs(atom, encoding, errors='strict'):
#         def json_decode(s):
#         def _json_encode(s):
#         def json_encode(value):
#     def random20():
#     def random20():
#     def next(i):
#     def __get_daemon(self):
#     def __set_daemon(self, daemon):
# class SetDaemonProperty:


# Path: cherrypy/lib/encoding.py
import struct
import time
import cherrypy
    import zlib
    import gzip
from cherrypy._cpcompat import basestring, BytesIO, ntob, set, unicodestr
from cherrypy.lib import file_generator
from cherrypy.lib import set_vary_header

                    do_find = False
            else:
                if self.debug:
                    cherrypy.log('Finding because not text_only', 'TOOLS.ENCODE')
                do_find = True

            if do_find:
                # Set "charset=..." param on response Content-Type header
                ct.params['charset'] = self.find_acceptable_charset()
                if self.debug:
                    cherrypy.log('Setting Content-Type %s' % ct,
                                 'TOOLS.ENCODE')
                response.headers["Content-Type"] = str(ct)

        return self.body

# GZIP

def compress(body, compress_level):
    """Compress 'body' at the given compress_level."""

    # See http://www.gzip.org/zlib/rfc-gzip.html
    yield ntob('\x1f\x8b')       # ID1 and ID2: gzip marker
    yield ntob('\x08')           # CM: compression method
    yield ntob('\x00')           # FLG: none set
    # MTIME: 4 bytes
    yield struct.pack("<L", int(time.time()) & int('FFFFFFFF', 16))
    yield ntob('\x02')           # XFL: max compression, slowest algo
    yield ntob('\xff')           # OS: unknown


    crc = zlib.crc32(ntob(""))