HttpResponse methods difference

30 views
Skip to first unread message

Yarick Antonov

unread,
Aug 27, 2014, 8:48:16 PM8/27/14
to django...@googlegroups.com
What the difference between HttpResponse.Write(), HttpResponse.flush() and HttpResponse.tell() methods?

ma...@tubeards.com

unread,
Aug 28, 2014, 10:31:12 AM8/28/14
to django...@googlegroups.com
As you see in: https://github.com/django/django/blob/master/django/http/response.py#L370 all three methods have different usecases.

.write(string) <- adds content
.tell() <- returns the length of content
.flush() <- just passing, does nothing (since at lease v1.5)

Cheers

Collin Anderson

unread,
Aug 28, 2014, 10:33:55 AM8/28/14
to django...@googlegroups.com
It's the same as python file objects
write sends data to the response
flush makes sure the data you wrote is actually getting sent out, not just buffered for alter
tell tells you how much data you've read or written. is where are you in the "file"
Reply all
Reply to author
Forward
0 new messages