MCPcopy Create free account
hub / github.com/apache/mesos / _request

Method _request

src/python/lib/mesos/http.py:154–221  ·  view source on GitHub ↗

Make an HTTP request with given method and an optional timeout. :param method: request method :type method: str :param additional_headers: additional headers to include in the request :type additional_headers: dict[str, str] :param timeout: timeout i

(self,
                 method,
                 additional_headers=None,
                 timeout=None,
                 auth=None,
                 use_gzip_encoding=None,
                 params=None,
                 **kwargs)

Source from the content-addressed store, hash-verified

152 )
153
154 def _request(self,
155 method,
156 additional_headers=None,
157 timeout=None,
158 auth=None,
159 use_gzip_encoding=None,
160 params=None,
161 **kwargs):
162 """
163 Make an HTTP request with given method and an optional timeout.
164
165 :param method: request method
166 :type method: str
167 :param additional_headers: additional headers to include in the request
168 :type additional_headers: dict[str, str]
169 :param timeout: timeout in seconds
170 :type timeout: float
171 :param auth: auth scheme for request
172 :type auth: requests.auth.AuthBase
173 :param use_gzip_encoding: boolean indicating whether to
174 pass gzip encoding in the request
175 headers or not
176 :type use_gzip_encoding: boolean
177 :param params: additional params to include in the request
178 :type params: str | dict[str, T]
179 :param kwargs: additional arguments to pass to requests.request
180 :type kwargs: dict[str, T]
181 :return: HTTP response
182 :rtype: requests.Response
183 """
184 headers = self.default_headers()
185 if additional_headers is not None:
186 headers.update(additional_headers)
187
188 if timeout is None:
189 timeout = self.default_timeout
190
191 if auth is None:
192 auth = self.default_auth
193
194 if use_gzip_encoding is None:
195 use_gzip_encoding = self.default_use_gzip_encoding
196
197 if headers and use_gzip_encoding:
198 headers.update(REQUEST_GZIP_HEADERS)
199
200 kwargs.update(dict(
201 url=self.url.geturl(),
202 method=method,
203 headers=headers,
204 timeout=timeout,
205 auth=auth,
206 params=params,
207 ))
208
209 # Here we call request without a try..except block since all exceptions
210 # raised here will be used to determine whether or not a retry is
211 # necessary in self.request.

Callers

nothing calls this directly

Calls 5

default_headersMethod · 0.95
MesosHTTPExceptionClass · 0.90
updateMethod · 0.45
requestMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected