當前位置: 首頁>>代碼示例>>Java>>正文


Java HttpResponse.getStatusText方法代碼示例

本文整理匯總了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();
}
 
開發者ID:dixantmittal,項目名稱:scalable-task-scheduler,代碼行數:22,代碼來源:HttpUtils.java

示例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());
    }
}
 
開發者ID:AlienIdeology,項目名稱:J-Cord,代碼行數:14,代碼來源:Requester.java

示例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());
    }
}
 
開發者ID:julianghionoiu,項目名稱:tdl-runner-scala,代碼行數:12,代碼來源:ChallengeServerClient.java


注:本文中的com.mashape.unirest.http.HttpResponse.getStatusText方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。