当前位置: 首页>>代码示例>>Java>>正文


Java HttpResponse.getBody方法代码示例

本文整理汇总了Java中com.mashape.unirest.http.HttpResponse.getBody方法的典型用法代码示例。如果您正苦于以下问题:Java HttpResponse.getBody方法的具体用法?Java HttpResponse.getBody怎么用?Java HttpResponse.getBody使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.mashape.unirest.http.HttpResponse的用法示例。


在下文中一共展示了HttpResponse.getBody方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getAsJSONArray

import com.mashape.unirest.http.HttpResponse; //导入方法依赖的package包/类
/**
 * @return The json array get by performing request.
 */
public JSONArray getAsJSONArray() {
    JSONArray json;
    try {
        HttpResponse<JsonNode> response = request.asJson();
        checkRateLimit(response);
        handleErrorCode(response);
        JsonNode node = response.getBody();

        if (!node.isArray()) {
            handleErrorResponse(node.getObject());
            throw new UnirestException("The request returns a JSON Object. Json: "+node.getObject().toString(4));
        } else {
            json = node.getArray();
        }
    } catch (UnirestException e) {
        throw new JSONException("Error Occurred while getting JSON Array: "+e.getLocalizedMessage());
    }
    return json;
}
 
开发者ID:AlienIdeology,项目名称:J-Cord,代码行数:23,代码来源:Requester.java

示例2: retrieveAllFiles

import com.mashape.unirest.http.HttpResponse; //导入方法依赖的package包/类
public static List<String> retrieveAllFiles(String auth, String folder) throws IOException, UnirestException {
    List<String> lis= new LinkedList<String>();
    HttpResponse<JsonNode> jsonResponse = Unirest.get("https://www.googleapis.com/drive/v2/files/root/children?q=title='"+folder+"'").header("Authorization","Bearer "+auth).asJson();
    JSONObject jsonObject= new JSONObject(jsonResponse.getBody());
    JSONArray array = jsonObject.getJSONArray("array");
    for(int i=0;i<array.length();i++){
        JSONArray jarray=array.getJSONObject(i).getJSONArray("items");
        int j=jarray.length();
        while(j>0){
            String id=jarray.getJSONObject(0).getString("id");
            auxRetrieveAllFiles(lis,auth,"https://www.googleapis.com/drive/v2/files?includeTeamDriveItems=false&pageSize=500&q='"+id+"'%20in%20parents"+"&key="+ MISConfig.getGoogle_api(),id);
            j--;
        }

    }
    return lis;
}
 
开发者ID:LithiumSR,项目名称:media_information_service,代码行数:18,代码来源:GDrvAPIOp.java

示例3: getList

import com.mashape.unirest.http.HttpResponse; //导入方法依赖的package包/类
/**
 * Get List of records of response.
 *
 * @param response
 * @return
 */
private List<T> getList(HttpResponse<Records> response) {

    final Records records = response.getBody();
    final List<T> list = new ArrayList<>();

    for (Map<String, Object> record : records.getRecords()) {
        T item = null;
        try {
            item = transform(record, this.type.newInstance());
        } catch (InstantiationException | IllegalAccessException | InvocationTargetException e) {
            LOG.error(e.getMessage(), e);
        }
        list.add(item);
    }
    return list;
}
 
开发者ID:Sybit-Education,项目名称:airtable.java,代码行数:23,代码来源:Table.java

示例4: performRequest

import com.mashape.unirest.http.HttpResponse; //导入方法依赖的package包/类
/**
 * Performs requests
 * @return HttpCode, the response status
 */
public HttpCode performRequest() {
    try {
        HttpResponse<JsonNode> response = request.asJson();
        checkRateLimit(response);
        handleErrorCode(response);
        JsonNode node = response.getBody();
        if (node != null && !node.isArray()) {
            handleErrorResponse(node.getObject());
        }
        return HttpCode.getByKey(response.getStatus());
    } catch (UnirestException e) {
        throw new RuntimeException("Fail to perform http request!");
    }
}
 
开发者ID:AlienIdeology,项目名称:J-Cord,代码行数:19,代码来源:Requester.java

示例5: downloadLatestMetadataZip

import com.mashape.unirest.http.HttpResponse; //导入方法依赖的package包/类
protected InputStream downloadLatestMetadataZip(String token) throws UnirestException {
    final HttpResponse<InputStream> response = Unirest.get(metadataUrl + "file/latestMeta")
            .header("X-Auth-Token", token)
            .asBinary();
    if (response.getStatus() == 404) return null;
    return response.getBody();
}
 
开发者ID:MineboxOS,项目名称:tools,代码行数:8,代码来源:DownloadFactory.java

示例6: 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

示例7: myAddress

import com.mashape.unirest.http.HttpResponse; //导入方法依赖的package包/类
public String myAddress() {
    final HttpResponse<String> string = siaCommand(SiaCommand.ADDRESS, ImmutableMap.of());
    if (walletIsLocked(string)) {
        return null;
    }
    final JSONObject jsonObject = new JSONObject(string.getBody());
    return jsonObject.getString("address");
}
 
开发者ID:MineboxOS,项目名称:minebox,代码行数:9,代码来源:SiaUtil.java

示例8: sendAction

import com.mashape.unirest.http.HttpResponse; //导入方法依赖的package包/类
String sendAction(String action) throws
        ClientErrorException, ServerErrorException, OtherCommunicationException {
    try {
        String encodedPath = URLEncoder.encode(this.journeyId, "UTF-8");
        String url = String.format("http://%s:%d/action/%s/%s", this.url, port, action, encodedPath);
        HttpResponse<String> response =  Unirest.post(url)
                .header("Accept", this.acceptHeader)
                .header("Accept-Charset", "UTF-8")
                .asString();
        ensureStatusOk(response);
        return response.getBody();
    } catch (UnirestException | UnsupportedEncodingException e ) {
        throw new OtherCommunicationException("Could not perform POST request",e);
    }
}
 
