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

Properly handle requests that do multiple writes (e.g. by aiohttp 3) #66

Closed
sjaensch opened this issue Feb 19, 2018 · 7 comments
Closed

Comments

@sjaensch
Copy link

sjaensch commented Feb 19, 2018

The aiohttp client in version 3 does (at least) two writes if the request has a body: one for the headers, a second for the body. This was done in aio-libs/aiohttp#2126 and is documented in the "Are there changes in behavior for the user?" section of the description. Check out the diff of the write_headers function.

With mocket, this is not handled correctly. The body is lost. Would it be possible to implement proper handling of this scenario?

Example test failures: https://travis-ci.org/sjaensch/aiobravado/jobs/343058521

Test 1 source
Test 2 source

@mindflayer
Copy link
Owner

Thank you very much for the contribution. I'll have a look at that as soon as possible.

@mindflayer
Copy link
Owner

mindflayer commented Feb 24, 2018

Hi @sjaensch, I did pip install -U aiohttp ending up with a virtualenv using version aiohttp-3.0.2 and I was able to run all the Mocket tests. Also, if I look at the two failing tests in your code, I don't see you actually enabled Mocket as I do at this line:
https://github.com/mindflayer/python-mocket/blob/master/tests/tests35/test_http_aiohttp.py#L60
Am I missing something?

@mindflayer mindflayer added the not sure Pleae provide more information label Feb 24, 2018
@sjaensch
Copy link
Author

@mindflayer Mocket is enabled with this fixture: https://github.com/sjaensch/aiobravado/blob/dfacf2655053f765d832f50adff4659a79a3063d/tests/functional/conftest.py#L74

There are several other tests that use Mocket and continue to pass. Note that the two tests in question also pass if you use aiohttp<3.0. The fact that Mocket tests pass with aiohttp 3.0.2 tells me that this case is not covered by your tests. :)

All of your aiohttp tests do simple GET requests. Make sure you do a request that contains a body, so typically a POST request with some data. The aiobravado tests that do GET requests are still passing as well with aiohttp 3.0. As I explained in the description, aiohttp 3 does two network writes: One for the request headers, one for the request body. GET requests usually do not have a request body.

@mindflayer mindflayer added enhancement and removed not sure Pleae provide more information labels Feb 25, 2018
@mindflayer
Copy link
Owner

Hi @sjaensch, could you try to run your tests using this branch (https://github.com/mindflayer/python-mocket/tree/body-via-send)?

@sjaensch
Copy link
Author

@mindflayer awesome! Both tests pass if I use that branch, well done!

@mindflayer
Copy link
Owner

I've seen you have another failing test apparently related to Mocket, feel free to file another issue with some information.

@mindflayer
Copy link
Owner

Here you are: https://pypi.python.org/pypi/mocket/2.2.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants