Skip to content
This repository has been archived by the owner on Sep 10, 2024. It is now read-only.

SpiffyTitles hangs if presented with a binary file link #111

Open
teh-mouses opened this issue Nov 9, 2018 · 2 comments
Open

SpiffyTitles hangs if presented with a binary file link #111

teh-mouses opened this issue Nov 9, 2018 · 2 comments

Comments

@teh-mouses
Copy link

teh-mouses commented Nov 9, 2018

Example - in a channel that my Limnoria bot with SpiffyTitles is running, a user can input the following:

http://217.182.215.117/radio/8010/psy.mp3

This causes the bot to hang for myself and other user, however one user seems to only get a 18 second hang. My workaround was to:

@config supybot.plugins.SpiffyTitles.linkMessageIgnorePattern /(.mp3+)$/

(Note: this does not happen if its just a .mp3 file, only if it's a live streaming mp3)

cottongin added a commit to cottongin/limnoria-plugins that referenced this issue Nov 9, 2018
fixes issue butterscotchstallion#111 (opening streaming URLs)
@progval
Copy link
Contributor

progval commented Nov 9, 2018

The issue is not that it's binary, it's that it never ends.

The cause is this line:

 request = requests.get(url, headers=headers, timeout=15, allow_redirects=True, verify=verify_ssl_certs)

To quote the doc:

timeout is not a time limit on the entire response download; rather, an exception is raised if the server has not issued a response for timeout seconds (more precisely, if no bytes have been received on the underlying socket for timeout seconds).

@cottongin
Copy link

Further from the doc:

By default, when you make a request, the body of the response is downloaded immediately. You can override this behaviour and defer downloading the response body until you access the Response.content attribute with the stream parameter:

tarball_url = 'https://github.com/requests/requests/tarball/master'
r = requests.get(tarball_url, stream=True)

At this point only the response headers have been downloaded and the connection remains open, hence allowing us to make content retrieval conditional

#112 fixes this

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

No branches or pull requests

3 participants