如何从 java servlet 内以分块响应发送 Http 预告片/页脚?
基本上我的响应标头包含
Transfer-encoding=chunked,
Trailer=[我想发送的一些预告片,例如“SomeTrailer”]
将数据写入 Servlet 输出流后,我正在编写预告片 “SomeTrailer:[value]”,但是 httpclient 没有正确解析它。 httpclient 将整个输入流(包括预告片)视为一个单一的 块。 我还尝试在数据写入输出流后将预告片写入响应标头,但没有成功。
请帮助
我还没有找到任何好的资源。
Basically my response headers contain
Transfer-encoding=chunked,
Trailer=[some trailer I want to send say e.g "SomeTrailer"]
Once I'm done writing the data to the Servlet outputstream, I'm writing the trailer
"SomeTrailer:[value]", but this is not being parsed by the httpclient correctly.
The httpclient considers the whole of inputstream (including the trailer) as a single
chunk.
I've also tried writing the trailer in a response header after the data has been written to the outputstream but without success.
Please help
I haven't found any good sources on this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我最终为此编写了一个简单的单线程网络服务器。事实证明这很容易。服务器非常简单。虽然代码有点粗糙,但主要思想就在那里。
它的作用是将文件内容作为第一个块发送,并将文件的校验和作为页脚发送。
I ended up writing a simple single threaded webserver for this. Turned out it was quite easy. The server is pretty simple. The code's a bit rough though, but the main idea is there.
What it does it sends the filecontents as the first chunk and the checksum of the file as a footer.