本文整理了Java中com.mashape.unirest.http.Unirest.get()
方法的一些代码示例,展示了Unirest.get()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Unirest.get()
方法的具体详情如下:
包路径:com.mashape.unirest.http.Unirest
类名称:Unirest
方法名:get
暂无
代码示例来源:origin: lets-blade/blade
protected HttpRequest get(String path) {
log.info("[GET] {}", (origin + path));
return Unirest.get(origin + path);
}
代码示例来源:origin: lets-blade/blade
protected String getBodyString(String path) throws Exception {
log.info("[GET] {}", (origin + path));
return Unirest.get(origin + path).asString().getBody();
}
代码示例来源:origin: lets-blade/blade
@Test
public void testListen() throws Exception {
Blade blade = Blade.of();
blade.listen(9001).start().await();
try {
int code = Unirest.get("http://127.0.0.1:9001").asString().getStatus();
assertEquals(404, code);
} finally {
blade.stop();
try {
new Socket("127.0.0.1", 9001);
Assert.fail("Server is still running");
} catch (ConnectException e) {
}
}
}
代码示例来源:origin: lets-blade/blade
@Test
public void testListenAddress() throws Exception {
Blade blade = Blade.of();
blade.listen("localhost", 9002).start().await();
try {
int code = Unirest.get("http://localhost:9002/").asString().getStatus();
assertEquals(404, code);
} finally {
blade.stop();
}
}
代码示例来源:origin: RaiMan/SikuliX2
public static boolean stopServer() {
try {
log.trace("stopServer: trying");
String url = urlBase + "/stop";
GetRequest request = Unirest.get(url);
try {
HttpResponse<?> response = request.asString();
// InputStream respIS = response.getRawBody();
// String respText = IOUtils.toString(respIS, "UTF-8");
// log.trace("%s", respText);
} catch (Exception ex) {
log.error("%s", ex.getMessage());
}
} catch (Exception e) {
log.error("stopServer: %s", e.getMessage());
return false;
}
return true;
}
}
代码示例来源:origin: vulnersCom/burp-vulners-scanner
Unirest.get(BURP_API_URL)
.routeParam("path", "rules")
.asJsonAsync(new VulnersRestCallback(callbacks) {
代码示例来源:origin: vulnersCom/burp-vulners-scanner
Unirest.get(BURP_API_URL)
.routeParam("path", "path")
.queryString("path", path)
代码示例来源:origin: RaiMan/SikuliX2
public static JSONObject get(String urlCommand) {
log.trace("get: %s", urlCommand);
HttpResponse<JsonNode> jsonResponse = null;
JSONObject response = null;
try {
jsonResponse = Unirest.get(urlBase + urlCommand)
.header("accept", "application/json")
.asJson();
} catch (UnirestException e) {
log.error("get: %s", e.getMessage());
}
String responseBody = "null";
if (SX.isNotNull(jsonResponse)) {
responseBody = jsonResponse.getBody().toString();
response = SXJson.makeObject(responseBody);
}
log.trace("get: response: %s",jsonResponse.getBody().toString());
return response;
}
代码示例来源:origin: vulnersCom/burp-vulners-scanner
final HttpRequest request = Unirest.get(BURP_API_URL)
.routeParam("path", "software")
.queryString("software", software.getAlias())
代码示例来源:origin: thejamesthomas/javabank
public boolean isMountebankRunning() {
try {
HttpResponse<JsonNode> response = Unirest.get(baseUrl).asJson();
return response.getStatus() == 200;
} catch (UnirestException e) {
return false;
}
}
代码示例来源:origin: forcelate/forcelate-benchmarks
@Override
public void orderBook() throws UnirestException {
HttpResponse<String> response = Unirest.get(orderBookURL())
.asString();
unirestParamsClient.orderBook(response, BITFINEX);
}
代码示例来源:origin: forcelate/forcelate-benchmarks
@Override
public void trades() throws UnirestException {
HttpResponse<String> response = Unirest.get(TRADES_URL)
.queryString("limit_trades", "100")
.asString();
unirestParamsClient.trades(response, BITFINEX);
}
}
代码示例来源:origin: forcelate/forcelate-benchmarks
@Override
public void ticker() throws IOException, UnirestException {
HttpResponse<String> response = Unirest.get(TICKER_URL)
.queryString(PAIR_QUERY_KEY, PAIR_QUERY_VALUE)
.asString();
unirestParamsClient.ticker(response, KRAKEN);
}
代码示例来源:origin: forcelate/forcelate-benchmarks
@Override
public void trades() throws IOException, UnirestException {
HttpResponse<String> response = Unirest.get(TRADES_URL)
.queryString(PAIR_QUERY_KEY, PAIR_QUERY_VALUE)
.asString();
unirestParamsClient.trades(response, KRAKEN);
}
}
代码示例来源:origin: io.teecube.t3/t3-site-enhancer
private List<Project> getProjects() throws UnirestException {
if (projects != null) {
return projects;
}
GetRequest projectsRequest = Unirest.get(apiEndPoint + "/projects").header("PRIVATE-TOKEN", privateToken);
if (getRequestOK(projectsRequest)) {
String json = projectsRequest.asJson().getBody().getArray().toString();
projects = Arrays.asList(mapper.readValue(json, Project[].class));
}
return projects;
}
代码示例来源:origin: ContainerSolutions/minimesos
@Override
public Boolean call() throws Exception {
try {
Unirest.get(getServiceUrl().toString() + APPS_ENDPOINT).header(HEADER_ACCEPT, APPLICATION_JSON).asJson().getBody().getObject();
} catch (UnirestException e) { //NOSONAR
// meaning API is not ready
return false;
}
return true;
}
}
代码示例来源:origin: ContainerSolutions/minimesos
@Override
public JSONObject getStateInfoJSON() throws UnirestException {
String stateUrl = getStateUrl();
GetRequest request = Unirest.get(stateUrl);
HttpResponse<JsonNode> response = request.asJson();
return response.getBody().getObject();
}
代码示例来源:origin: mattia-battiston/clean-architecture-example
private void whenTheCapacityIsRetrievedForExchange(String exchangeCode) throws UnirestException {
String apiPath = GetCapacityForExchangeEndpoint.API_PATH.replace("{exchangeCode}", exchangeCode);
String apiUrl = "http://localhost:8080" + apiPath;
log("API Url", apiUrl);
HttpResponse<String> httpResponse = Unirest.get(apiUrl).asString();
responseStatus = httpResponse.getStatus();
log("Response Status", responseStatus);
responseContent = httpResponse.getBody();
log("Response Content", formatJson(responseContent));
}
代码示例来源:origin: mattia-battiston/clean-architecture-example
private void whenTheApiToGetTheDeviceDetailsIsCalledForThatDevice() throws UnirestException {
String apiPath = GetBroadbandAccessDeviceEndpoint.API_PATH.replace("{hostname}", HOSTNAME);
String apiUrl = "http://localhost:8080" + apiPath;
log("API Url", apiUrl);
HttpResponse<String> httpResponse = Unirest.get(apiUrl).asString();
responseStatus = httpResponse.getStatus();
log("Response Status", responseStatus);
responseContent = httpResponse.getBody();
log("Response Content", formatJson(responseContent));
}
代码示例来源:origin: mesos/elasticsearch
@Test
public void shouldStartAndServeFile() throws UnknownHostException, UnirestException, InterruptedException {
final SimpleFileServer simpleFileServer = new SimpleFileServer(TEST_FILE);
simpleFileServer.run();
InetSocketAddress address = simpleFileServer.getAddress();
String serverAddress = NetworkUtils.addressToString(address, true);
HttpResponse<String> response = Unirest.get(serverAddress + "/get").asString();
assertEquals(200, response.getStatus());
assertTrue(response.getBody().contains("This is a test file"));
}
内容来源于网络,如有侵权,请联系作者删除!