计算 Apache.HttpClient 接收了多少数据?

huangapple 未分类评论48阅读模式
英文:

caculate how many data Apache.HttpClient recevied?

问题

我只想在HTTP上测量服务器-客户端的网络速度。

为此,我的服务器API返回大数据(1GB,字节数组),客户端请求此API,但在特定秒数后会被强制断开连接。

然后我将计算有多少客户端收到数据,并将秒数相除。

我正在使用CloseableHttpAsyncClientHttpAsyncRequestProducerAsyncCharConsumer<HttpResponse>。并且我在AsyncCharConsumer<HttpResponse>.onCharReceived()中汇总接收到的数据,并尝试使用HttpGet.abort()断开连接。

当我没有强制断开连接时,汇总的数据是正确的,但此请求被中止,汇总值为0。我该如何解决?谢谢。

Apache HttpComponent异步请求文档示例

英文:

I simply want to measure the network speed server-client on HTTP.

For that, My Server API return the big data(1GB, byte array) and Client request to this API but will disconnect forcingly after specific seconds.

And then I will calculate how many client got and divide seconds.

I am using CloseableHttpAsyncClient, HttpAsyncRequestProducer, AsyncCharConsumer<HttpResponse>. and I summarize received data in AsyncCharConsumer<HttpResponse>.onCharReceived() and try to disconnect using HttpGet.abort().

When I didn't disconnect forcely, summarized mount is correct but this request was aborted, summarized value is 0. How can I get that? thanks.

Apache HttpComponent Async Request Document Example

huangapple
  • 本文由 发表于 2020年5月29日 17:07:48
  • 转载请务必保留本文链接:https://java.coder-hub.com/62082362.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定