Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop streamreader payload #2558

Merged
merged 4 commits into from
Nov 25, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES/2257.removal
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Drop `StreamReaderPayload` and `DataQueuePayload`.
30 changes: 2 additions & 28 deletions aiohttp/payload.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import asyncio
import io
import json
import mimetypes
Expand All @@ -11,11 +10,11 @@
from . import hdrs
from .helpers import (content_disposition_header, guess_filename,
parse_mimetype, sentinel)
from .streams import DEFAULT_LIMIT, DataQueue, EofStream, StreamReader
from .streams import DEFAULT_LIMIT


__all__ = ('PAYLOAD_REGISTRY', 'get_payload', 'payload_type', 'Payload',
'BytesPayload', 'StringPayload', 'StreamReaderPayload',
'BytesPayload', 'StringPayload',
'IOBasePayload', 'BytesIOPayload', 'BufferedReaderPayload',
'TextIOPayload', 'StringIOPayload', 'JsonPayload')

Expand Down Expand Up @@ -263,28 +262,6 @@ def size(self):
return None


class StreamReaderPayload(Payload):

async def write(self, writer):
chunk = await self._value.read(DEFAULT_LIMIT)
while chunk:
await writer.write(chunk)
chunk = await self._value.read(DEFAULT_LIMIT)


class DataQueuePayload(Payload):

async def write(self, writer):
while True:
try:
chunk = await self._value.read()
if not chunk:
break
await writer.write(chunk)
except EofStream:
break


class JsonPayload(BytesPayload):

def __init__(self, value,
Expand All @@ -305,6 +282,3 @@ def __init__(self, value,
PAYLOAD_REGISTRY.register(
BufferedReaderPayload, (io.BufferedReader, io.BufferedRandom))
PAYLOAD_REGISTRY.register(IOBasePayload, io.IOBase)
PAYLOAD_REGISTRY.register(
StreamReaderPayload, (asyncio.StreamReader, StreamReader))
PAYLOAD_REGISTRY.register(DataQueuePayload, DataQueue)
21 changes: 0 additions & 21 deletions tests/test_client_functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -2481,24 +2481,3 @@ def connection_lost(self, exc):
connector.close()
server.close()
await server.wait_closed()


@pytest.mark.xfail
async def test_stream_reader(test_client):
DATA = b'1234567890' * (2**16)

async def h1(request):
return web.Response(body=DATA)

async def h2(request):
async with aiohttp.ClientSession() as sess:
async with sess.get(client.make_url('/h1')) as resp:
return web.Response(body=resp.content)

app = web.Application()
app.router.add_get('/h1', h1)
app.router.add_get('/h2', h2)

client = await test_client(app)
resp = await client.get('/h2')
assert await resp.read() == DATA
14 changes: 0 additions & 14 deletions tests/test_web_functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -1641,17 +1641,3 @@ async def handler(request):

with pytest.warns(DeprecationWarning):
await client.get('/')


async def test_stream_reader(test_client):
DATA = b'1234567890' * (2**16)

async def handler(request):
return web.Response(body=request.content)

app = web.Application()
app.router.add_post('/', handler)

client = await test_client(app)
resp = await client.post('/', data=DATA)
assert await resp.read() == DATA