public interface Response
| 限定符和类型 | 方法和说明 |
|---|---|
boolean |
acceptRanges()
是否支持分段下载
|
String |
body()
返回字符串
|
byte[] |
bodyAsBytes()
返回字节数组
|
void |
bodyAsFile(Path file)
将输入流写入到指定文件
若文件已存在,则会追加到文件尾部
|
void |
bodyAsFile(String filePath)
将输入流写入到指定文件
若文件已存在,则会追加到文件尾部
|
com.alibaba.fastjson.JSONArray |
bodyAsJSONArray()
返回JSON数组
|
com.alibaba.fastjson.JSONObject |
bodyAsJSONObject()
返回JSON对象
|
InputStream |
bodyStream()
获取输入流
|
String |
charset()
获取编码格式
|
String |
contentEncoding()
获取contentEncoding头部信息,若不存在则返回null
|
long |
contentLength()
获取大小
|
String |
contentType()
获取返回格式类型
|
void |
disconnect()
断开连接
|
String |
filename()
获取文件名
|
boolean |
hasCookie(String name)
是否存在指定Cookie
|
boolean |
hasCookie(String name,
String value)
是否存在指定Cookie
|
boolean |
hasHeader(String name)
是否有该Header
|
boolean |
hasHeader(String name,
String value)
是否存在该Header
|
List<String> |
header(String name)
获取头部信息
|
Map<String,List<String>> |
headers()
获取所有Header信息
|
com.alibaba.fastjson.JSONArray |
jsonpAsJSONArray()
解析jsonp返回JSON数组
|
com.alibaba.fastjson.JSONObject |
jsonpAsJSONObject()
解析jsonp返回JSON对象
|
Response |
maxDownloadSpeed(int maxDownloadSpeed)
设置最大下载速率(kb/s)
|
Document |
parse()
解析成DOM数并返回Document对象
|
DocumentParser |
parser()
使用事件监听机制获取处理DOM树
|
ResponseMeta |
responseMeta()
获取返回元数据
|
int |
statusCode()
获取状态码
|
String |
statusMessage()
获取状态说明
|
String |
url()
获取返回地址
|
String url()
int statusCode()
String statusMessage()
String charset()
String contentType()
long contentLength()
String filename()
boolean acceptRanges()
String contentEncoding()
boolean hasHeader(String name)
name - 头部名称boolean hasCookie(String name)
name - cookie名称boolean hasCookie(String name, String value)
name - cookie名称value - cookie值Response maxDownloadSpeed(int maxDownloadSpeed)
String body() throws IOException
IOExceptioncom.alibaba.fastjson.JSONObject bodyAsJSONObject()
throws IOException
IOExceptioncom.alibaba.fastjson.JSONArray bodyAsJSONArray()
throws IOException
IOExceptioncom.alibaba.fastjson.JSONObject jsonpAsJSONObject()
throws IOException
IOExceptioncom.alibaba.fastjson.JSONArray jsonpAsJSONArray()
throws IOException
IOExceptionbyte[] bodyAsBytes()
throws IOException
IOExceptionvoid bodyAsFile(String filePath) throws IOException
若文件已存在,则会追加到文件尾部
IOExceptionvoid bodyAsFile(Path file) throws IOException
若文件已存在,则会追加到文件尾部
IOExceptionInputStream bodyStream()
Document parse() throws IOException
IOExceptionDocumentParser parser() throws IOException
IOExceptionvoid disconnect()
ResponseMeta responseMeta()
Copyright © 2021. All rights reserved.