def test_s3_put_object_chunked_newlines(self):
    bucket_name = ('test-bucket-%s' % short_uid())
    object_key = 'data'
    self.s3_client.create_bucket(Bucket=bucket_name)
    body = 'Hello\r\n\r\n\r\n\r\n'
    headers = ('\n            Authorization: %s\n            Content-Type: audio/mpeg\n            X-Amz-Content-Sha256: STREAMING-AWS4-HMAC-SHA256-PAYLOAD\n            X-Amz-Date: 20190918T051509Z\n            X-Amz-Decoded-Content-Length: %s\n        ' % (aws_stack.mock_aws_request_headers('s3')['Authorization'], len(body)))
    headers = dict([[field.strip() for field in pair.strip().split(':', 1)] for pair in headers.strip().split('\n')])
    data = (('d;chunk-signature=af5e6c0a698b0192e9aa5d9083553d4d241d81f69ec62b184d05c509ad5166af\r\n' + '%s\r\n0;chunk-signature=f2a50a8c0ad4d212b579c2489c6d122db88d8a0d0b987ea1f3e9d081074a5937\r\n') % body)
    url = ('%s/%s/%s' % (config.TEST_S3_URL, bucket_name, object_key))
    req = PutRequest(url, to_bytes(data), headers)
    urlopen(req, context=ssl.SSLContext()).read()
    downloaded_object = self.s3_client.get_object(Bucket=bucket_name, Key=object_key)
    download_file_object = to_str(downloaded_object['Body'].read())
    self.assertEqual(len(str(download_file_object)), len(body))
    self.assertEqual(str(download_file_object), body)
    self._delete_bucket(bucket_name, [object_key])
def test_s3_put_object_chunked_newlines(self):
    bucket_name = ('test-bucket-%s' % short_uid())
    object_key = 'data'
    self.s3_client.create_bucket(Bucket=bucket_name)
    body = 'Hello\r\n\r\n\r\n\r\n'
    headers = ('\n            Authorization: %s\n            Content-Type: audio/mpeg\n            X-Amz-Content-Sha256: STREAMING-AWS4-HMAC-SHA256-PAYLOAD\n            X-Amz-Date: 20190918T051509Z\n            X-Amz-Decoded-Content-Length: %s\n        ' % (aws_stack.mock_aws_request_headers('s3')['Authorization'], len(body)))
    headers = dict([[field.strip() for field in pair.strip().split(':', 1)] for pair in headers.strip().split('\n')])
    data = (('d;chunk-signature=af5e6c0a698b0192e9aa5d9083553d4d241d81f69ec62b184d05c509ad5166af\r\n' + '%s\r\n0;chunk-signature=f2a50a8c0ad4d212b579c2489c6d122db88d8a0d0b987ea1f3e9d081074a5937\r\n') % body)
    url = ('%s/%s/%s' % (config.TEST_S3_URL, bucket_name, object_key))
    req = PutRequest(url, to_bytes(data), headers)
    urlopen(req, context=ssl.SSLContext()).read()
    downloaded_object = self.s3_client.get_object(Bucket=bucket_name, Key=object_key)
    download_file_object = to_str(downloaded_object['Body'].read())
    self.assertEqual(len(str(download_file_object)), len(body))
    self.assertEqual(str(download_file_object), body)
    self._delete_bucket(bucket_name, [object_key])