difference between cookie and string in request header

吃可爱长大的小学妹 提交于 2020-07-08 09:39:05

问题


Cookie is nothing but a small piece of information most of the times a string in the request header send by the client to server. If i add one more string to the request header at server in java like conn.addRequestProperty("iPlanetDirectoryPro", token); then is there any difference between the two? Can the second one be also considered as a cookie.

Regards,

Maclean Maurice Pinto


回答1:


You'll want to read the HTTP specification (message headers) and the HTTP State Management specification.

The HTTP specification provides message headers

Each header field consists of a name followed by a colon (":") and the field value.

For example, you could have

Content-Length:42

This is a header.

The HTTP State Management specification defines the Cookie and Set-Cookie headers. Those are two specific headers that are used for achieving state in HTTP request and response cycles (HTTP is a stateless protocol).

So

conn.addRequestProperty("iPlanetDirectoryPro", token); then is there any difference between the two?

Yes, there is a big difference. The above is a simple request header. It has nothing to do with a Cookie.



来源:https://stackoverflow.com/questions/21226475/difference-between-cookie-and-string-in-request-header

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