Merge pull request #1846 from 1122455801/rest_compatible_json_headers

[Add] rest_client的data参数增加其他格式支持
This commit is contained in:
vn.py 2019-06-25 10:28:15 +08:00 committed by GitHub
commit 72b28df57b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -6,7 +6,7 @@ from datetime import datetime
from enum import Enum
from multiprocessing.dummy import Pool
from queue import Empty, Queue
from typing import Any, Callable, Optional
from typing import Any, Callable, Optional, Union
import requests
@ -28,7 +28,7 @@ class Request(object):
method: str,
path: str,
params: dict,
data: dict,
data: Union[dict, str, bytes],
headers: dict,
callback: Callable = None,
on_failed: Callable = None,
@ -140,7 +140,7 @@ class RestClient(object):
path: str,
callback: Callable,
params: dict = None,
data: dict = None,
data: Union[dict, str, bytes] = None,
headers: dict = None,
on_failed: Callable = None,
on_error: Callable = None,
@ -152,7 +152,7 @@ class RestClient(object):
:param path:
:param callback: callback function if 2xx status, type: (dict, Request)
:param params: dict for query string
:param data: dict for body
:param data: Http body. If it is a dict, it will be converted to form-data. Otherwise, it will be converted to bytes.
:param headers: dict for headers
:param on_failed: callback function if Non-2xx status, type, type: (code, dict, Request)
:param on_error: callback function when catching Python exception, type: (etype, evalue, tb, Request)