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

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

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

HttpRequest.asBinary介绍

暂无

代码示例

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

@Override
public File stopVideoCapture(String outputFile) {
  if (nodeUrl == null) {
    throw new ScenarioException("You cannot stop video capture before driver has been created and corresponding node instanciated");
  }
  
  logger.info("stopping capture");
  try {
    HttpResponse<InputStream> videoResponse = Unirest.get(String.format("%s%s", nodeUrl, NODE_TASK_SERVLET))
      .queryString("action", "stopVideoCapture")
      .queryString("session", sessionId).asBinary();
    InputStream videoI = videoResponse.getBody();
    
    File videoFile = new File(outputFile);
    FileOutputStream os = new FileOutputStream(videoFile);
    IOUtils.copy(videoI, os);
    os.close();
    
    return videoFile;
    
  } catch (UnirestException | IOException e) {
    logger.warn(String.format("Could not stop video capture: %s", e.getMessage()));
    return null;
  }
}

代码示例来源:origin: hatboysam/JavaSnap

private static HttpResponse<InputStream> requestStoryBinary(String path) throws UnirestException {
  HttpRequest req = Unirest.get(BASE_URL + path)
      .header(JSON_TYPE_KEY, JSON_TYPE)
      .header(USER_AGENT_KEY, USER_AGENT);
  // Execute and return as bytes
  HttpResponse<InputStream> resp = req.asBinary();
  // Record
  lastRequestPath = path;
  lastResponse = resp;
  lastResponseBodyClass = InputStream.class;
  return resp;
}

代码示例来源: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);
  }
}

代码示例来源:origin: Apicurio/apicurio-studio

HttpResponse<InputStream> response = request.asBinary();

相关文章