Skip to content

Commit db8c509

Browse files
committed
added web.Request.content and deprecated web.Request.payload
1 parent ad29c09 commit db8c509

File tree

3 files changed

+23
-2
lines changed

3 files changed

+23
-2
lines changed

aiohttp/web.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import json
1010
import re
1111
import os
12+
import warnings
1213

1314
from urllib.parse import urlsplit, parse_qsl, urlencode, unquote
1415
from types import MappingProxyType
@@ -283,7 +284,13 @@ def cookies(self):
283284

284285
@property
285286
def payload(self):
286-
"""Return raw paiload stream."""
287+
"""Return raw payload stream."""
288+
warnings.warn('use Request.content instead', DeprecationWarning)
289+
return self._payload
290+
291+
@property
292+
def content(self):
293+
"""Return raw payload stream."""
287294
return self._payload
288295

289296
@asyncio.coroutine

docs/web_reference.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,13 +131,25 @@ first positional parameter.
131131

132132
Read-only :class:`~aiohttp.multidict.MultiDictProxy` lazy property.
133133

134+
.. attribute:: content
135+
136+
A :class:`~aiohttp.streams.FlowControlStreamReader` instance,
137+
input stream for reading request's *BODY*.
138+
139+
Read-only property.
140+
134141
.. attribute:: payload
135142

136143
A :class:`~aiohttp.streams.FlowControlStreamReader` instance,
137144
input stream for reading request's *BODY*.
138145

139146
Read-only property.
140147

148+
.. warning::
149+
150+
Attribute :attr:`~Request.payload` is deprecated, please use
151+
:attr:`~Request.content` instead.
152+
141153
.. attribute:: content_type
142154

143155
Read-only property with *content* part of *Content-Type* header.

tests/test_web_request.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,9 @@ def test_ctor(self):
4545
# second call should return the same object
4646
self.assertIs(get, req.GET)
4747

48-
self.assertIs(self.payload, req.payload)
48+
with self.assertWarns(DeprecationWarning):
49+
self.assertIs(self.payload, req.payload)
50+
self.assertIs(self.payload, req.content)
4951
self.assertIs(self.transport, req.transport)
5052
self.assertTrue(req.keep_alive)
5153

0 commit comments

Comments
 (0)