コード例 #1
0
ファイル: handlers.py プロジェクト: aiven/botocore
def escape_xml_payload(params, **kwargs):
    # Replace \r and \n with the escaped sequence over the whole XML document
    # to avoid linebreak normalization modifying customer input when the
    # document is parsed. Ideally, we would do this in ElementTree.tostring,
    # but it doesn't allow us to override entity escaping for text fields. For
    # this operation \r and \n can only appear in the XML document if they were
    # passed as part of the customer input.
    body = params['body']
    replaced = False
    if b'\r' in body:
        replaced = True
        body = body.replace(b'\r', b'
')
    if b'\n' in body:
        replaced = True
        body = body.replace(b'\n', b'
')

    if not replaced:
        return

    params['body'] = body
    if 'Content-MD5' in params['headers']:
        # The Content-MD5 is now wrong, so we'll need to recalculate it
        del params['headers']['Content-MD5']
        conditionally_calculate_md5(params, **kwargs)
コード例 #2
0
ファイル: serialize.py プロジェクト: karthik94940/Swiggy
 def _prepare_additional_traits(self, request, operation_model):
     """Determine if additional traits are required for given model"""
     if operation_model.http_checksum_required:
         conditionally_calculate_md5(request)
     return request
コード例 #3
0
 def _prepare_additional_traits_in_response(
         self, response: HttpResponse, operation_model: OperationModel):
     """Applies additional traits on the raw response for a given model or protocol."""
     if operation_model.http_checksum_required:
         conditionally_calculate_md5(response)
     return response