def __call__(self, environ, start_response): request = self._create_request(environ) request_mock = _RequestObjectProxy(request.prepare()) if request_mock.body is None: request_mock.body = "" response = self.adapter.match(request_mock) response = self._create_response(response) return response(environ, start_response)
def __call__(self, environ, start_response): request = self._create_request(environ) request.url = request.url.split("?")[0] request_mock = _RequestObjectProxy(request.prepare()) # if request_mock.body is None: if not (hasattr(request_mock, 'body')) or request_mock.body is None: request_mock.body = "{}" response = self.adapter.match(request_mock) response = self._create_response(response) return response(environ, start_response)
def send(self, request, **kwargs): request = _RequestObjectProxy(request, case_sensitive=self._case_sensitive, **kwargs) self._add_to_history(request) for matcher in reversed(self._matchers): try: resp = matcher(request) except Exception: request._matcher = weakref.ref(matcher) raise if resp is not None: request._matcher = weakref.ref(matcher) resp.connection = self return resp raise exceptions.NoMockAddress(request)
def send(self, request, **kwargs): request = _RequestObjectProxy(request, case_sensitive=self._case_sensitive, **kwargs) self._add_to_history(request) for matcher in reversed(self._matchers): try: resp = matcher(request) except Exception: request._matcher = weakref.ref(matcher) raise if resp is not None: request._matcher = weakref.ref(matcher) resp.connection = self logger.debug('{} {} {}'.format(request._request.method,request._request.url, resp.status_code)) return resp raise exceptions.NoMockAddress(request)