HEAD response from AWS in Android fails
See original GitHub issueVersion: 0.10.13
Requesting HEAD from AWS S3 should return the headers of an object. The headers contain Content-Length header which represents the size of the object.
And as it is known HEAD responses have no body.
Anyway in RNFetchBlobReq.java the HEAD response is handled as it would have body and in line 505 bytes() method is called:
byte[] b = resp.body().bytes();
And in okhttp3 an IOException is raised if Content-Length does not match the body length:
public final byte[] bytes() throws IOException {
long contentLength = contentLength();
if (contentLength > Integer.MAX_VALUE) {
throw new IOException("Cannot buffer entire body for content length: " + contentLength);
}
BufferedSource source = source();
byte[] bytes;
try {
bytes = source.readByteArray();
} finally {
Util.closeQuietly(source);
}
if (contentLength != -1 && contentLength != bytes.length) {
throw new IOException("Content-Length ("
+ contentLength
+ ") and stream length ("
+ bytes.length
+ ") disagree");
}
return bytes;
}
So this ruins pretty bad requesting metadata from AWS.
Issue Analytics
- State:
- Created 5 years ago
- Comments:6
Top Results From Across the Web
Error Responses - Amazon Simple Storage Service
Lists and describes the Amazon S3 error responses and their associated HTTP status codes.
Read more >HeadObject - Amazon Simple Storage Service
The HEAD action retrieves metadata from an object without returning the object itself. This action is useful if you're only interested in an...
Read more >HTTP 400 status code (Bad Request) - Amazon CloudFront
When the deployment is complete, the distribution's status changes to Deployed, and you should stop receiving the AuthorizationHeaderMalformed error responses.
Read more >Signing and authenticating REST requests
This topic explains authenticating requests using Signature Version 2. Amazon S3 now supports the latest Signature Version 4. This latest signature version ...
Read more >Resolve Access Denied errors from a CloudFront distribution ...
I'm using an Amazon Simple Storage Service (Amazon S3) bucket as the origin of my Amazon CloudFront distribution. I'm using the S3 REST...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@JofBigHealth Hey, so glad that I could help you out. 😃
This bug made me very frustrated back then and I researched and researched it until found that last resort like solution.
Really hope that it will get fixed some day, rn-fetch-blob is good stuff otherwise!
Hey @JofBigHealth / @sakarit,
I tried using your approach but I’m not getting any response back even though the server is sending back the response. Could you please help me out with it?