在 HTTP 响应正文中发送媒体之前,我要对媒体执行什么编码
我目前正在开发一个 HTTP 服务器。
当客户端请求 PNG 时,我的响应标头格式正确,并以 Content-Type 响应: image/png
我必须对 .png 文件执行哪些步骤和编码过程才能将其作为 byte[] 发送http 响应正文?
谢谢!
I am currently developing a HTTP server.
When a client requests a PNG, my response headers are properly formatted and respond with Content-Type : image/png
What steps and encoding processes do I have to perform on my .png file to send it as a byte[] in the http response body?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
正如其他人所说,没有,但是,为了额外的信用,您的服务器应该在发送文本或 xml 文档(图像已经压缩)时检查客户端是否接受 gzip 编码(查看“accept-encoding”标头),并使用内容编码标头。
还应尊重接受、接受字符集和接受语言。
所有内容均记录在 RFC2616 (HTTP 1.1) 中
As others have said, none, HOWEVER, for extra credit your server should check if the client accepts gzip encoding (look at the 'accept-encoding' header) when sending text or xml documents (images are compressed already) and send gzip with a content-encoding header.
Also accept, accept-charset and accept-language should be respected.
All are documented in RFC2616 (HTTP 1.1)
无,除非由
传输编码
HTTP 标头。
这一切都非常有据可查。
None, unless specified by the
Transfer-Encoding
HTTP header.It is all very well-documented.
没有任何。 只要友善并发送“内容长度”即可。
None. Just be nice and send the "Content-length" as well.