
net.dongliu.cute.http.ResponseInfo Maven / Gradle / Ivy
The newest version!
package net.dongliu.cute.http;
import java.nio.charset.Charset;
import java.util.Optional;
/**
* Carry the http response info, mainly the http status code and headers.
*/
public class ResponseInfo {
private final int statusCode;
private final Headers headers;
ResponseInfo(int statusCode, Headers headers) {
this.statusCode = statusCode;
this.headers = headers;
}
/**
* the http response status
*/
public int statusCode() {
return statusCode;
}
/**
* the http response headers
*/
public Headers headers() {
return headers;
}
/**
* Get the charset set in response header. If not set, return empty Optional
*/
public Optional getCharset() {
return headers.contentType().flatMap(ContentType::charset);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy