首页 文章

泽西http客户端

提问于
浏览
0

我正在使用jersey http客户端向一些远程API发送请求 . 我需要测量向服务器发送请求所需的时间,并等待它被处理并且服务器返回一些状态代码 . 我有什么方法可以用球衣做到这一点?这是我的post方法代码:

public Response post(String targetUrl, Entity entity)
  {
    return client.target(targetUrl)
        .request()
        .accept(MediaType.APPLICATION_JSON_TYPE)
        .header(SERVER_AUTH, true)
        .post(entity);
  }

1 回答

  • 0

    实际上,这是我的错 . 默认情况下,此客户端已同步,因此它会阻止线程,直到收到响应 . 但我的问题是URL不正确,代码立即返回状态'Resouce not found' .

相关问题