Modifier and Type | Field and Description |
---|---|
protected JdkHttpConnection |
httpConnection
持有连接对象
|
protected int |
status
响应状态码
|
Modifier | Constructor and Description |
---|---|
protected |
JdkHttpResponse(JdkHttpConnection httpConnection,
JdkCookieManager cookieManager,
Request message)
构造
|
Modifier and Type | Method and Description |
---|---|
ResponseBody |
body()
获取响应体,包含服务端返回的内容和Content-Type信息
如果为HEAD、CONNECT、TRACE等方法无响应体,则返回 null |
byte[] |
bodyBytes()
获取响应流字节码
此方法会转为同步模式 |
InputStream |
bodyStream()
|
Charset |
charset()
获取字符集编码,默认为响应头中的编码
|
void |
close() |
HttpCookie |
getCookie(String name)
获取Cookie
|
List<HttpCookie> |
getCookies()
获取Cookie
如果启用Cookie管理器,则返回这个站点相关的所有Cookie信息,否则返回当前的响应的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, wait
bodyStr, contentEncoding, contentLength, getCookieStr, getFileNameFromDisposition, header, headerList, isChunked, isOk, then
protected JdkHttpConnection httpConnection
protected int status
protected JdkHttpResponse(JdkHttpConnection httpConnection, JdkCookieManager cookieManager, Request message)
httpConnection
- JdkHttpConnection
cookieManager
- Cookie管理器message
- 请求消息public String header(String name)
Response
public JdkHttpResponse sync()
Response
InputStream
。public List<HttpCookie> getCookies()
public HttpCookie getCookie(String name)
name
- Cookie名HttpCookie
public String getCookieValue(String name)
name
- Cookie名public InputStream bodyStream()
bodyStream
in interface Response
public ResponseBody body()
Response
null
body
in interface Response
ResponseBody
public byte[] bodyBytes()
public void close()
close
in interface Closeable
close
in interface AutoCloseable
Copyright © 2025. All rights reserved.