Class HttpResponse
java.lang.Object
com.sure.tool.http.HttpResponse
-
Method Summary
Modifier and TypeMethodDescriptionbody()响应体文本(按getCharset()解码)。byte[]响应体字节(防御性拷贝)。Content-Type 响应头,无则返回null。cookies()解析全部 Set-Cookie 响应头为 Cookie 键值 Map(同名取第一个,忽略 Path/Expires 等属性)。响应字符集:从 Content-Type 解析,解析失败或无 charset 时回退 UTF-8。获取指定 Cookie 的值(来自 Set-Cookie 响应头),无则返回null。int响应状态码。getUrl()最终请求 URL(跟随重定向后)。指定响应头的第一个值(大小写不敏感),不存在返回null。headers()全部响应头(大小写保持原始,值为不可变 List)。headerValues(String name) 指定响应头的全部值(大小写不敏感),不存在返回空 List。booleanisOk()是否 2xx 成功。
-
Method Details
-
getStatus
public int getStatus()响应状态码。- Returns:
- 状态码
-
isOk
public boolean isOk()是否 2xx 成功。- Returns:
- 是否成功
-
getUrl
-
headers
-
headerValues
-
header
-
contentType
-
getCharset
-
body
-
bodyBytes
public byte[] bodyBytes()响应体字节(防御性拷贝)。- Returns:
- 响应体字节
-
cookies
-
getCookie
-