mirror of
https://github.com/chrislusf/seaweedfs
synced 2025-09-18 01:02:46 +02: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
1 changed files with 7 additions and 0 deletions
|
@ -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();
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue