Browse Source
client-java: handle server HTTP errors (#3762)
* client-java: handle server HTTP errors
* Update SeaweedWrite.java
pull/3764/head
kvtb
2 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with
7 additions and
0 deletions
-
other/java/client/src/main/java/seaweedfs/client/SeaweedWrite.java
|
|
@ -149,6 +149,13 @@ public class SeaweedWrite { |
|
|
|
CloseableHttpResponse response = SeaweedUtil.getClosableHttpClient().execute(post); |
|
|
|
|
|
|
|
try { |
|
|
|
if (response.getStatusLine().getStatusCode() / 100 != 2) { |
|
|
|
if (response.getEntity().getContentType() != null && response.getEntity().getContentType().getValue().equals("application/json")) { |
|
|
|
throw new IOException(EntityUtils.toString(response.getEntity(), "UTF-8")); |
|
|
|
} else { |
|
|
|
throw new IOException(response.getStatusLine().getReasonPhrase()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
String etag = response.getLastHeader("ETag").getValue(); |
|
|
|
|
|
|
|