#7581: Middleware accessing HttpResponse.content breaks streaming HttpResponse objects. -------------------------------------+------------------------------------- Reporter: mrmachine | Owner: ccahoon Type: New feature | Status: new Component: Core (Other) | Version: master Severity: Normal | Resolution: Keywords: stream HttpResponse | Triage Stage: Accepted Content-Length | Needs documentation: 0 Has patch: 1 | Patch needs improvement: 0 Needs tests: 0 | UI/UX: 0 Easy pickings: 0 | -------------------------------------+-------------------------------------
Comment (by mrmachine): I assume you meant `process_response()` and `process_streaming_response()` methods for middleware classes? I think this would be much nicer to work with, and easier to explain to middleware authors than asking them to do `hasattr(response, 'streaming_content')`. But it would mean a little more work to refactor some of the bundled middleware classes. One thing you didn't mention is automatically closing file-like objects passed as content to regular and streaming responses. For streaming responses, Django should close them automatically, because users won't be able to. I think that we should do the same for regular responses as well for consistency and to avoid accidentally leaving files open. I'm not sure if this would be a backwards incompatible change, or if it would need a deprecation path, or if a deprecation path would be possible? I guess this could be implemented separately, if it decided to go ahead. -- Ticket URL: <https://code.djangoproject.com/ticket/7581#comment:37> Django <https://code.djangoproject.com/> The Web framework for perfectionists with deadlines. -- You received this message because you are subscribed to the Google Groups "Django updates" group. To post to this group, send email to django-updates@googlegroups.com. To unsubscribe from this group, send email to django-updates+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.