mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
client-java: handle server HTTP errors (#3762)
* client-java: handle server HTTP errors * Update SeaweedWrite.java
This commit is contained in:
parent
e00a12b099
commit
5e9039d728
|
@ -149,6 +149,13 @@ public class SeaweedWrite {
|
||||||
CloseableHttpResponse response = SeaweedUtil.getClosableHttpClient().execute(post);
|
CloseableHttpResponse response = SeaweedUtil.getClosableHttpClient().execute(post);
|
||||||
|
|
||||||
try {
|
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();
|
String etag = response.getLastHeader("ETag").getValue();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue