Skip to content

Commit

Permalink
Logging form-data prior to processing form data.
Browse files Browse the repository at this point in the history
  • Loading branch information
jkeyes committed Dec 5, 2017
1 parent c00fdf7 commit 20672f3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
3 changes: 2 additions & 1 deletion stripe/api_requestor.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,8 @@ def request_raw(self, method, url, params=None, supplied_headers=None):

util.log_info('Request to Stripe api', method=method, path=abs_url)
util.log_debug(
'Post details', post_data=post_data, api_version=self.api_version)
'Post details',
post_data=encoded_params, api_version=self.api_version)

rbody, rcode, rheaders = self._client.request(
method, abs_url, headers, post_data)
Expand Down
10 changes: 10 additions & 0 deletions tests/test_api_requestor.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import datetime
import unittest2
import tempfile

from mock import Mock, ANY

Expand Down Expand Up @@ -475,6 +476,15 @@ def test_invalid_grant_error(self):
self.requestor.request,
'get', self.valid_path, {})

def test_raw_request_with_file_param(self):
test_file = tempfile.NamedTemporaryFile()
test_file.write('\u263A'.encode('utf-16'))
test_file.seek(0)
params = {'file': test_file, 'purpose': 'dispute_evidence'}
supplied_headers = {'Content-Type': 'multipart/form-data'}
self.mock_response('{}', 200)
self.requestor.request('post', '/v1/files', params, supplied_headers)


class DefaultClientTests(unittest2.TestCase):

Expand Down

0 comments on commit 20672f3

Please sign in to comment.