33This module builds on BaseHTTPServer and implements DAV commands
44
55"""
6- from __future__ import absolute_import
76from . import AuthServer
87from six .moves import urllib
98import logging
2524from pywebdav import __version__
2625
2726from xml .parsers .expat import ExpatError
28- import six
2927
3028log = logging .getLogger (__name__ )
3129
@@ -77,7 +75,7 @@ def send_body(self, DATA, code=None, msg=None, desc=None,
7775 and len (DATA ) > self .encode_threshold :
7876 buffer = io .BytesIO ()
7977 output = gzip .GzipFile (mode = 'wb' , fileobj = buffer )
80- if isinstance (DATA , str ) or isinstance ( DATA , six . text_type ) :
78+ if isinstance (DATA , str ):
8179 output .write (DATA )
8280 else :
8381 for buf in DATA :
@@ -98,7 +96,7 @@ def send_body(self, DATA, code=None, msg=None, desc=None,
9896 if DATA :
9997 if isinstance (DATA , str ):
10098 DATA = DATA .encode ('utf-8' )
101- if isinstance (DATA , six . text_type ) or isinstance (DATA , bytes ):
99+ if isinstance (DATA , str ) or isinstance (DATA , bytes ):
102100 log .debug ("Don't use iterator" )
103101 self .wfile .write (DATA )
104102 else :
@@ -152,7 +150,7 @@ def send_body_chunks(self, DATA, code, msg=None, desc=None,
152150 output .write (DATA )
153151 else :
154152 for buf in DATA :
155- buf = buf .encode () if isinstance (buf , six . text_type ) else buf
153+ buf = buf .encode () if isinstance (buf , str ) else buf
156154 output .write (buf )
157155 output .close ()
158156 buffer .seek (0 )
@@ -171,8 +169,8 @@ def send_body_chunks(self, DATA, code, msg=None, desc=None,
171169 self .wfile .write (GZDATA )
172170
173171 elif DATA :
174- DATA = DATA .encode () if isinstance (DATA , six . text_type ) else DATA
175- if isinstance (DATA , six . binary_type ):
172+ DATA = DATA .encode () if isinstance (DATA , str ) else DATA
173+ if isinstance (DATA , bytes ):
176174 self .wfile .write (b"%s\r \n " % hex (len (DATA ))[2 :].encode ())
177175 self .wfile .write (DATA )
178176 self .wfile .write (b"\r \n " )
@@ -182,7 +180,7 @@ def send_body_chunks(self, DATA, code, msg=None, desc=None,
182180 if self ._config .DAV .getboolean ('http_response_use_iterator' ):
183181 # Use iterator to reduce using memory
184182 for buf in DATA :
185- buf = buf .encode () if isinstance (buf , six . text_type ) else buf
183+ buf = buf .encode () if isinstance (buf , str ) else buf
186184 self .wfile .write ((hex (len (buf ))[2 :] + "\r \n " ).encode ())
187185 self .wfile .write (buf )
188186 self .wfile .write (b"\r \n " )
@@ -273,7 +271,7 @@ def _HEAD_GET(self, with_body=False):
273271 if with_body is False :
274272 data = None
275273
276- if isinstance (data , str ) or isinstance ( data , six . text_type ) :
274+ if isinstance (data , str ):
277275 self .send_body (data , status_code , None , None , content_type ,
278276 headers )
279277 else :
0 commit comments