-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Added Asynchronous Features To Close Issue #1637 #2469
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
base: main
Are you sure you want to change the base?
Conversation
- Modified the authentication to integrate asynchronous functionality - Modified the where HttpRequest is called to AsyncHttpRequest class Co-authored-by: Kyongsu Kang Co-authored-by: Lizzy Zhou
Co-Author-By: Kyongsu Kang Co-Author-By: Lizzy Zhou
Co-Authored by: Kyongsu Kang Co-Authored by: Lizzy Zhou
if resp.status == 200 and "location" in resp.headers: #Potential Tech Issue problem | ||
self.resumable_uri = resp.headers["location"] #Potential Tech Issue problem | ||
else: | ||
raise ResumableUploadError(resp, content) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✨ AI Suggestion: Directly accessing resp.headers["location"]
can lead to a KeyError
if the header is unexpectedly missing, even if the status code is 200. Use the .get()
method for safer access and raise a more specific error if the essential header is absent.
if resp.status == 200 and "location" in resp.headers: #Potential Tech Issue problem | |
self.resumable_uri = resp.headers["location"] #Potential Tech Issue problem | |
else: | |
raise ResumableUploadError(resp, content) | |
location = resp.headers.get("location") | |
if resp.status == 200 and location: | |
self.resumable_uri = location | |
else: | |
# Raise error if status is 200 but location is missing, or if status is not 200 | |
raise ResumableUploadError( | |
resp, content, message="Missing 'location' header in resumable URI response." | |
) |
# If resp doesn't contain range header, resumable progress is 0 | ||
self.resumable_progress = 0 | ||
if "location" in resp: | ||
self.resumable_uri = resp.headers["location"] #Potential Tech Issue problem |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✨ AI Suggestion: Directly accessing resp.headers["location"]
after a 308 response can lead to a KeyError
if the header is missing. Use .get()
for safer access to prevent potential runtime errors.
# If resp doesn't contain range header, resumable progress is 0 | |
self.resumable_progress = 0 | |
if "location" in resp: | |
self.resumable_uri = resp.headers["location"] #Potential Tech Issue problem | |
except KeyError: | |
# If resp doesn't contain range header, resumable progress is 0 | |
self.resumable_progress = 0 | |
# Use .get() for safer access to the location header | |
location = resp.headers.get("location") | |
if location: | |
self.resumable_uri = location |
We have added asynchronous features for HTTP requests, authentication, as well as completed some of the checklist below:
Fixes #<1637> 🦕