-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
URL validation/access fixes #4695
Conversation
All the demos for this PR have been deployed at https://huggingface.co/spaces/gradio-pr-deploys/pr-4695-all-demos |
e5f04d7
to
500dc72
Compare
Nice improvements @akx! Could we just add some tests for this:
Should be good to merge then |
…t does); add is_http_url_like
Thank you very much @akx! |
Description
I was profiling things and noticed a whole lot of time was spent in
is_valid_url
and was pretty surprised that that function actually does HTTP requests if it can.This PR:
requests
session if it needs to do both HEAD + GETprobe_url
because that's more what it does, with a deprecation trampoline for possible external usersis_valid_url
was only used to check whether another function that does arequests
request should be called to the newis_http_url_like
function.While working on that I realized there were small bugs in
encode_url_to_base64
anddownload_tmp_copy_of_file
where they didn't check for the response status, and would thus happily end up writing e.g. an error page out.These changes are in the
gradio_client
library, but these functions are gratuitously used bygradio
itself.🎯 PRs Should Target Issues
This PR does not target an issue right now, sorry; this was just another small papercut sort of problem I could easily fix.