com.mashape.unirest.request.HttpRequest.asString()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(6.1k)|赞(0)|评价(0)|浏览(126)

本文整理了Java中com.mashape.unirest.request.HttpRequest.asString()方法的一些代码示例,展示了HttpRequest.asString()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。HttpRequest.asString()方法的具体详情如下:
包路径:com.mashape.unirest.request.HttpRequest
类名称:HttpRequest
方法名:asString

HttpRequest.asString介绍

暂无

代码示例

代码示例来源:origin: lets-blade/blade

protected String bodyToString(String path) throws Exception {
  return get(path).asString().getBody();
}

代码示例来源:origin: com.infotel.seleniumRobot/core

@Override
public void startVideoCapture() {
  if (nodeUrl == null) {
    throw new ScenarioException("You cannot start video capture before driver has been created and corresponding node instanciated");
  }
  
  logger.info("starting capture");
  try {
    Unirest.get(String.format("%s%s", nodeUrl, NODE_TASK_SERVLET))
      .queryString("action", "startVideoCapture")
      .queryString("session", sessionId).asString();
  } catch (UnirestException e) {
    logger.warn(String.format("Could start video capture: %s", e.getMessage()));
  }
}

代码示例来源:origin: com.infotel.seleniumRobot/core

/**
 * returns the list of processes, on the node, whose name without extension is the requested one
 * e.g: getProcessList("WINWORD")
 * Case will be ignored
 */
@Override
public List<Integer> getProcessList(String processName) {
  if (nodeUrl == null) {
    throw new ScenarioException("You cannot get a remote process before driver has been created and corresponding node instanciated");
  }
  
  logger.info("getting process list for: " + processName);
  try {
    List<String> pidListStr = Arrays.asList(Unirest.get(String.format("%s%s", nodeUrl, NODE_TASK_SERVLET))
      .queryString("action", "processList")
      .queryString("name", processName)
      .asString()
      .getBody()
      .split(","));
    return pidListStr.stream().map(Integer::valueOf).collect(Collectors.toList());
  } catch (UnirestException e) {
    logger.warn(String.format("Could not get process list of %s: %s", processName, e.getMessage()));
  }
  
  return new ArrayList<>();
}

代码示例来源:origin: forcelate/forcelate-benchmarks

@Override
public void ticker() throws IOException, UnirestException {
  HttpResponse<String> response = Unirest.get(POLONIEX_BASE_URL)
      .queryString(COMMAND_QUERY_KEY, "returnTicker")
      .asString();
  unirestParamsClient.ticker(response, POLONIEX);
}

代码示例来源:origin: com.infotel.seleniumRobot/core

/**
 * Take screenshot of the full desktop
 * @return a string with base64 content of the image
 */
@Override
public String captureDesktopToBuffer() {
  if (nodeUrl == null) {
    throw new ScenarioException("You cannot take screenshot before driver has been created and corresponding node instanciated");
  }
  
  logger.info("capturing desktop");
  try {
    return Unirest.get(String.format("%s%s", nodeUrl, NODE_TASK_SERVLET))
      .queryString("action", "screenshot")
      .asString().getBody();
    
  } catch (UnirestException e) {
    logger.warn(String.format("Could not capture desktop: %s", e.getMessage()));
  }
  return "";
}

代码示例来源: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: forcelate/forcelate-benchmarks

@Override
public void orderBook() throws IOException, UnirestException {
  HttpResponse<String> response = Unirest.get(ORDER_BOOK_URL)
      .queryString(PAIR_QUERY_KEY, PAIR_QUERY_VALUE)
      .queryString("count", "100")
      .asString();
  unirestParamsClient.orderBook(response, KRAKEN);
}

代码示例来源:origin: forcelate/forcelate-benchmarks

@Override
public void orderBook() throws IOException, UnirestException {
  HttpResponse<String> response = Unirest.get(POLONIEX_BASE_URL)
      .queryString(COMMAND_QUERY_KEY, "returnOrderBook")
      .queryString("currencyPair", "all")
      .queryString("depth", "100")
      .asString();
  unirestParamsClient.orderBook(response, POLONIEX);
}

代码示例来源:origin: gradle.plugin.GoBqa/gradle-plugin

response = getRequestNoBody.asString();
}catch (Exception ex){
  track.fail("Getrequest:Error during call Api Rest op from URL::"+getRequestNoBody.getUrl() +"' \n" + ex.getMessage());

代码示例来源:origin: forcelate/forcelate-benchmarks

@Override
  public void trades() throws IOException, UnirestException {
    HttpResponse<String> response = Unirest.get(POLONIEX_BASE_URL)
        .queryString(COMMAND_QUERY_KEY, "returnTradeHistory")
        .queryString("currencyPair", "BTC_NXT")
        .queryString("start", "1410158341")
        .queryString("end", "1410158341")
        .asString();
    unirestParamsClient.trades(response, POLONIEX);
  }
}

代码示例来源:origin: gradle.plugin.GoBqa/gradle-plugin

response = postRequestNoBody.asString();
} catch (Exception ex) {
  track.fail("Postrequest:Error during call Api Rest op from URL::" + postRequestNoBody.getUrl() + "' \n" + ex.getMessage());

代码示例来源:origin: CognitiveJ/cognitivej

private T doWork() {
  try {
    setupErrorHandlers();
    WorkingContext workingContext = workingContext();
    HttpRequest builtRequest = buildUnirest(workingContext)
        .queryString(workingContext.getQueryParams())
        .headers(workingContext.getHeaders()).header("Ocp-Apim-Subscription-Key", cognitiveContext.subscriptionKey);
    if (!workingContext.getHttpMethod().equals(HttpMethod.GET) && workingContext().getPayload().size() > 0) {
      buildBody((HttpRequestWithBody) builtRequest);
    }
    HttpResponse response;
    if (typedResponse() == InputStream.class)
      response = builtRequest.asBinary();
    else
      response = builtRequest.asString();
    checkForError(response);
    return postProcess(typeResponse(response.getBody()));
  } catch (UnirestException | IOException e) {
    throw new CognitiveException(e);
  }
}

相关文章