在 HTTP 响应正文中发送媒体之前,我要对媒体执行什么编码

发布于 2024-07-25 10:38:53 字数 178 浏览 5 评论 0原文

我目前正在开发一个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

如果没结果 2024-08-01 10:38:54

正如其他人所说,没有,但是,为了额外的信用,您的服务器应该在发送文本或 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)

你穿错了嫁妆 2024-08-01 10:38:53

无,除非由 传输编码HTTP 标头。

这一切都非常有据可查

None, unless specified by the Transfer-Encoding HTTP header.

It is all very well-documented.

南薇 2024-08-01 10:38:53

没有任何。 只要友善并发送“内容长度”即可。

None. Just be nice and send the "Content-length" as well.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文