问题描述
我正在编写一个返回字节数组的 RESTful 服务.我知道几种与 HTTP 相关的响应类型,包括 text/html、application/xml 和 image/png(以及其他几种).我不知道与通用字节数组相关联的响应类型.
I am writing a RESTful service that returns an array of bytes. I know of several response types associated with HTTP, including text/html, application/xml, and image/png (among several others). I am unaware of a response type that would be associated with a generic array of bytes.
这样的响应类型存在吗?我不想将字节作为文本发送,而且图像类型似乎都不合适.是否有一种字节"类型表示字节数组?
Does such a response type exist? I don't want to send the bytes as text, and none of the image types seem appropriate. Is there a kind of "byte" type that represents an array of bytes?
有人请指教...
推荐答案
application/octet-stream
为此向 IANA 注册:
application/octet-stream
is registered with IANA for this purpose:
octet-stream"子类型用于表示一个主体包含任意二进制数据.
它实际上是在 RFC 2046,第 4.5.1 节中定义的.
It is actually defined in RFC 2046, section 4.5.1.
这篇关于通用字节响应类型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!