ipfs-api-kotlin icon indicating copy to clipboard operation
ipfs-api-kotlin copied to clipboard

change get api deal with the 500 code

Open ghost opened this issue 6 years ago • 0 comments

If you cat a wrong hash, the ipfs http api will response code 500 and with message. In this case if we use the response boy and cover it to stream or byte ,it will not the true content of the hash code,it will be the content of the 'Wrong Message'.

So we need check the response code by {response.isSuccessful} to insure we go the right response.

OKHTTP: <-- 500 Internal Server Error http://127.0.0.1:5001/api/v0/cat/QmZC6gALejeRt2TAHHMnEkcEXeyX3XUSZ4yRkpt43UkM5A?timeout=30s (30002ms) OKHTTP: Access-Control-Allow-Headers: X-Stream-Output, X-Chunked-Output, X-Content-Length OKHTTP: Access-Control-Expose-Headers: X-Stream-Output, X-Chunked-Output, X-Content-Length OKHTTP: Content-Type: application/json OKHTTP: Server: go-ipfs/0.4.18-190117 OKHTTP: Trailer: X-Stream-Error OKHTTP: Vary: Origin OKHTTP: Date: Tue, 26 Feb 2019 03:18:31 GMT OKHTTP: Transfer-Encoding: chunked OKHTTP: {"Message":"failed to get block for QmZC6gALejeRt2TAHHMnEkcEXeyX3XUSZ4yRkpt43UkM5A: context deadline exceeded","Code":0,"Type":"error"} OKHTTP: <-- END HTTP (136-byte body)

ghost avatar Feb 26 '19 03:02 ghost