{"action":"opened","issue":{"url":"https://api.github.com/repos/celery/celery/issues/2499","labels_url":"https://api.github.com/repos/celery/celery/issues/2499/labels{/name}","comments_url":"https://api.github.com/repos/celery/celery/issues/2499/comments","events_url":"https://api.github.com/repos/celery/celery/issues/2499/events","html_url":"https://github.com/celery/celery/issues/2499","id":57414505,"number":2499,"title":"`celery.http_dispatch` always fail due to celery trying to handle bytes as string","user":{"login":"clarkorz","id":3261477,"avatar_url":"https://avatars.githubusercontent.com/u/3261477?v=3","gravatar_id":"","url":"https://api.github.com/users/clarkorz","html_url":"https://github.com/clarkorz","followers_url":"https://api.github.com/users/clarkorz/followers","following_url":"https://api.github.com/users/clarkorz/following{/other_user}","gists_url":"https://api.github.com/users/clarkorz/gists{/gist_id}","starred_url":"https://api.github.com/users/clarkorz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/clarkorz/subscriptions","organizations_url":"https://api.github.com/users/clarkorz/orgs","repos_url":"https://api.github.com/users/clarkorz/repos","events_url":"https://api.github.com/users/clarkorz/events{/privacy}","received_events_url":"https://api.github.com/users/clarkorz/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-02-12T03:59:30Z","updated_at":"2015-02-12T03:59:30Z","closed_at":null,"body":"Hi, I'm trying celery as tasks distributor for my nodejs project. I create a minimal celery project which only imports `celery.task.http` module. \r\n\r\n```js\r\n// will be exposed to route /api/tasks/status\r\nTask.status = function (callback) {\r\n    callback(null, { status: 'success', retval: 'hello' });\r\n  };\r\n\r\n// call task using node-celery\r\nvar task = client.createTask('celery.http_dispatch');\r\nvar result = task.call([], { url: 'http://172.16.208.1:3000/api/tasks/status', method: 'GET' });\r\n```\r\n```\r\ncurl http://172.16.208.1:3000/api/tasks/status\r\n{\"status\":\"success\",\"retval\":\"hello\"}\r\ncurl -I http://172.16.208.1:3000/api/tasks/status\r\nHTTP/1.1 200 OK\r\nX-Powered-By: Express\r\nVary: Origin, Accept-Encoding\r\nAccess-Control-Allow-Credentials: true\r\nContent-Type: application/json; charset=utf-8\r\nContent-Length: 37\r\nETag: W/\"25-d3757658\"\r\nDate: Thu, 12 Feb 2015 03:45:48 GMT\r\nConnection: keep-alive\r\n```\r\n\r\nThe web hook is executed successfully but celery fail to parse the json response.\r\n\r\n```\r\ncelery -A default worker -l DEBUG\r\n...\r\n[2015-02-07 12:05:42,004: INFO/MainProcess] Received task: celery.http_dispatch[329a1353-f2e8-40db-bd02-89d66dbe1386]\r\n[2015-02-07 12:05:42,004: DEBUG/MainProcess] TaskPool: Apply <function _fast_trace_task at 0x7f8e513e3400> (args:('celery.http_dispatch', '329a1353-f2e8-40db-bd02-89d66dbe1386', [], {'url': 'http://172.16.208.1:3000/api/tasks/status', 'method': 'GET'}, {'args': [], 'headers': {}, 'is_eager': False, 'kwargs': {'url': 'http://172.16.208.1:3000/api/tasks/status', 'method': 'GET'}, 'task': 'celery.http_dispatch', 'id': '329a1353-f2e8-40db-bd02-89d66dbe1386', 'delivery_info': {'redelivered': False, 'routing_key': 'celery', 'priority': None, 'exchange': ''}, 'hostname': 'celery@clarkorz', 'reply_to': None, 'group': None, 'correlation_id': None}) kwargs:{})\r\n[2015-02-07 12:05:42,010: DEBUG/MainProcess] Task accepted: celery.http_dispatch[329a1353-f2e8-40db-bd02-89d66dbe1386] pid:48307\r\n[2015-02-07 12:05:42,027: ERROR/MainProcess] Task celery.http_dispatch[329a1353-f2e8-40db-bd02-89d66dbe1386] raised unexpected: TypeError('initial_value must be str or None, not bytes',)\r\nTraceback (most recent call last):\r\n  File \"/opt/celery/lib/python3.4/site-packages/celery/app/trace.py\", line 240, in trace_task\r\n    R = retval = fun(*args, **kwargs)\r\n  File \"/opt/celery/lib/python3.4/site-packages/celery/app/trace.py\", line 438, in __protected_call__\r\n    return self.run(*args, **kwargs)\r\n  File \"/opt/celery/lib/python3.4/site-packages/celery/task/http.py\", line 190, in dispatch\r\n    ).dispatch()\r\n  File \"/opt/celery/lib/python3.4/site-packages/celery/task/http.py\", line 157, in dispatch\r\n    return extract_response(raw_response)\r\n  File \"/opt/celery/lib/python3.4/site-packages/celery/task/http.py\", line 70, in extract_response\r\n    payload = loads(raw_response)\r\n  File \"/opt/celery/lib/python3.4/site-packages/anyjson/__init__.py\", line 135, in loads\r\n    return implementation.loads(value)\r\n  File \"/opt/celery/lib/python3.4/site-packages/anyjson/__init__.py\", line 98, in loads\r\n    return self._filedecode(StringIO(s))\r\nTypeError: initial_value must be str or None, not bytes\r\n```\r\n\r\nI'm not familiar with python or celery, but I think `StringIO` only accepts string, so `raw_response` is a bytes array and should be decoded to a string."}}