Skip to content

Fix BufferedReader over a SocketIO to properly read the right amount#2409

Merged
coolreader18 merged 6 commits into
masterfrom
coolreader18/fix-http
Feb 3, 2021
Merged

Fix BufferedReader over a SocketIO to properly read the right amount#2409
coolreader18 merged 6 commits into
masterfrom
coolreader18/fix-http

Conversation

@coolreader18
Copy link
Copy Markdown
Member

This gets basic requests functionality working:

$ mkdir deps
$ pip install -t deps requests
<snip>
$ cd deps
$ rustpython
>>>>> import requests
>>>>> res = requests.get("http://httpbin.org/get")
>>>>> res.json()
{'args': {}, 'headers': {'Accept': '*/*', 'Accept-Encoding': 'gzip, deflate', 'Host': 'httpbin.org', 'User-Agent': 'python-requests/2.25.1', 'X-Amzn-Trace-Id': 'Root=1-600ce51d-187d27d01dae14c54f63f539'}, 'origin': '99.104.70.102', 'url': 'http://httpbin.org/get'}

I spent a lot of time debugging this, but I think the key thing that stopped it from hanging forever in SocketIO.readinto was fixing _io to use as_contiguous instead of obj_bytes, which wasn't taking the range of a memoryview into account, as well as changing a > to a >= in _io.

@coolreader18 coolreader18 force-pushed the coolreader18/fix-http branch 9 times, most recently from 9e25621 to 231b5d5 Compare January 29, 2021 16:42
@coolreader18 coolreader18 force-pushed the coolreader18/fix-http branch from 231b5d5 to 235c384 Compare January 29, 2021 17:47
Comment thread vm/src/stdlib/socket.rs Outdated
@coolreader18 coolreader18 force-pushed the coolreader18/fix-http branch from 03d0049 to 46ec578 Compare February 3, 2021 16:53
@coolreader18 coolreader18 force-pushed the coolreader18/fix-http branch from 46ec578 to 160505d Compare February 3, 2021 16:54
@coolreader18
Copy link
Copy Markdown
Member Author

The re tests are fixed on master

@coolreader18 coolreader18 merged commit 6d371ce into master Feb 3, 2021
@coolreader18 coolreader18 deleted the coolreader18/fix-http branch February 3, 2021 17:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants