AssertionError: Cannot read more than the available bytes from the HTTP incoming data.

188 views
Skip to first unread message

Patrick Kranzlmueller

unread,
May 24, 2013, 5:20:35 AM5/24/13
to django-res...@googlegroups.com
I know that this is not related to django–rest–framework, but I guess someone here may have dealt with this issue already.

I'm building a simple test case for my app with trying to POST xml–data. And when I'm running the test case I get the above message.

Tom Christie

unread,
May 24, 2013, 5:32:36 AM5/24/13
to django-res...@googlegroups.com
Hi Patrick,

I don't know if it will help any, but it sounds like a malformed request.
Presumably the Content-Length header is reporting more bytes than are actually present in the request body.

Cheers,

  Tom

patrick kranzlmueller

unread,
May 24, 2013, 5:43:46 AM5/24/13
to django-res...@googlegroups.com
this may be a dump question, but how can I check content-length resp. length of the request body?
it seems that content-length is not being set ... do I need to set that manually with an xml–request?

thx,
patrick



2013/5/24 Tom Christie <christ...@gmail.com>

--
You received this message because you are subscribed to a topic in the Google Groups "Django REST framework" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/django-rest-framework/rLKow4Kx5ZM/unsubscribe?hl=en-US.
To unsubscribe from this group and all its topics, send an email to django-rest-fram...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Patrick Kranzlmueller

unread,
May 24, 2013, 6:09:46 AM5/24/13
to django-res...@googlegroups.com
funny thing is, if I add
print "SOURCE:", source
to line 99 in defuxedxml/common.py it works.
Message has been deleted

Patrick Kranzlmueller

unread,
May 24, 2013, 8:20:46 AM5/24/13
to django-res...@googlegroups.com
if anyone else runs into this, changing wsgi.input from FakePayLoad to StringIO solved the problem.

kwargs['wsgi.input'] = StringIO(data)

I'm pretty sure this is not a decent solution though.

Tom Christie

unread,
May 24, 2013, 8:55:43 AM5/24/13
to django-res...@googlegroups.com
Patrick,

  I expect you're bumping into a Django 1.3 bug #15785.  (Also discussed on the mailing list, here)
One of the aspects of that bug is that `request.read(9999999)` will raise an assertion error when used against the test client,
rather than simply returning all the remaining stream.  It's fixed in 1.4.  (Randomly, that was my first contribution to core Django.)

  Another way for this error to occur might be if you're overriding the test client and instantiating the dummy request incorrectly.

  I guess it's one of those two things.

Cheers,

  Tom

patrick kranzlmueller

unread,
May 24, 2013, 9:04:21 AM5/24/13
to django-res...@googlegroups.com
Hi Tom,

in my case it's probably the 1.3 bug you've mentioned since I tested with the default test client as well.

Thanks,
Patrick



2013/5/24 Tom Christie <christ...@gmail.com>

--
Reply all
Reply to author
Forward
0 new messages