コード例 #1
0
ファイル: s3mock.py プロジェクト: mozilla/antenna
    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
コード例 #2
0
ファイル: s3mock.py プロジェクト: jinyongjie/antenna
    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