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)
| 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. |
nothing calls this directly
no test coverage detected