@Contract(threading=IMMUTABLE) public class BasicResponseHandler extends AbstractResponseHandler<String>
ResponseHandler将响应正文返回为成功(2xx)响应的字符串。
如果响应代码为> = 300,则响应正文被消耗,并抛出HttpResponseException 。
如果这与HttpClient.execute( org.apache.http.client.methods.HttpUriRequest, org.apache.http.client.ResponseHandler)一起使用 ,HttpClient可以在内部处理重定向(3xx响应)。
| Constructor and Description |
|---|
BasicResponseHandler() |
| Modifier and Type | Method and Description |
|---|---|
String |
handleEntity(HttpEntity entity)
以String作为主体返回实体。
|
String |
handleResponse(HttpResponse response)
如果响应成功(2xx状态代码),请从响应体读取实体并将其传递给实体处理程序方法。
|
public String handleEntity(HttpEntity entity) throws IOException
handleEntity在
AbstractResponseHandler<String>
IOException
public String handleResponse(HttpResponse response) throws HttpResponseException, IOException
AbstractResponseHandler复制
HttpResponseException 。
handleResponse在接口
ResponseHandler<String>
handleResponse在
AbstractResponseHandler<String>
response - 对过程的反应
ClientProtocolException - 在http协议错误的情况下
IOException - 出现问题或连接中止时
HttpResponseException
Copyright © 1999–2017 The Apache Software Foundation. All rights reserved.