MCPcopy Index your code
hub / github.com/dataforseo/PythonClient / request

Method request

dataforseo_client/rest.py:95–238  ·  view source on GitHub ↗

Perform requests. :param method: http request method :param url: http request url :param headers: http request headers :param body: request json body, for `application/json` :param post_params: request post parameters, `appl

(
        self,
        method,
        url,
        headers=None,
        body=None,
        post_params=None,
        _request_timeout=None
    )

Source from the content-addressed store, hash-verified

93 self.pool_manager = urllib3.PoolManager(**pool_args)
94
95 def request(
96 self,
97 method,
98 url,
99 headers=None,
100 body=None,
101 post_params=None,
102 _request_timeout=None
103 ):
104 """Perform requests.
105
106 :param method: http request method
107 :param url: http request url
108 :param headers: http request headers
109 :param body: request json body, for `application/json`
110 :param post_params: request post parameters,
111 `application/x-www-form-urlencoded`
112 and `multipart/form-data`
113 :param _request_timeout: timeout setting for this request. If one
114 number provided, it will be total request
115 timeout. It can also be a pair (tuple) of
116 (connection, read) timeouts.
117 """
118 method = method.upper()
119 assert method in [
120 'GET',
121 'HEAD',
122 'DELETE',
123 'POST',
124 'PUT',
125 'PATCH',
126 'OPTIONS'
127 ]
128
129 if post_params and body:
130 raise ApiValueError(
131 "body parameter cannot be used with post_params parameter."
132 )
133
134 post_params = post_params or {}
135 headers = headers or {}
136
137 timeout = None
138 if _request_timeout:
139 if isinstance(_request_timeout, (int, float)):
140 timeout = urllib3.Timeout(total=_request_timeout)
141 elif (
142 isinstance(_request_timeout, tuple)
143 and len(_request_timeout) == 2
144 ):
145 timeout = urllib3.Timeout(
146 connect=_request_timeout[0],
147 read=_request_timeout[1]
148 )
149
150 try:
151 # For `POST`, `PUT`, `PATCH`, `OPTIONS`, `DELETE`
152 if method in ['POST', 'PUT', 'PATCH', 'OPTIONS', 'DELETE']:

Callers 1

call_apiMethod · 0.80

Calls 3

ApiValueErrorClass · 0.90
ApiExceptionClass · 0.90
RESTResponseClass · 0.85

Tested by

no test coverage detected