Improve empty body check
Fixes gh-22265
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -79,8 +79,13 @@ class MessageBodyClientHttpResponseWrapper implements ClientHttpResponse {
|
||||
* @return {@code true} if the response has a zero-length message body, {@code false} otherwise
|
||||
* @throws IOException in case of I/O errors
|
||||
*/
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
public boolean hasEmptyMessageBody() throws IOException {
|
||||
InputStream body = this.response.getBody();
|
||||
// Per contract body shouldn't be null, but check anyway..
|
||||
if (body == null) {
|
||||
return true;
|
||||
}
|
||||
if (body.markSupported()) {
|
||||
body.mark(1);
|
||||
if (body.read() == -1) {
|
||||
|
||||
Reference in New Issue
Block a user