开发者ID:julianghionoiu,项目名称:tdl-runner-scala,代码行数:16,代码来源:ChallengeServerClient.java

示例9: testIsTestRepositoryAvailable

import com.mashape.unirest.http.HttpResponse; //导入方法依赖的package包/类
@Test
public void testIsTestRepositoryAvailable() throws IOException, UnirestException {
    HttpResponse<RepositoryContainer> response = Unirest.get(seRepoTestServer.LOCALHOST_REPOS)
            .asObject(RepositoryContainer.class);
    RepositoryContainer repos = response.getBody();

    assertTrue(repos.getRepositories().stream().map(Repository::getName).collect(Collectors.toList
            ()).contains(TestDataProvider.TEST_REPO));
}
 
开发者ID:adr,项目名称:eadlsync,代码行数:10,代码来源:SeRepoTestServerTest.java

示例10: login

import com.mashape.unirest.http.HttpResponse; //导入方法依赖的package包/类
@Override
public UserProfile login(PlayerLogin playerLogin) {
    try {
        HttpResponse<UserProfile> userProfileResponse = Unirest.post(config.getBaseUrl() + "/mc/player/login")
                .header("x-access-token", config.getAuthToken())
                .header("accept", "application/json")
                .header("Content-Type", "application/json")
                .body(playerLogin)
                .asObject(UserProfile.class);
        return userProfileResponse.getBody();
    } catch (UnirestException e) {
        e.printStackTrace();
        return null;
    }
}
 
开发者ID:WarzoneMC,项目名称:Warzone,代码行数:16,代码来源:HttpClient.java

示例11: loadmap

import com.mashape.unirest.http.HttpResponse; //导入方法依赖的package包/类
@Override
public MapLoadResponse loadmap(Map map) {
    try {
        HttpResponse<MapLoadResponse> mapLoadResponse = Unirest.post(config.getBaseUrl() + "/mc/map/load")
                .header("x-access-token", config.getAuthToken())
                .header("accept", "application/json")
                .header("Content-Type", "application/json")
                .body(map)
                .asObject(MapLoadResponse.class);
        return mapLoadResponse.getBody();
    } catch (UnirestException e) {
        e.printStackTrace();
        return null;
    }
}
 
开发者ID:WarzoneMC,项目名称:Warzone,代码行数:16,代码来源:HttpClient.java

示例12: loadMatch

import com.mashape.unirest.http.HttpResponse; //导入方法依赖的package包/类
@Override
public MatchInProgress loadMatch(MatchLoadRequest matchLoadRequest) {
    try {
        HttpResponse<MatchInProgress> userProfileResponse = Unirest.post(config.getBaseUrl() + "/mc/match/load")
                .header("x-access-token", config.getAuthToken())
                .header("accept", "application/json")
                .header("Content-Type", "application/json")
                .body(matchLoadRequest)
                .asObject(MatchInProgress.class);
        return userProfileResponse.getBody();
    } catch (UnirestException e) {
        e.printStackTrace();
        return null;
    }
}
 
开发者ID:WarzoneMC,项目名称:Warzone,代码行数:16,代码来源:HttpClient.java

示例13: extractBody

import com.mashape.unirest.http.HttpResponse; //导入方法依赖的package包/类
private static Object extractBody(Method method, HttpResponse response) {
    if (isString(returnTypeof(method)) && response.getBody() != null) {
        return trimEnclosingQuotes(response.getBody().toString());
    } else {
        return response.getBody();
    }
}
 
开发者ID:drinkwater-io,项目名称:drinkwater-java,代码行数:8,代码来源:Rest.java

示例14: deleteEffects

import com.mashape.unirest.http.HttpResponse; //导入方法依赖的package包/类
/**
 * Deletes multiple effects and removes them from the device
 *
 * @param effectIds the {@link EffectIds}
 * @return the result
 * @throws UnirestException
 */
public ResponseResult deleteEffects(EffectIds effectIds) throws UnirestException {
	checkInitialized();
	HttpResponse<ResponseResult> response = Unirest
			.put(this.session.getUri() + "/effect")
			.body(effectIds)
			.asObject(ResponseResult.class);
	return response.getBody();
}
 
开发者ID:InventivetalentDev,项目名称:RazerChromaRESTClient,代码行数:16,代码来源:ChromaClient.java

示例15: send

import com.mashape.unirest.http.HttpResponse; //导入方法依赖的package包/类
/**
 * Send the payload to Discord.
 *
 * @throws WebhookException the webhook exception
 */
public void send() throws WebhookException {
    this.obj.put("embeds", new JSONArray().put(this.embed));

    try {
        HttpResponse<JsonNode> response = Unirest.post(this.webhookUrl).header("Content-Type", "application/json").body(this.obj).asJson();

        try {
            if (response.getBody() == null || response.getBody().getObject().get("embeds") == null) throw new JSONException("Expected.");
            throw new WebhookException(response.getBody().getObject().toString(2));
        } catch (JSONException ignored) {}
    } catch (UnirestException e) { e.printStackTrace(); }
}
 
开发者ID:jammehcow,项目名称:jenkins-discord,代码行数:18,代码来源:DiscordWebhook.java


注:本文中的com.mashape.unirest.http.HttpResponse.getBody方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。