java类com.mashape.unirest.http.HttpResponse的实例源码

Gephi.java 文件源码 项目:exportJanusGraphToGephi 阅读 18 收藏 0 点赞 0 评论 0
public static void updateGraphTest() {

        //System.out.println(jsonObj.toString());

        try {
            HttpResponse<JsonNode> response = Unirest.post(url + "?operation=updateGraph")
                    .header("content-type", "application/json")
                    .header("cache-control", "no-cache")
                    .body("{\"an\":{\"520248\":{\"id\":520248,\"label\":\"artist\"}}}")
                    .asJson();
            System.out.println(response.getBody());
        } catch(UnirestException e) {
            e.printStackTrace();
        }
    }
TestExceptionMapper.java 文件源码 项目:javalin 阅读 25 收藏 0 点赞 0 评论 0
@Test
public void test_typedMappedException_isHandled() throws Exception {
    app.get("/typed-exception", ctx -> {
        throw new TypedException();
    }).exception(TypedException.class, (e, ctx) -> {
        ctx.result(e.proofOfType());
    });
    HttpResponse<String> response = GET_asString("/typed-exception");
    assertThat(response.getBody(), is("I'm so typed"));
    assertThat(response.getStatus(), is(200));
}
DownloadFactory.java 文件源码 项目:tools 阅读 25 收藏 0 点赞 0 评论 0
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();
}
TestHaltException.java 文件源码 项目:javalin 阅读 25 收藏 0 点赞 0 评论 0
@Test
public void test_afterRuns_afterHalt() throws Exception {
    app.get("/some-route", ctx -> {
        throw new HaltException(401, "Stop!");
    }).after(ctx -> {
        ctx.status(418);
    });
    HttpResponse<String> response = call(HttpMethod.GET, "/some-route");
    assertThat(response.getBody(), is("Stop!"));
    assertThat(response.getStatus(), is(418));
}
TestExceptionMapper.java 文件源码 项目:javalin 阅读 22 收藏 0 点赞 0 评论 0
@Test
public void test_moreSpecificException_isHandledFirst() throws Exception {
    app.get("/exception-priority", ctx -> {
        throw new TypedException();
    }).exception(Exception.class, (e, ctx) -> {
        ctx.result("This shouldn't run");
    }).exception(TypedException.class, (e, ctx) -> {
        ctx.result("Typed!");
    });
    HttpResponse<String> response = GET_asString("/exception-priority");
    assertThat(response.getBody(), is("Typed!"));
    assertThat(response.getStatus(), is(200));
}
SeRepoTestServerTest.java 文件源码 项目:eadlsync 阅读 19 收藏 0 点赞 0 评论 0
@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));
}
HttpClient.java 文件源码 项目:Warzone 阅读 24 收藏 0 点赞 0 评论 0
@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;
    }
}
HttpClient.java 文件源码 项目:Warzone 阅读 24 收藏 0 点赞 0 评论 0
@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;
    }
}
HttpClient.java 文件源码 项目:Warzone 阅读 24 收藏 0 点赞 0 评论 0
@Override
public void addKill(Death death) {
    try {
        HttpResponse<JsonNode> jsonResponse = Unirest.post(config.getBaseUrl() + "/mc/death/new")
                .header("x-access-token", config.getAuthToken())
                .header("accept", "application/json")
                .header("Content-Type", "application/json")
                .body(death)
                .asJson();
    } catch (UnirestException e) {
        e.printStackTrace();
    }
}
HttpClient.java 文件源码 项目:Warzone 阅读 25 收藏 0 点赞 0 评论 0
@Override
public void finishMatch(MatchFinishPacket matchFinishPacket) {
    try {
        HttpResponse<JsonNode> jsonResponse = Unirest.post(config.getBaseUrl() + "/mc/match/finish")
                .header("x-access-token", config.getAuthToken())
                .header("accept", "application/json")
                .header("Content-Type", "application/json")
                .body(matchFinishPacket)
                .asJson();
    } catch (UnirestException e) {
        e.printStackTrace();
    }
}


问题


面经


文章

微信
公众号

扫码关注公众号