How can I display multiple Content-Type in a HTTP response message?

℡╲_俬逩灬. 提交于 2019-12-12 05:04:05

问题


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

ex)

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

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


回答1:


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

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

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



来源:https://stackoverflow.com/questions/46986159/how-can-i-display-multiple-content-type-in-a-http-response-message

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!