| 限定符和类型 | 字段和说明 |
|---|---|
protected JdkHttpConnection |
httpConnection
持有连接对象
|
protected int |
status
响应状态码
|
| 限定符 | 构造器和说明 |
|---|---|
protected |
JdkHttpResponse(JdkHttpConnection httpConnection,
boolean ignoreEOFError,
Charset requestCharset,
boolean isAsync,
boolean isIgnoreBody)
构造
|
| 限定符和类型 | 方法和说明 |
|---|---|
ResponseBody |
body()
获取响应体,包含服务端返回的内容和Content-Type信息
|
byte[] |
bodyBytes()
获取响应流字节码
此方法会转为同步模式 |
InputStream |
bodyStream()
|
Charset |
charset()
获取字符集编码,默认为响应头中的编码
|
void |
close() |
HttpCookie |
getCookie(String name)
获取Cookie
|
List<HttpCookie> |
getCookies()
获取Cookie
|
String |
getCookieValue(String name)
获取Cookie值
|
int |
getStatus()
获取状态码
|
String |
header(String name)
根据name获取头信息
根据RFC2616规范,header的name不区分大小写 |
Map<String,List<String>> |
headers()
获取headers
|
JdkHttpResponse |
sync()
同步
如果为异步状态,则暂时不读取服务器中响应的内容,而是持有Http链接的 InputStream。 |
String |
toString() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitbodyStr, contentEncoding, contentLength, getCookieStr, header, isChunked, isOk, thenprotected JdkHttpConnection httpConnection
protected int status
protected JdkHttpResponse(JdkHttpConnection httpConnection, boolean ignoreEOFError, Charset requestCharset, boolean isAsync, boolean isIgnoreBody)
httpConnection - JdkHttpConnectionignoreEOFError - 是否忽略响应读取时可能的EOF异常requestCharset - 编码,从请求编码中获取默认编码isAsync - 是否异步isIgnoreBody - 是否忽略读取响应体public String header(String name)
Responsepublic JdkHttpResponse sync()
InputStream。public List<HttpCookie> getCookies()
public HttpCookie getCookie(String name)
name - Cookie名HttpCookiepublic String getCookieValue(String name)
name - Cookie名public InputStream bodyStream()
bodyStream 在接口中 Responsepublic ResponseBody body()
Responsebody 在接口中 ResponseResponseBodypublic void close()
close 在接口中 Closeableclose 在接口中 AutoCloseableCopyright © 2023. All rights reserved.