def _make_request(self, url, method, payload={}, headers={}): """ A wrapper around httplib2.Http.request. Required Arguments: url The url of the request. method The method of the request. I.e. 'GET', 'PUT', 'POST', 'DELETE'. Optional Arguments: payload The urlencoded parameters. headers Additional headers of the request. """ try: return self._get_http().request(url, method, payload, headers=headers) except socket.error as e: # Try again just in case there was an issue with the cached _http try: self._clear_http() return self._get_http().request(url, method, payload, headers=headers) except socket.error as e: raise exc.dRestAPIError(e.args[1])
def _make_request(self, url, method, payload={}, headers={}): """ A wrapper around httplib2.Http.request. Required Arguments: url The url of the request. method The method of the request. I.e. 'GET', 'PUT', 'POST', 'DELETE'. Optional Arguments: payload The urlencoded parameters. headers Additional headers of the request. """ try: if self._meta.ignore_ssl_validation: http = Http(disable_ssl_certificate_validation=True) else: http = Http() if self._auth_credentials: http.add_credentials(self._auth_credentials[0], self._auth_credentials[1]) return http.request(url, method, payload, headers=headers) except socket.error as e: raise exc.dRestAPIError(e.args[1])
def auth(self, *args, **kw): """ Authenticate the request, determined by Meta.auth_mech. Arguments and Keyword arguments are just passed to the auth_mech function. """ if self._meta.auth_mech in self.auth_mechanizms: func = getattr(self, '_auth_via_%s' % self._meta.auth_mech) func(*args, **kw) else: raise exc.dRestAPIError("Unknown TastyPie auth mechanism.")
def auth(self, *args, **kw): """ Authenticate the request, determined by Meta.auth_mech. Arguments and Keyword arguments are just passed to the auth_mech function. """ if self._meta.auth_mech in self._meta.auth_mechanizms: func = getattr(self, '_auth_via_%s' % self._meta.auth_mech) func(*args, **kw) else: raise exc.dRestAPIError("Unknown TastyPie auth mechanism.")