[Django] #18523: Add getvalue to HttpResponse

23 views
Skip to first unread message

Django

unread,
Jun 27, 2012, 3:36:14 AM6/27/12
to django-...@googlegroups.com
#18523: Add getvalue to HttpResponse
-----------------------------------------+------------------------
Reporter: claudep | Owner: nobody
Type: New feature | Status: new
Component: HTTP handling | Version: master
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 |
-----------------------------------------+------------------------
The !HttpResponse object can almost be used as another stream object.
Unfortunately, it doesn't offer the getvalue() method to be able to read
its content, hence requiring conditional code in some circonstances (see
#15197). What about adding it (!HttpResponse.getvalue() ===
!HttpResponse.content)?

--
Ticket URL: <https://code.djangoproject.com/ticket/18523>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Jul 7, 2012, 12:00:27 PM7/7/12
to django-...@googlegroups.com
#18523: Add getvalue to HttpResponse
-------------------------------+------------------------------------
Reporter: claudep | Owner: nobody
Type: New feature | Status: new
Component: HTTP handling | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+------------------------------------
Changes (by aaugustin):

* stage: Unreviewed => Accepted


Comment:

Good idea.

Do Python's docs provide a list of the methods that a "stream object" must
support? While we're there, we should also check that HttpRequest objects
support all the methods that make sense.

--
Ticket URL: <https://code.djangoproject.com/ticket/18523#comment:1>

Django

unread,
Jul 7, 2012, 12:35:09 PM7/7/12
to django-...@googlegroups.com
#18523: Add getvalue to HttpResponse
-------------------------------+------------------------------------
Reporter: claudep | Owner: nobody
Type: New feature | Status: new
Component: HTTP handling | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+------------------------------------

Comment (by claudep):

I think http://docs.python.org/library/io.html?highlight=stream#io.IOBase
lists basic API for streams.

--
Ticket URL: <https://code.djangoproject.com/ticket/18523#comment:2>

Django

unread,
Oct 8, 2013, 3:41:54 PM10/8/13
to django-...@googlegroups.com
#18523: Add getvalue to HttpResponse
-------------------------------+------------------------------------

Reporter: claudep | Owner: nobody
Type: New feature | Status: new
Component: HTTP handling | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+------------------------------------

Comment (by unaizalakain):

I would add the following attributes and methods:

- `HttpResponseBase.closed`: set to `False` in `__init__`, set to `True`
in `close()`
- `HttpResponseBase.writable()`: returns `False` because `write(content)`
raises an exception (should be changed to `IOError` BTW)
- `HttpResponseBase.writelines(lines)`: raises `IOError`
- `HttpResponseBase.tell()`: change it to raise `IOError`
- `HttpResponse.getvalue()`: returns `self.content`
- `HttpResponse.writelines(lines)`: writes each line with
`self.write(line)`

--
Ticket URL: <https://code.djangoproject.com/ticket/18523#comment:3>

Django

unread,
Apr 14, 2014, 1:24:40 PM4/14/14
to django-...@googlegroups.com
#18523: Add getvalue to HttpResponse
-------------------------------+------------------------------------
Reporter: claudep | Owner: Osmose
Type: New feature | Status: assigned

Component: HTTP handling | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+------------------------------------
Changes (by Osmose):

* owner: nobody => Osmose
* status: new => assigned
* has_patch: 0 => 1


Comment:

I submitted a PR with the changes mentioned in comment:3 here:
https://github.com/django/django/pull/2545

--
Ticket URL: <https://code.djangoproject.com/ticket/18523#comment:4>

Django

unread,
Aug 13, 2014, 9:27:17 AM8/13/14
to django-...@googlegroups.com
#18523: Add getvalue to HttpResponse
-------------------------------+------------------------------------
Reporter: claudep | Owner: Osmose
Type: New feature | Status: assigned
Component: HTTP handling | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-------------------------------+------------------------------------
Changes (by timgraham):

* needs_better_patch: 0 => 1


Comment:

