mirror of
https://github.com/MineLittlePony/MineLittlePony.git
synced 2025-03-23 04:07:11 +01:00
Backport null fix when reading a response
This commit is contained in:
parent
ec4a357aa6
commit
547659ca30
1 changed files with 8 additions and 1 deletions
|
@ -5,6 +5,8 @@ import com.google.common.io.CharStreams;
|
|||
import com.google.gson.JsonObject;
|
||||
import com.voxelmodpack.hdskins.server.SkinServer;
|
||||
|
||||
import org.apache.http.Header;
|
||||
import org.apache.http.HttpEntity;
|
||||
import org.apache.http.HttpStatus;
|
||||
import org.apache.http.NameValuePair;
|
||||
import org.apache.http.client.methods.CloseableHttpResponse;
|
||||
|
@ -19,6 +21,7 @@ import java.io.InputStreamReader;
|
|||
import java.lang.reflect.Type;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
|
@ -37,8 +40,12 @@ public interface MoreHttpResponses extends AutoCloseable {
|
|||
return getResponse().getStatusLine().getStatusCode();
|
||||
}
|
||||
|
||||
default Optional<HttpEntity> getEntity() {
|
||||
return Optional.ofNullable(getResponse().getEntity());
|
||||
}
|
||||
|
||||
default String getContentType() {
|
||||
return getResponse().getEntity().getContentType().getValue();
|
||||
return getEntity().map(HttpEntity::getContentType).map(Header::getValue).orElse("text/plain");
|
||||
}
|
||||
|
||||
default InputStream getInputStream() throws IOException {
|
||||
|
|
Loading…
Add table
Reference in a new issue