本文整理匯總了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());
}
}