-
Notifications
You must be signed in to change notification settings - Fork 24.5k
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
[Fix] Android/Fetch
: Handle IOException when using fetch with HEAD method
#30072
Conversation
Fetch
: Handle IOException when using fetch with HEAD methodAndroid/Fetch
: Handle IOException when using fetch with HEAD method
Base commit: 0045621 |
Base commit: 0045621 |
public WritableMap toResponseData(Response response) throws IOException { | ||
byte[] data = {}; | ||
try { | ||
data = response.body().bytes(); |
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.
What if we want to process a 204 no content? this would still fail when u call bytes on a null body
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.
Changed! Thank you for your suggestions 😄 !
ReactAndroid/src/main/java/com/facebook/react/modules/blob/BlobModule.java
Outdated
Show resolved
Hide resolved
Co-authored-by: Lawrence Mouarkach <[email protected]>
This PR is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 7 days. |
This PR was closed because it has been stalled for 7 days with no activity. |
Summary
This pr fixes: #30055 .
Since fetch with HEAD method did not have body.
We should handle the error from Okhttp when it consuming the empty body.
Changelog
[Android] [Fixed] - HEAD requests with fetch should not be failed.
Test Plan
Please initiated a new project and replaced the app with the following code:
It should console warn the result instead of
Network request failed
.Thanks you so much for your code review!