Re: [Django] #30694: FileResponse does not seek its file source

2019-08-12 Thread Django
#30694: FileResponse does not seek its file source
---+--
 Reporter:  Claude Paroz   |Owner:  nobody
 Type:  Bug|   Status:  closed
Component:  HTTP handling  |  Version:  2.2
 Severity:  Normal |   Resolution:  wontfix
 Keywords: | Triage Stage:  Unreviewed
Has patch:  0  |  Needs documentation:  0
  Needs tests:  0  |  Patch needs improvement:  0
Easy pickings:  0  |UI/UX:  0
---+--
Changes (by Carlton Gibson):

 * status:  new => closed
 * resolution:   => wontfix


Comment:

 Hi Claude.

 > ...shouldn't FileResponse seek itself ...

 I think not here.

 I imagine a situation where you want to tail a log, say. You can't do that
 if we reset the stream position ourselves.

 I then think that resetting the stream makes `FileResponse` a little bit
 too clever. (Happy if someone wants to put that in a subclass, but it's
 beyond "take a buffer, stream it to an HTTP response", which is what I
 take to be the limit of the scope here.)

 So, for me, the maxim in play is, "You pass an open file. Your
 responsibility to `seek` accordingly".

 As such, I'm going to go with `wontfix`. I hope that makes sense.

 **Maybe** an addition to the FileResponse docs?

 > ...`streaming_content` begins from the current cursor position of
 `open_file`...

 (Or such, somewhere.)

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/065.9d1e68295affdcda8730cea52c487828%40djangoproject.com.


[Django] #30694: FileResponse does not seek its file source

2019-08-10 Thread Django
#30694: FileResponse does not seek its file source
-+
   Reporter:  Claude Paroz   |  Owner:  nobody
   Type:  Bug| Status:  new
  Component:  HTTP handling  |Version:  2.2
   Severity:  Normal |   Keywords:
   Triage Stage:  Unreviewed |  Has patch:  0
Needs documentation:  0  |Needs tests:  0
Patch needs improvement:  0  |  Easy pickings:  0
  UI/UX:  0  |
-+
 I'm not sure this is a bug, but I was bitten by some code today:

 {{{
 buffer = io.BytesIO()
 buffer.write(b'some binary content')
 return FileResponse(buffer, filename='somename.bin')
 }}}
 and the response is empty because the stream position is at the end of the
 buffer. I can easily fix that by seeking the buffer myself, but shouldn't
 `FileResponse` seek itself in `_set_streaming_content` before calling
 `filelike.read`?

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/050.868d5f3ce013a3ddf0d61f664826ccc0%40djangoproject.com.