如何在HTTP响应消息中显示多个Content-Type? [英] How can I display multiple Content-Type in a HTTP response message?

查看:2015
本文介绍了如何在HTTP响应消息中显示多个Content-Type?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在套接字编程中,我必须显示多个Content-Type。

In a socket programming, I must display multiple Content-Types.

ex)

Content-Type : text/html, text/css, text/javascript, image/png

但是,此代码不起作用。
如何在HTTP响应消息中显示多个Content-Type?
谢谢...

However, this code doesn't work. How can I display multiple Content-Type in a HTTP response message? Thank you...

推荐答案

Content-Type 根据您可能指定的默认内容类型,根据请求者的 Accept 参数,只能是一种类型,但是,如果您的客户对特定类型,它应该在 Accept 请求标头中发送他想要的类型,并且您应该以请求的内容类型作为响应。

Content-Type means should be only one type based on the requester's Accept parameter of a default content type you may specify, however if your client is interested in a specific type, it should send the type he wants in Accept request header and you should respond back with the requested content type.

请求者可能会发送多种类型,例如

requester may send multiple types through to say for example

Accept: application/json
Accept: text/html

这意味着请求者可以理解两种类型。如果服务器可以服务并以 json 格式返回,否则服务器应使用 text / html

which means the requester can understand both types. If server can serve and respond back in json format otherwise it should response back with text/html

有关 Content-Type 标头和其他 HTTP 规范的详细信息,请检查

More info on Content-Type header and other HTTP specs, please check this

这篇关于如何在HTTP响应消息中显示多个Content-Type?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