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

StreamWriter appends not wanted information. #475

Closed
MatthiasSchild opened this issue Aug 27, 2015 · 4 comments
Closed

StreamWriter appends not wanted information. #475

MatthiasSchild opened this issue Aug 27, 2015 · 4 comments
Labels
Milestone

Comments

@MatthiasSchild
Copy link

I'm currently working on a mjpeg proxy server with aiohttp. I use the StreamWriter to transmit the information. But if I'm using

sr.write(b"x")
sr.write(b"y")
sr.write(b"z")

the StreamResponse appends the length of the chunk with a newline

x1\r\ny1\r\nz1\r\n

Is there a posibility to send raw data?


EDIT:

I wrote StreamWriter, but i mean StreamResponse.
I've found out that the StreamResponse uses the chunked transfer encoding and those "not wanted information" are part of it.

@asvetlov
Copy link
Member

Would you provide a test that reproduces your problem?

I've wrote one:

    def test_stream_response_multiple_chunks(self):
        @asyncio.coroutine
        def handler(request):
            resp = web.StreamResponse()
            resp.start(request)
            resp.write(b'x')
            resp.write(b'y')
            resp.write(b'z')
            return resp

        @asyncio.coroutine
        def go():
            _, srv, url = yield from self.create_server('GET', '/', handler)
            client = ClientSession(loop=self.loop)
            resp = yield from client.get(url)
            self.assertEqual(200, resp.status)
            data = yield from resp.read()
            self.assertEqual(b'xyz', data)
            yield from resp.release()

        self.loop.run_until_complete(go())

and it works as expeced.

@asvetlov asvetlov added this to the 0.18 milestone Sep 1, 2015
@vbraun
Copy link

vbraun commented Sep 4, 2015

I think this is the same as #476, chunked transfer requires a HTTP/1.1 client to make sense of the reply

@asvetlov
Copy link
Member

asvetlov commented Sep 4, 2015

Perhaps yes. Let's close the issue.

@asvetlov asvetlov closed this as completed Sep 4, 2015
@lock
Copy link

lock bot commented Oct 29, 2019

This thread has been automatically locked since there has not been
any recent activity after it was closed. Please open a new issue for
related bugs.

If you feel like there's important points made in this discussion,
please include those exceprts into that new issue.

@lock lock bot added the outdated label Oct 29, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Oct 29, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants