summaryrefslogtreecommitdiff
path: root/cherrypy/lib
diff options
context:
space:
mode:
Diffstat (limited to 'cherrypy/lib')
-rw-r--r--cherrypy/lib/caching.py4
-rw-r--r--cherrypy/lib/encoding.py14
-rw-r--r--cherrypy/lib/httputil.py10
-rw-r--r--cherrypy/lib/static.py6
4 files changed, 17 insertions, 17 deletions
diff --git a/cherrypy/lib/caching.py b/cherrypy/lib/caching.py
index c4449d85..aa265164 100644
--- a/cherrypy/lib/caching.py
+++ b/cherrypy/lib/caching.py
@@ -41,7 +41,7 @@ import six
import cherrypy
from cherrypy.lib import cptools, httputil
-from cherrypy._cpcompat import ntob, Event
+from cherrypy._cpcompat import Event
class Cache(object):
@@ -406,7 +406,7 @@ def tee_output():
yield chunk
# save the cache data
- body = ntob('').join(output)
+ body = b''.join(output)
cherrypy._cache.put((response.status, response.headers or {},
body, response.time), len(body))
diff --git a/cherrypy/lib/encoding.py b/cherrypy/lib/encoding.py
index 72e58f9c..0fc15225 100644
--- a/cherrypy/lib/encoding.py
+++ b/cherrypy/lib/encoding.py
@@ -5,7 +5,7 @@ import io
import six
import cherrypy
-from cherrypy._cpcompat import text_or_bytes, ntob
+from cherrypy._cpcompat import text_or_bytes
from cherrypy.lib import file_generator
from cherrypy.lib import is_closable_iterator
from cherrypy.lib import set_vary_header
@@ -277,15 +277,15 @@ def compress(body, compress_level):
import zlib
# 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
+ yield b'\x1f\x8b' # ID1 and ID2: gzip marker
+ yield b'\x08' # CM: compression method
+ yield b'\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
+ yield b'\x02' # XFL: max compression, slowest algo
+ yield b'\xff' # OS: unknown
- crc = zlib.crc32(ntob(''))
+ crc = zlib.crc32(b'')
size = 0
zobj = zlib.compressobj(compress_level,
zlib.DEFLATED, -zlib.MAX_WBITS,
diff --git a/cherrypy/lib/httputil.py b/cherrypy/lib/httputil.py
index aa3dd6d4..66ba0114 100644
--- a/cherrypy/lib/httputil.py
+++ b/cherrypy/lib/httputil.py
@@ -56,11 +56,11 @@ def urljoin_bytes(*atoms):
This will correctly join a SCRIPT_NAME and PATH_INFO into the
original URL, even if either atom is blank.
"""
- url = ntob('/').join([x for x in atoms if x])
- while ntob('//') in url:
- url = url.replace(ntob('//'), ntob('/'))
+ url = b'/'.join([x for x in atoms if x])
+ while b'//' in url:
+ url = url.replace(b'//', b'/')
# Special-case the final url of "", and return "/" instead.
- return url or ntob('/')
+ return url or b'/'
def protocol_from_http(protocol_str):
@@ -538,7 +538,7 @@ class HeaderMap(CaseInsensitiveDict):
# because we never want to fold lines--folding has
# been deprecated by the HTTP working group.
v = b2a_base64(v.encode('utf-8'))
- return (ntob('=?utf-8?b?') + v.strip(ntob('\n')) + ntob('?='))
+ return (b'=?utf-8?b?' + v.strip(b'\n') + b'?=')
raise ValueError('Could not encode header part %r using '
'any of the encodings %r.' %
diff --git a/cherrypy/lib/static.py b/cherrypy/lib/static.py
index ed6467a0..da9d9373 100644
--- a/cherrypy/lib/static.py
+++ b/cherrypy/lib/static.py
@@ -204,7 +204,7 @@ def _serve_fileobj(fileobj, content_type, content_length, debug=False):
def file_ranges():
# Apache compatibility:
- yield ntob('\r\n')
+ yield b'\r\n'
for start, stop in r:
if debug:
@@ -223,12 +223,12 @@ def _serve_fileobj(fileobj, content_type, content_length, debug=False):
gen = file_generator_limited(fileobj, stop - start)
for chunk in gen:
yield chunk
- yield ntob('\r\n')
+ yield b'\r\n'
# Final boundary
yield ntob('--' + boundary + '--', 'ascii')
# Apache compatibility:
- yield ntob('\r\n')
+ yield b'\r\n'
response.body = file_ranges()
return response.body
else: