diff --git a/hoover/utils.py b/hoover/utils.py index bdf87b1..441f42f 100644 --- a/hoover/utils.py +++ b/hoover/utils.py @@ -22,8 +22,14 @@ def newfunc(*args, **kwargs): return wraps(func)(newfunc) -def post_to_endpoint(endpoint, message): +def post_to_endpoint(endpoint, message, encoding='utf-8'): h = Http() + # If unicode, try to encode + if isinstance(message, unicode): + try: + message = message.encode(encoding) + except UnicodeEncodeError: + pass h.request(endpoint, 'POST', message) async_post_to_endpoint = async(post_to_endpoint)