简体   繁体   English

在 kuzzle 搜索 javascript-sdk 上获取请求内容长度

[英]Get request Content-Length on kuzzle search javascript-sdk

i wondering how can i get the Content-Length size when i call kuzzle.document.search .我想知道如何在调用kuzzle.document.search时获得 Content-Length 大小。

Any help?有什么帮助吗?

Thanks谢谢

Unfortunately the content of the Content-Length header is not directly available through the Javascript SDK.不幸的是,不能通过 Javascript SDK 直接获得Content-Length标头的Content-Length

You can either send a raw HTTP request to Kuzzle to get this header by yourself or you can approximately compute the total size of the response by hand:您可以向 Kuzzle 发送原始 HTTP 请求以自己获取此标头,也可以手动计算大约响应的总大小:

let result = await sdk.document.search(...);
const contentLength = Buffer.from(JSON.stringify(result._response)).byteLength;

As I say in the comment, I will suggest this feature in our product workshop.正如我在评论中所说,我会在我们的产品研讨会中推荐此功能。 I will keep you informed.我会随时通知你。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM