本文整理汇总了Java中com.mashape.unirest.http.HttpResponse.getStatusText方法的典型用法代码示例。如果您正苦于以下问题:Java HttpResponse.getStatusText方法的具体用法?Java HttpResponse.getStatusText怎么用?Java HttpResponse.getStatusText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.mashape.unirest.http.HttpResponse
的用法示例。
在下文中一共展示了HttpResponse.getStatusText方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processHttpRequest
import com.mashape.unirest.http.HttpResponse; //导入方法依赖的package包/类
public static String processHttpRequest(String completeURL,
Map<String, Object> params,
Map<String, String> customHeaders,
HttpMethod method) throws IOException {
Map<String, String> headers = getDefaultHeader();
if (customHeaders != null) {
headers.putAll(customHeaders);
}
HttpResponse<JsonNode> result = executeHttpMethod(completeURL, params, headers, method);
if (result == null) {
return null;
}
if (result.getStatus() != 200) {
String exceptionResponse = result.getBody().toString();
throw new ServiceException((result.getStatus() + result.getStatusText()),
exceptionResponse);
}
return result.getBody().toString();
}
示例2: handleErrorCode
import com.mashape.unirest.http.HttpResponse; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private void handleErrorCode(HttpResponse response) {
HttpCode error = HttpCode.getByKey(response.getStatus());
if (error.isServerError() || error.isFailure()) {
if (error.equals(HttpCode.TOO_MANY_REQUESTS)) { // Rate limited
checkRateLimit(response);
} else {
throw new HttpErrorException(error);
}
} else if (error == HttpCode.UNKNOWN){
throw new HttpErrorException(response.getStatus(), response.getStatusText());
}
}
示例3: ensureStatusOk
import com.mashape.unirest.http.HttpResponse; //导入方法依赖的package包/类
private static void ensureStatusOk(HttpResponse<String> response) throws ClientErrorException,
ServerErrorException, OtherCommunicationException {
int responseStatus = response.getStatus();
if (isClientError(responseStatus)) {
throw new ClientErrorException(response.getBody());
} else if (isServerError(responseStatus)) {
throw new ServerErrorException(response.getStatusText());
} else if (isOtherErrorResponse(responseStatus)) {
throw new OtherCommunicationException(response.getStatusText());
}
}