2121
2222def __return_wrapper (resp ):
2323 if resp .status_code != 200 or resp .headers .get ('X-Reqid' ) is None :
24+ print (resp .text )
2425 return None , ResponseInfo (resp )
2526 resp .encoding = 'utf-8'
26- ret = resp .json (encoding = 'utf-8' ) if resp .text != '' else {}
27+ ret = resp .json () if resp .text != '' else {}
2728 return ret , ResponseInfo (resp )
2829
2930
@@ -37,6 +38,21 @@ def _init():
3738 global _session
3839 _session = session
3940
41+ def _delete (url , data , files , auth , headers = None ):
42+ if _session is None :
43+ _init ()
44+ try :
45+ post_headers = _headers .copy ()
46+ if headers is not None :
47+ for k , v in headers .items ():
48+ post_headers .update ({k : v })
49+ r = _session .delete (
50+ url , data = data , files = files , auth = auth , headers = post_headers ,
51+ timeout = config .get_default ('connection_timeout' ))
52+ except Exception as e :
53+ return None , ResponseInfo (None , e )
54+ return __return_wrapper (r )
55+
4056
4157def _post (url , data , files , auth , headers = None ):
4258 if _session is None :
@@ -107,6 +123,9 @@ def _post_with_auth(url, data, auth):
107123def _post_with_auth_and_headers (url , data , auth , headers ):
108124 return _post (url , data , None , qiniu .auth .RequestsAuth (auth ), headers )
109125
126+ def _delete_with_auth_and_headers (url , data , auth , headers ):
127+ return _delete (url , data , None , qiniu .auth .RequestsAuth (auth ), headers )
128+
110129
111130def _put_with_auth (url , data , auth ):
112131 return _put (url , data , None , qiniu .auth .RequestsAuth (auth ))
0 commit comments