I want to read a raw HTTP request in Django 1.3.
Is there an easy way to do it?
I tried the following without success:
clength = int(request.META.get("CONTENT_LENGTH"))
data = request.read(1000)
# data comes out empty
Also tried:
for part in request:
pass
# never enters the loop
The reason I am doing this is because somehow my raw_post_data
attribute is empty when using multipart/related
MIME information on the POST
command. Apparently is a bug that's been there for a long time.
For django version < 1.4, you can use HttpRequest.raw_post_data
, and for version >= 1.4, using HttpRequest.body
instead.
Have you tried HttpRequest.raw_post_data? Looks like something you should take a look at until the bug is fixed. https://docs.djangoproject.com/en/1.3/ref/request-response/#django.http.HttpRequest.raw_post_data
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With