public interface HttpResponse extends Closeable
| 限定符和类型 | 方法和说明 |
|---|---|
Header[] |
getAllHeaders()
获取所有的header
|
InputStream |
getContent()
获取response body
|
String |
getContent(Charset charset)
获取response body
|
String |
getContent(String charset)
获取response body
|
long |
getContentLength()
获取response body的长度,如果获取失败则返回一个负数
|
String |
getContentType()
获取
Content-Type |
Header |
getFirstHeader(String headerName)
获取header
|
Header[] |
getHeaders(String headerName)
获取header
|
String |
getHeaderValue(String headerName)
获取header value
|
Locale |
getLocale()
获取当前response的语言
|
String |
getReasonPhrase()
获取 response 原因,如
OK, Switching Protocols, Forbidden等 |
int |
getStatusCode()
获取 response 状态码,如
200,404等 |
boolean |
isChunked() |
void |
setContent(byte[] data,
String mimeType,
Charset charset)
设置response body
|
void |
setContent(InputStream inputStream,
String mimeType,
Charset charset)
设置response body
|
void |
setContent(String content,
String mimeType,
Charset charset)
设置response body
|
void |
transferTo(OutputStream outputStream)
response body transfer to output stream
|
int getStatusCode()
200,404等String getReasonPhrase()
OK, Switching Protocols, Forbidden等boolean isChunked()
long getContentLength()
InputStream getContent() throws IOException, UnsupportedEncodingException
String getContent(String charset) throws IOException, UnsupportedEncodingException
charset - 字符编码IOExceptionUnsupportedEncodingExceptionString getContent(Charset charset) throws IOException
charset - 字符编码IOExceptionvoid setContent(InputStream inputStream, String mimeType, Charset charset)
Header getFirstHeader(String headerName)
headerName - header nameHeader[] getHeaders(String headerName)
headerName - header nameHeader[] getAllHeaders()
String getContentType()
Content-TypeLocale getLocale()
void transferTo(OutputStream outputStream) throws IOException
outputStream - 目标输出流IOExceptionCopyright © 2019. All rights reserved.