public class HttpClientHttpResponse extends Object implements HttpResponse
CloseableHttpResponse| 构造器和说明 |
|---|
HttpClientHttpResponse(org.apache.http.client.methods.CloseableHttpResponse httpResponse) |
| 限定符和类型 | 方法和说明 |
|---|---|
void |
close() |
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
|
public HttpClientHttpResponse(org.apache.http.client.methods.CloseableHttpResponse httpResponse)
public int getStatusCode()
HttpResponse200,404等getStatusCode 在接口中 HttpResponsepublic String getReasonPhrase()
HttpResponseOK, Switching Protocols, Forbidden等getReasonPhrase 在接口中 HttpResponsepublic boolean isChunked()
isChunked 在接口中 HttpResponsepublic long getContentLength()
HttpResponsegetContentLength 在接口中 HttpResponsepublic InputStream getContent() throws IOException, UnsupportedEncodingException
HttpResponsegetContent 在接口中 HttpResponseIOExceptionUnsupportedEncodingExceptionpublic String getContent(String charset) throws IOException, UnsupportedEncodingException
HttpResponsegetContent 在接口中 HttpResponsecharset - 字符编码IOExceptionUnsupportedEncodingExceptionpublic String getContent(Charset charset) throws IOException
HttpResponsegetContent 在接口中 HttpResponsecharset - 字符编码IOExceptionpublic void setContent(InputStream inputStream, String mimeType, Charset charset)
HttpResponsesetContent 在接口中 HttpResponsepublic void setContent(String content, String mimeType, Charset charset)
HttpResponsesetContent 在接口中 HttpResponsepublic void setContent(byte[] data,
String mimeType,
Charset charset)
HttpResponsesetContent 在接口中 HttpResponsepublic String getHeaderValue(String headerName)
HttpResponsegetHeaderValue 在接口中 HttpResponseheaderName - header namepublic Header getFirstHeader(String headerName)
HttpResponsegetFirstHeader 在接口中 HttpResponseheaderName - header namepublic Header[] getHeaders(String headerName)
HttpResponsegetHeaders 在接口中 HttpResponseheaderName - header namepublic Header[] getAllHeaders()
HttpResponsegetAllHeaders 在接口中 HttpResponsepublic String getContentType()
HttpResponseContent-TypegetContentType 在接口中 HttpResponsepublic Locale getLocale()
HttpResponsegetLocale 在接口中 HttpResponsepublic void transferTo(OutputStream outputStream) throws IOException
HttpResponsetransferTo 在接口中 HttpResponseoutputStream - 目标输出流IOExceptionpublic void close()
throws IOException
close 在接口中 Closeableclose 在接口中 AutoCloseableIOExceptionCopyright © 2019. All rights reserved.