From dbf1deb4e0d030d944cfab7d6543e92805c6d0f2 Mon Sep 17 00:00:00 2001 From: Ritesh Kadmawala Date: Sun, 31 May 2015 13:12:26 +0530 Subject: [PATCH] Convert any data to be posted to buffer api to utf-8 encoding --- buffpy/api.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/buffpy/api.py b/buffpy/api.py index 92e755e..cca7a28 100644 --- a/buffpy/api.py +++ b/buffpy/api.py @@ -54,6 +54,11 @@ def post(self, url, parser=None, **params): headers = {'Content-Type': 'application/x-www-form-urlencoded'} + #Check if posting data and if data is unicode, encoding it as utf-8 + if 'data' in params and isinstance(params['data'], unicode): + params['data'] = params['data'].encode('utf-8') + + response = self.session.post(url=BASE_URL % url, headers=headers, **params) return parser(response.content)