Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow binary data in OAuth1Session.request #201

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions AUTHORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,5 @@ Add yourself as a contributor!
* [Tatsuji Tsuchiya](https://github.com/ta2xeo)
* [Chris McGraw](https://github.com/mitgr81)
* [Ken Koontz](https://github.com/kennethkoontz)
* [Markus Leuthold](https://github.com/githubkusi)
* (your name here)
3 changes: 2 additions & 1 deletion rauth/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,8 @@ def _parse_optional_params(self, oauth_params, req_kwargs):
for oauth_param in OPTIONAL_OAUTH_PARAMS:
if oauth_param in params:
oauth_params[oauth_param] = params.pop(oauth_param)
if oauth_param in data:

if type(data) is not bytes and oauth_param in data:
oauth_params[oauth_param] = data.pop(oauth_param)

if params:
Expand Down
7 changes: 7 additions & 0 deletions tests/test_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,13 @@ def test_request_with_optional_data_as_string(self, mock_request):
r = self.session.request('POST', 'http://example.com/', data=data)
self.assert_ok(r)

@patch.object(requests.Session, 'request')
def test_request_with_optional_data_as_binary(self, mock_request):
mock_request.return_value = self.response
data = bytes(1)
r = self.session.request('POST', 'http://example.com/', data=data)
self.assert_ok(r)

@patch.object(requests.Session, 'request')
def test_request_with_optional_params_with_data(self, mock_request):
mock_request.return_value = self.response
Expand Down