Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[网络] 40.Accept 和 Content-Type #977

Open
qiilee opened this issue Feb 24, 2020 · 0 comments
Open

[网络] 40.Accept 和 Content-Type #977

qiilee opened this issue Feb 24, 2020 · 0 comments

Comments

@qiilee
Copy link
Member

qiilee commented Feb 24, 2020

答案:

Accept 请求头用来告知客户端可以处理的内容类型,这种内容类型用 MIME 类型来表示。
服务器使用 Content-Type 应答头通知客户端它的选择。

Accept: text/html
Accept: image/*
Accept: text/html, application/xhtml+xml, application/xml;q=0.9, */*;q=0.8

1.Accept 属于请求头, Content-Type 属于实体头。

Http 报头分为通用报头,请求报头,响应报头和实体报头。

请求方的 http 报头结构:通用报头|请求报头|实体报头

响应方的 http 报头结构:通用报头|响应报头|实体报头

2.Accept 代表发送端(客户端)希望接受的数据类型。

比如:Accept:text/xml;

代表客户端希望接受的数据类型是 xml 类型

Content-Type 代表发送端(客户端|服务器)发送的实体数据的数据类型。

比如:Content-Type:text/html;

代表发送端发送的数据格式是 html。

二者合起来,

Accept:text/xml;

Content-Type:text/html

即代表希望接受的数据类型是 xml 格式,本次请求发送的数据的数据格式是 html。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant