yanzhenjie / AndServer

:cherries: Web server and web framework of Android platform.
https://yanzhenjie.com/AndServer
Apache License 2.0
3.74k stars 755 forks source link

AndServer如何支持chunked 内容回传? #537

Closed wudelun closed 7 months ago

wudelun commented 7 months ago

请问如何在AndServer 上支持http 标准的chunked 分块传输编码方式呢?

目前我遇到希望通过chunked 连续传输N个json 数据

wudelun commented 7 months ago

@CrossOrigin(methods = {RequestMethod.POST, RequestMethod.GET}) @GetMapping("/api/stream") StreamBody stream() { ChunkedJsonInputStream chunkedJsonInputStream = new ChunkedJsonInputStream(); InventoryManager.getInstance().setChunkedJsonInputStream(chunkedJsonInputStream); return new StreamBody(chunkedJsonInputStream); } 最终使用StreamBody 实现ChunkedJsonInputStream协议。问题我就先关闭了