There are some comments for improvement on the PR. Please uncheck "Patch
needs improvement" when you update it, thanks.

--
Ticket URL: <https://code.djangoproject.com/ticket/18523#comment:5>

Django

unread,
Aug 13, 2014, 9:54:39 AM8/13/14
to django-...@googlegroups.com
#18523: Add getvalue to HttpResponse
-------------------------------+------------------------------------
Reporter: claudep | Owner: Osmose
Type: New feature | Status: assigned
Component: HTTP handling | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-------------------------------+------------------------------------

Comment (by Osmose):

Will do, just having trouble finding a good time to work on this lately.
:D

--
Ticket URL: <https://code.djangoproject.com/ticket/18523#comment:6>

Django

unread,
Aug 22, 2014, 8:13:58 AM8/22/14
to django-...@googlegroups.com
#18523: Add getvalue to HttpResponse
-------------------------------+------------------------------------
Reporter: claudep | Owner: Osmose
Type: New feature | Status: assigned
Component: HTTP handling | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+------------------------------------
Changes (by Osmose):

* needs_better_patch: 1 => 0


Comment:

Updated branch with changes in response to feedback. :D

--
Ticket URL: <https://code.djangoproject.com/ticket/18523#comment:7>

Django

unread,
Aug 26, 2014, 9:06:44 PM8/26/14
to django-...@googlegroups.com
#18523: Add getvalue to HttpResponse
-------------------------------+------------------------------------
Reporter: claudep | Owner: Osmose
Type: New feature | Status: assigned
Component: HTTP handling | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-------------------------------+------------------------------------
Changes (by timgraham):

* needs_better_patch: 0 => 1


Comment:

There are some problems with the tests on Python 3.

--
Ticket URL: <https://code.djangoproject.com/ticket/18523#comment:8>

Django

unread,
Oct 30, 2014, 1:51:04 PM10/30/14
to django-...@googlegroups.com
#18523: Add getvalue to HttpResponse
-------------------------------+------------------------------------
Reporter: claudep | Owner: Osmose
Type: New feature | Status: assigned
Component: HTTP handling | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+------------------------------------
Changes (by timgraham):

* needs_better_patch: 1 => 0


--
Ticket URL: <https://code.djangoproject.com/ticket/18523#comment:9>

Django

unread,
Nov 3, 2014, 12:25:07 PM11/3/14
to django-...@googlegroups.com
#18523: Add getvalue to HttpResponse
-------------------------------------+-------------------------------------

Reporter: claudep | Owner: Osmose
Type: New feature | Status: assigned
Component: HTTP handling | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for
Has patch: 1 | checkin
Needs tests: 0 | Needs documentation: 0
Easy pickings: 0 | Patch needs improvement: 0
| UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by timgraham):

* stage: Accepted => Ready for checkin


--
Ticket URL: <https://code.djangoproject.com/ticket/18523#comment:10>

Django

unread,
Nov 3, 2014, 12:32:40 PM11/3/14
to django-...@googlegroups.com
#18523: Add getvalue to HttpResponse
-------------------------------------+-------------------------------------
Reporter: claudep | Owner: Osmose
Type: New feature | Status: closed

Component: HTTP handling | Version: master
Severity: Normal | Resolution: fixed

Keywords: | Triage Stage: Ready for
Has patch: 1 | checkin
Needs tests: 0 | Needs documentation: 0
Easy pickings: 0 | Patch needs improvement: 0
| UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham <timograham@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"ebc8e79cf3bdd42a99e91d6e679248d07097d3db"]:
{{{
#!CommitTicketReference repository=""
revision="ebc8e79cf3bdd42a99e91d6e679248d07097d3db"
Fixed #18523 -- Added stream-like API to HttpResponse.

Added getvalue() to HttpResponse to return the content of the response,
along with a few other methods to partially match io.IOBase.

Thanks Claude Paroz for the suggestion and Nick Sanford for review.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/18523#comment:11>

Reply all
Reply to author
Forward
0 new messages