ask/celery — pull request #515 by mitar (2011-11-01 04:06:49+00:00)
Title: Fixed HTTP POST requests.

HTTP POST requests do not really work. At least Django is not able to parse them properly (even request.raw_post_data is empty). There are few reasons for that but main is that headers have been set explicitly so urllib2 has not populate them itself. For example, content-length is one of such missing.

Also some non-documented internals have been used to manipulate headers. Public API provides only ``request.add_header``.

I have changed code so that Celery headers are added after urllib2 populates its own. ``Content-Type`` is changed to ``application/x-www-form-urlencoded`` which in fact correct as payload is urlencoded and not JSON encoded.

Request before my changes looked like this:

POST /foo/ HTTP/1.0
Host: localhost:8080
Content-Type: application/json
User-Agent: celery/2.4.0rc1
Content-type: application/json
User-agent: celery/2.4.0rc1

Yes, headers were doubled.

Now they look like this:

POST /foo/ HTTP/1.0
Content-type: application/x-www-form-urlencoded
Content-length: 411
Host: localhost:8080
User-agent: celery/2.4.0rc1