remove not used rest_client

1. "json的内容可以通过设置Content-Type为application/json达成,没必要单独增加一个json字段。" remove not used code
2.  在alpaca撤单调试过程中,发生返回值200,但body.text是json的情况,致rest_client解析json报错,加了try/catch做处理
This commit is contained in:
vigarbuaa 2019-06-22 10:51:50 +08:00
parent 08d3b26a5d
commit 17fe9bf914

View File

@ -49,10 +49,6 @@ class Request(object):
self.response = None self.response = None
self.status = RequestStatus.ready self.status = RequestStatus.ready
self.json=None
def set_json(self, json_str: dict):
self.json=json_str
def __str__(self): def __str__(self):
if self.response is None: if self.response is None:
@ -65,7 +61,6 @@ class Request(object):
"headers: {}\n" "headers: {}\n"
"params: {}\n" "params: {}\n"
"data: {}\n" "data: {}\n"
"json: {}\n"
"response:" "response:"
"{}\n".format( "{}\n".format(
self.method, self.method,
@ -75,7 +70,6 @@ class Request(object):
self.headers, self.headers,
self.params, self.params,
self.data, self.data,
self.json,
"" if self.response is None else self.response.text, "" if self.response is None else self.response.text,
) )
) )
@ -151,7 +145,6 @@ class RestClient(object):
on_failed: Callable = None, on_failed: Callable = None,
on_error: Callable = None, on_error: Callable = None,
extra: Any = None, extra: Any = None,
json_str: dict = None,
): ):
""" """
Add a new request. Add a new request.
@ -177,8 +170,6 @@ class RestClient(object):
on_error, on_error,
extra, extra,
) )
if json_str is not None:
request.set_json(json_str)
self._queue.put(request) self._queue.put(request)
return request return request
@ -262,7 +253,6 @@ class RestClient(object):
headers=request.headers, headers=request.headers,
params=request.params, params=request.params,
data=request.data, data=request.data,
json=request.json,
proxies=self.proxies, proxies=self.proxies,
) )
request.response = response request.response = response