Cookie和请求标头中的字符串之间的区别 [英] difference between cookie and string in request header

查看:116
本文介绍了Cookie和请求标头中的字符串之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在大多数情况下,Cookie只是一小部分信息,客户端将请求标头中的字符串发送给服务器。如果我在Java中的服务器上的请求标头中再添加一个字符串,例如 conn.addRequestProperty( iPlanetDirectoryPro,token); ,那么两者之间有什么区别吗?

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.

致谢,

Maclean Maurice Pinto

Maclean Maurice Pinto

推荐答案

您需要阅读 HTTP规范(消息标头)和 HTTP状态管理规范

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

HTTP规范提供消息头

The HTTP specification provides message headers


每个标头字段由一个名称,一个冒号(:)和
字段值组成。

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

例如,您可以

Content-Length:42

这是标头。

HTTP状态管理规范定义了 Cookie Set-Cookie 标头。这两个是用于在HTTP请求和响应周期中实现状态的特定标头(HTTP是无状态协议)。

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,令牌);那么
两者之间有什么区别吗?

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

是的,有很大的区别。上面是一个简单的请求标头。它与 Cookie 无关。

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

这篇关于Cookie和请求标头中的字符串之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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