def build_response(self, request): status_code = self.resp['status_code'] headers = self.resp['headers'] body = self.resp['body'] response = Response() response.status_code = status_code if 'content-type' not in headers: headers['content-type'] = 'text/xml' if 'content-length' not in headers: headers['content-length'] = len(body) response.raw = HTTPResponse( body=io.BytesIO(body), headers=headers, status=status_code, reason=CODE_TO_REASON[status_code], preload_content=False, decode_content=False ) response.reason = response.raw.reason # From the request response.url = request.url response.request = request response.connection = self return response
def build_response(self, request): status_code = self.resp['status_code'] headers = self.resp['headers'] body = self.resp['body'] response = Response() response.status_code = status_code if 'content-type' not in headers: headers['content-type'] = 'text/xml' if 'content-length' not in headers: headers['content-length'] = len(body) response.raw = HTTPResponse(body=io.BytesIO(body), headers=headers, status=status_code, reason=CODE_TO_REASON[status_code], preload_content=False, decode_content=False) response.reason = response.raw.reason # From the request response.url = request.url response.request = request response.connection = self return response