nbbrd.io.http.HttpResponse Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of java-io-http Show documentation
Show all versions of java-io-http Show documentation
Common IO utilities - http
The newest version!
package nbbrd.io.http;
import lombok.NonNull;
import nbbrd.io.net.MediaType;
import java.io.*;
import java.nio.charset.StandardCharsets;
public interface HttpResponse extends Closeable {
@NonNull MediaType getContentType() throws IOException;
@NonNull InputStream getBody() throws IOException;
default @NonNull Reader getBodyAsReader() throws IOException {
return new InputStreamReader(getBody(), getContentType().getCharset().orElse(StandardCharsets.UTF_8));
}
default @NonNull InputStream asDisconnectingInputStream() throws IOException {
return DisconnectingInputStream.of(this);
}
}