zoukankan      html  css  js  c++  java
  • Http协议规范

    HTTP(HyperTextTransferProtocol)是超文本传输协议的缩写,它用于传送WWW方式的数据,关于HTTP协议的详细内容请参考RFC2616

    HTTP协议采用了请求/响应模型。客户端向服务器发送一个请求,请求头包含请求的方法、URI、协议版本、以及包含请求修饰符、客户信息和内容的类似于MIME的消息结构

    服务器以一个状态行作为响应,相应的内容包括消息协议的版本,成功或者错误编码加上包含服务器信息、实体元信息以及可能的实体内容

    • 通常HTTP消息包括客户机向服务器的请求消息和服务器向客户机的响应消息
    • 这两种类型的消息由一个起始行,一个或者多个头域,一个只是头域结束的空行和可选的消息体组成
    • HTTP的头域包括通用头,请求头,响应头和实体头四个部分。每个头域由一个域名,冒号(:)和域值三部分组成
    • 域名是大小写无关的,域值前可以添加任何数量的空格符,头域可以被扩展为多行,在每行开始处,使用至少一个空格或制表符

    通用头域

    通用头域包含请求和响应消息都支持的头域,通用头域包含Cache-Control、Connection、Date、Pragma、Transfer- Encoding、Upgrade、Via

    对通用头域的扩展要求通讯双方都支持此扩展,如果存在不支持的通用头域,一般将会作为实体头域处理。下面简单介绍几个在UPnP消息中使用的通用头域

    Cache-Control头域

    Cache-Control指定请求和响应遵循的缓存机制

    • 在请求消息或响应消息中设置Cache-Control并不会修改另一个消息处理过程中的缓存处理过程
    • 请求时的缓存指令包括no- cache、no-store、max-age、max-stale、min-fresh、only-if-cached
    • 响应消息中的指令包括 public、private、no-cache、no-store、no-transform、must-revalidate、proxy- revalidate、max-age

    各个消息中的指令含义如下

    Public指示响应可被任何缓存区缓存。

    • Private指示对于单个用户的整个或部分响应消息,不能被共享缓存处理。这允许服务器仅仅描述当用户的部分响应消息,此响应消息对于其他用户的请求无效。
    • no-cache指示请求或响应消息不能缓存
    • no-store用于防止重要的信息被无意的发布。在请求消息中发送将使得请求和响应消息都不使用缓存。
    • max-age指示客户机可以接收生存期不大于指定时间(以秒为单位)的响应。
    • min-fresh指示客户机可以接收响应时间小于当前时间加上指定时间的响应。
    • max-stale指示客户机可以接收超出超时期间的响应消息。如果指定max-stale消息的值,那么客户机可以接收超出超时期指定值之内的响应消息。

    Date头域

    Date头域表示消息发送的时间,时间的描述格式由rfc822定义

    例如,Date:Mon,31Dec200104:25:57GMT

    Date描述的时间表示世界标准时,换算成本地时间,需要知道用户所在的时区

    Pragma头域

    Pragma头域用来包含实现特定的指令,最常用的是Pragma:no-cache。在HTTP/1.1协议中,它的含义和Cache-Control:no-cache相同

    请求消息

    请求消息的第一行为下面的格式

    MethodSPRequest- URISPHTTP-VersionCRLFMethod

    SP表示空格

    Request-URI遵循URI格式,在此字段为星号(*)时,说明请求并不用于某个特定的资源地址,而是用于服务器本身

    HTTP- Version表示支持的HTTP版本,例如为HTTP/1.1

    CRLF表示换行回车符

    Method Request-URI HTTP-Version
    Method
    • 表示对于Request-URI完成的方法
    • 这个字段是大小写敏感的,包括OPTIONS、 GET、HEAD、POST、PUT、Delete、TRACE。方法GET和HEAD应该被所有的通用WEB服务器支持
    • GET方法取回由Request-URI标识的信息
    • HEAD方法也是取回由Request-URI标识的信息,只是可以在响应时,不返回消息体
    • POST方法可以请求服务器接收包含在请求中的实体信息,可以用于提交表单,向新闻组、BBS、邮件群组和数据库发送消息

    请求头域允许客户端向服务器传递关于请求或者关于客户机的附加信息

    请求头域可能包含下列字段

    • Accept、Accept-Charset、Accept-Encoding、Accept-Language、
    • Authorization、From、Host、If-Modified-Since、If-Match、If-None-Match
    • If- Range、If-Range、If-Unmodified-Since、Max-Forwards
    • Proxy-Authorization、 Range、Referer、User-Agent

    对请求头域的扩展要求通讯双方都支持,如果存在不支持的请求头域,一般将会作为实体头域处理

    典型的请求消息

    GET http://download.microtool.de:80/somedata.exe
    Host:download.microtool.de
    Accept:*/*
    Pragma:no-cache
    Cache-Control:no-cache
    Referer:http://download.microtool.de/
    User-Agent:Mozilla/4.04[en](Win95;I;Nav)
    Range:bytes=554554-

    通用头部分

    • Request URL:浏览器当前的请求地址
    • Request Method:请求方法(一般是get/post)
    • Status Code:状态码
    • Remote Address:请求的远程地址,ip地址+端口
    • Referrer Policy:监管访问信息来源

    请求头部分

    • Accept:用来告知客户端可以处理的内容类型,这种用MIME类型来表示
    • Accept-Encoding:会将客户端能够理解的内容编码方式(通常是某种压缩算法),服务端会选择一个客户端的提议,并在响应报文首部Content-Encoding中通知客户端选择
    • Accept-Language:表示请求头在客户端声明它可以理解的自然语言,借助内容协商机制,服务端在选项中选择一项,并使用Content-Language应答头通知客户端的选择
    • Connection:决定当前事务完成后,是否会关闭网络连接
    • Cookie:
    • Host:本机地址
    • Referer:包含之前请求的网络被访问的网络页面
    • User-Agent:用户请求的信息,包含浏览器信息等

    Host头域

    • Host头域指定请求资源的Intenet主机和端口号,必须表示请求url的原始服务器或网关的位置
    • HTTP/1.1请求必须包含主机头域,否则系统会以400状态码返回

    Referer头域

    • Referer 头域允许客户端指定请求uri的源资源地址,这可以允许服务器生成回退链表,可用来登陆、优化cache等
    • 他也允许废除的或错误的连接由于维护的目的被追踪
    • 如果请求的uri没有自己的uri地址,Referer不能被发送
    • 如果指定的是部分uri地址,则此地址应该是一个相对地址

    Range头域

    • Range头域可以请求实体的一个或者多个子范围
    • 表示头500个字节:bytes=0-499
    • 表示第二个500字节:bytes=500-999
    • 表示最后500个字节:bytes=-500
    • 表示500字节以后的范围:bytes=500-
    • 第一个和最后一个字节:bytes=0-0,-1
    • 同时指定几个范围:bytes=500-600,601-999

    但是服务器可以忽略此请求头,如果无条件GET包含Range请求头,响应会以状态码206(PartialContent)返回而不是以200(OK)

    User-Agent头域

    User-Agent头域的内容包含发出请求的用户信息

    响应消息

    响应消息的第一行为下面的格式

    HTTP-VersionSPStatus-CodeSPReason-PhraseCRLF

    • HTTP- Version表示支持的HTTP版本,例如为HTTP/1.1
    • Status-Code是一个三个数字的结果代码
    • Reason-Phrase给 Status-Code提供一个简单的文本描述
    • Status-Code主要用于机器自动识别,Reason-Phrase主要用于帮助用户理解

    Status-Code的第一个数字定义响应的类别,后两个数字没有分类的作用

    第一个数字可能取5个不同的值

    • 1xx:信息响应类,表示接收到请求并且继续处理
    • 2xx:处理成功响应类,表示动作被成功接收、理解和接受
    • 3xx:重定向响应类,为了完成指定的动作,必须接受进一步处理
    • 4xx:客户端错误,客户请求包含语法错误或者是不能正确执行
    • 5xx:服务端错误,服务器不能正确执行一个正确的请求

    响应头域允许服务器传递不能放在状态行的附加信息,这些域主要描述服务器的信息和Request-URI进一步的信息

    响应头域包含Age、 Location、Proxy-Authenticate、Public、Retry-After、Server、Vary、Warning、WWW- Authenticate

    对响应头域的扩展要求通讯双方都支持,如果存在不支持的响应头域,一般将会作为实体头域处理

    典型的响应消息

    HTTP/1.0 200 OK
    Date:Mon,31Dec200104:25:57GMT
    Server:Apache/1.3.14(Unix)
    Content-type:text/html
    Last-modified:Tue,17Apr200106:46:28GMT
    Etag:"a030f020ac7c01:1e9f"
    Content-length:39725426
    Content-range:bytes554554-40279979/40279980

    Location响应头

    Location响应头用于重定向接收者到一个新URI地址

    Server响应头

    Server响应头包含处理请求的原始服务器的软件信息

    此域能包含多个产品标识和注释,产品标识一般按照重要性排序

    实体

    请求消息和响应消息都可以包含实体信息,实体信息一般由实体头域和实体组成

    实体头域包含关于实体的原信息

    实体头包括

    • Allow、Content- Base、Content-Encoding、Content-Language
    • Content-Length、Content-Location、 Content-MD5、Content-Range
    • Content-Type、Etag、Expires、Last-Modified、 extension-header

    extension-header允许客户端定义新的实体头,但是这些域可能无法未接受方识别

    实体可以是一个经过编码的字节流,它的编码方式由Content-Encoding或Content-Type定义,它的长度由Content-Length或 Content-Range定义

    Content-Type实体头

    • Content-Type实体头用于向接收方指示实体的介质类型,指定HEAD方法送到接收方的实体介质类型,或GET方法发送的请求介质类型Content-Range实体头
    • Content-Range实体头用于指定整个实体中的一部分的插入位置,他也指示了整个实体的长度
    • 在服务器向客户返回一个部分响应,它必须描述响应覆盖的范围和整个实体长度

    一般格式

    Content-Range:bytes-unitSPfirst-byte-pos-last-byte-pos/entity-legth

    传送头500个字节次字段的形式:

    • Content-Range:bytes0-499/1234如果一个http消息包含此节(例如,对范围请求的响应或对一系列范围的重叠请求)
    • Content-Range表示传送的范围
    • Content-Length表示实际传送的字节数
    • Last-modified实体头
    • Last-modified实体头指定服务器上保存内容的最后修订时间

    HTTP协议(RFC2616)方法定义

    OPTIONS

    OPTIONS 方法表示在由 Request-URI 标识的请求/响应链上关于有效通迅选项信息的请求

    • 该方法允许客户端判断与某个资源相关的选项和/或需求或者服务器的能力,而不需要采用资源行为或发起资源获取
    • 该方法的响应不能缓存
    • 如果OPTIONS请求包括实体(如由 Content-Length或 Transfer-Encoding的存在表示),这时媒体类型必须通过 Content-Type 域表示

    尽管本规范没有定义该实体的用法,将来的HTTP 扩展可能使用 OPTIONS 消息体来更详细地查询服务器的信息

    服务器不支持该扩展,可以丢弃该请求消息体
    如果 Request-URI 是星号(“*”),OPTIONS 请求通常试图应用于服务器而不是特定的资源。

    由于服务器的通迅选项一般由资源决定,所以“*”请求只作为“ping”或“no-op”类型的方法有用

    它没有任何作用,除了允许客户端测试服务器的能力

    例如,可用来测试HTTP/1.1 代理的一致性(或缺少因素)。
    如果 Request-URI不是星号,OPTIONS请求只应用于与该资源通迅时的有效选项。

    200 响应应该包括任何头部域来表示服务器实现和可应用到该资源的可选特性(如Allow),可能包括该规范没有定义的扩展

    如果有响应消息体,则应该还包括通迅选项的信息

    本规范没有定义该消息体的格式,但可能在将来扩展 HTTP时定义

    内容协商可用于选择适当的响应格式,如果不包括响应消息体,则响应必须包括域值为“0”的 Content-Length 域

    Max-Forwards 请求头部域可能用于请求链中定位特定代理

    • 当代理收到关于允许请求转发的absoluteURI的OPTIONS请求时, 代理必须检查Max-Forwards域
    • 如果Max-Forwards域值为0(“0” ),则代理不能转发该消息
    • 取而代之,代理应该以它自己的通迅选项来响应
    • 如果 Max-Forwards 域值是大于 0 的整数,代理在转发该请求时必须将域值减一
    • 如果请求中不存在 Max-Forwards域,则转发的请求中不能包括Max-Forwards域

    GET

    • GET 方法即获取由 Request-URI 标识的任何信息(以实体的形式)
    • 如果 Request-URI引用某个数据处理过程,则应该以它产生的数据作为在响应中的实体,而不是该过程的源代码文本,除非该过程碰巧输出该文本
    • 如果请求消息包括 If-Modified-Since、If-Unmodified-Since、If-Match、If-None-Match或者If-Range头部域,则GET方法的语义变为“条件GET”
    • 条件 GET方法请求只传输在条件头部域描述情形下的实体
    • 条件 GET 方法试图通过允许刷新缓存的实体而不需要多次请求或传输客户端已经拥有的数据来减少非必要的网络使用
    • 如果请求消息包括 Range头部域,则 GET方法的语义变为“局部 GET”
    • 局部 GET请求只需传输实体的某部分

    HEAD

    除了服务器不能在响应中返回消息体,HEAD 方法与 GET 相同

    • HEAD 请求的响应中的HTTP 头部中包含的元信息应该与 GET 请求发送的响应中的信息相同
    • 该方法可用来获取请求暗示实体的元信息, 而不需要传输实体本身
    • 该方法常用来测试超文本链接的有效性、可用性和最近的修改。
    • 当响应中包含的信息可用于更新先前从该资源缓存的实体时, HEAD 请求的响应可能是可缓冲的
    • 如果新的域值表明该缓冲的实体与当前实体不同(如可通过 Content-Length、Content-MD5、ETag或Last-Modified的区别来表示)
    • 这时缓冲服务器必须将该缓存实体作为过期的

    POST

    POST 方法用来请求原始服务器接受请求中封装的实体作为从属于请求行中的Request-URI标识的副属。POST设计允许完成下列功能的统一方法:

    • 注解存在资源;
    • 上传消息到论坛、新闻组或相似的讨论组
    • 向数据处理过程提供数据块,如递交表单的结果
    • 通过追加操作来扩展数据库

    POST 方法执行的实际功能由服务器决定,且通常取决于 Request-URI

    上传的实体从属于该URI,通过文件从属于包含它的目录,新的论文从属于它上传的新闻组,或记录从属于数据库的方式

    POST方法执行的行为可能不导致通过 URI 能够标识的某个资源

    在这种情况下,200(OK)或 204(No Content)都是适合的响应状态

    这取决于描述结果的响应是否包括实体,如果原始服务器创建了资源,响应应该是 201(Created),且包含描述请求状态的实体,和新资源的引用,和Location头部

    该方法的响应不能缓存,除非响应包括适当的Cache-Control或 Expires头部域

    303(See Other)响应能够用来引导用户代理获取可缓存的资源

    PUT

    PUT方法请求以提供的Request-URI存储封装的实体
    如果 Request-URI引用已经存在的资源,该封装实体应该被认作原始服务器存储的修改版本

    如果 Request-URI没有指向已存在的资源, 且该URI可以被请求的用户代理定义为新的资源

    则原始服务器可以用该 URI创建资源

    如果创建了新的资源,则原始服务器必须通过 201(Created)响应提示用户代理
    如果修改了已存在的资源,则应该发送200(OK)或 204(No Content)响应代码来表示成功完成了请求

    如果不能按 Request-URI创建或修改资源,则应该给出适当的错误响应以反映出问题的性质

    实体的接受方不能乎略任何不理解或没有实现的 Content-*(如Content-Range)头部,在这种情况下必须返回 501(Not Implemented)响应。
    如果请求通过缓冲服务器且Request-URI标识出一个或多个缓冲的实体,则应该认为这些实体过期了。该方法的响应不可缓存。

    POST和PUT请求间的基本区别反映在 Request-URI 的不统一

    POST请求中 URI 标识的资源将处理封装的实体

    • 该资源可能是数据接收过程、其它协议的网关或接受注解的独立实体
    • 与此对应,PUT请求中的URI标识请求封装的实体——用户代理知道该 URI是目标且服务器不能试图将该请求应用到其它资源上
    • 如果服务器希望该请求应用到不同的 URI上,则它必须发送301(Moved Permanently)请求

    这时客户代理可以自己决定是否要重定向该请求,可以用许多不同的 URI 标识同个资源

    例如,一篇文章可以有标识为“当前版本”的URI,它独立于标识每个特别版本的 URI

    在这种情况下,使用通用 URI 的 PUT 请求可能造成原始服务器定义的一些不同URI的结果,HTTP/1.1 没有定义PUT方法如何影响原始服务器的状态

    除了其它特殊实体头部的规定,PUT 请求中的实体头部应该应用到 PUT 创建或修改的资源上

    DELETE

    DELETE 方法请求原始服务器删除Request-URI 标识的资源

    原始服务器可在人为干涉下(或其它意思)屏闭该方法

    客户端不能确保该操作已经提交,即使原始服务器发出的状,态码表明动作已经成功完成也如此

    然而,在给出响应的时候,服务器不应该表示成功,除非它试图删除该资源或将它移动到不可访问的位置

    如果响应包含描述状态的实体,成功响应应该是200(OK)

    如果动作没有实施,则是202(Accepted)

    如果动作已经实施但响应不包含实体,则是 204(No Content)

    如果请求通过缓冲服务器,且Request-URI标识一个或多个当前缓存的实体,则应该认为这些实体已经过期。该方法的响应不可缓存

    TRACE

    TRACE 方法用于引起远程的,该请求消息的应用层回射

    请求的最终接收者应该反射200(OK)响应,并以该消息作为客户端回收消息的实体

    最终接收者是原始服务器或第一个收到请求中的Max-Forwards值为0(0)的代理或网关

    TRACE 请求不能包括实体

    TRACE 允许客户端看见请求链上的另一端收到了什么,然后使用该数据作为测试或诊断信息

    Via 头部域的值有特殊作用,将它作为请求链路径

    使用Max-Forwards头部域允许客户端限制请求链的长度,这对于测试无限循环转发消息的代理链非常有用

    如请求有效,则响应应该在实体中包含整个请求消息,设置 Content-Type 为“message/http” ,该方法的响应不能缓存

    CONNECT

    规范保留 CONNECT 方法名。该方法用于代理,使之能够动态切换隧道(例如 SSL隧道)

    Requests

    Field nameDescriptionExample
    Accept Content-Types that are acceptable Accept: text/plain
    Accept-Charset Character sets that are acceptable Accept-Charset: utf-8
    Accept-Encoding Acceptable encodings Accept-Encoding: <compress | gzip | identity>
    Accept-Language Acceptable languages for response Accept-Language: en-US
    Accept-Ranges Allows the server to indicate its acceptance of range requests for a resource Accept-Ranges: bytes
    Authorization Authentication credentials for HTTP authentication Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
    Cache-Control Used to specify directives that MUST be obeyed by all caching mechanisms along the request/response chain Cache-Control: no-cache
    Connection What type of connection the user-agent would prefer Connection: close
    Cookie an HTTP cookie previously sent by the server with Set-Cookie (below) Cookie: $Version=1; Skin=new;
    Content-Length The length of the request body in octets (8-bit bytes) Content-Length: 348
    Content-Type The mime type of the body of the request (used with POST and PUT requests) Content-Type: application/x-www-form-urlencoded
    Date The date and time that the message was sent Date: Tue, 15 Nov 1994 08:12:31 GMT
    Expect Indicates that particular server behaviors are required by the client Expect: 100-continue
    From The email address of the user making the request From: user@email.com
    Host The domain name of the server (for virtual hosting), mandatory since HTTP/1.1 Host: en.wikipedia.org
    If-Match Only perform the action if the client supplied entity matches the same entity on the server. This is mainly for methods like PUT to only update a resource if it has not been modified since the user last updated it. If-Match: "737060cd8c284d8af7ad3082f209582d"
    If-Modified-Since Allows a 304 Not Modified to be returned if content is unchanged If-Modified-Since: Sat, 29 Oct 1994 19:43:31 GMT
    If-None-Match Allows a 304 Not Modified to be returned if content is unchanged, see HTTP ETag If-None-Match: "737060cd8c284d8af7ad3082f209582d"
    If-Range If the entity is unchanged, send me the part(s) that I am missing; otherwise, send me the entire new entity If-Range: "737060cd8c284d8af7ad3082f209582d"
    If-Unmodified-Since Only send the response if the entity has not been modified since a specific time. If-Unmodified-Since: Sat, 29 Oct 1994 19:43:31 GMT
    Max-Forwards Limit the number of times the message can be forwarded through proxies or gateways. Max-Forwards: 10
    Pragma Implementation-specific headers that may have various effects anywhere along the request-response chain. Pragma: no-cache
    Proxy-Authorization Authorization credentials for connecting to a proxy. Proxy-Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
    Range Request only part of an entity. Bytes are numbered from 0. Range: bytes=500-999
    Referer This is the address of the previous web page from which a link to the currently requested page was followed. Referer: http://en.wikipedia.org/wiki/Main_Page
    TE The transfer encodings the user agent is willing to accept: the same values as for the response header Transfer-Encoding can be used, plus the "trailers" value (related to the "chunked" transfer method) to notify the server it accepts to receive additional headers (the trailers) after the last, zero-sized, chunk. TE: trailers,deflate;q=0.5
    Upgrade Ask the server to upgrade to another protocol. Upgrade: HTTP/2.0, SHTTP/1.3, IRC/6.9, RTA/x11
    User-Agent The user agent string of the user agent User-Agent: Mozilla/5.0 (Linux; X11)
    Via Informs the server of proxies through which the request was sent. Via: 1.0 fred, 1.1 nowhere.com (Apache/1.1)
    Warning A general warning about possible problems with the entity body. Warning: 199 Miscellaneous warning

    Responses

    Field nameDescriptionExample
    Accept-Ranges What partial content range types this server supports Accept-Ranges: bytes
    Age The age the object has been in a proxy cache in seconds Age: 12
    Allow Valid actions for a specified resource. To be used for a 405 Method not allowed Allow: GET, HEAD
    Cache-Control Tells all caching mechanisms from server to client whether they may cache this object Cache-Control: no-cache
    Content-Encoding The type of encoding used on the data Content-Encoding: gzip
    Content-Language The language the content is in Content-Language: da
    Content-Length The length of the response body in octets (8-bit bytes) Content-Length: 348
    Content-Location An alternate location for the returned data Content-Location: /index.htm
    Content-Disposition An opportunity to raise a "File Download" dialogue box for a known MIME type Content-Disposition: attachment; filename=fname.ext
    Content-MD5 Base64-encoded binary MD5 sum of the content of the response Content-MD5: Q2hlY2sgSW50ZWdyaXR5IQ==
    Content-Range Where in a full body message this partial message belongs Content-Range: bytes 21010-47021/47022
    Content-Type The mime type of this content Content-Type: text/html; charset=utf-8
    Date The date and time that the message was sent Date: Tue, 15 Nov 1994 08:12:31 GMT
    ETag An identifier for a specific version of a resource, often a Message Digest, see ETag ETag: "737060cd8c284d8af7ad3082f209582d"
    Expires Gives the date/time after which the response is considered stale Expires: Thu, 01 Dec 1994 16:00:00 GMT
    Last-Modified The last modified date for the requested object, in RFC 2822 format Last-Modified: Tue, 15 Nov 1994 12:45:26 GMT
    Location Used in redirection, or when a new resource has been created. Location: http://www.w3.org/pub/WWW/People.html
    Pragma Implementation-specific headers that may have various effects anywhere along the request-response chain. Pragma: no-cache
    Proxy-Authenticate Request authentication to access the proxy. Proxy-Authenticate: Basic
    Refresh Used in redirection, or when a new resource has been created. This refresh redirects after 5 seconds.
    (This is a proprietary/non-standard header extension introduced by Netscape and supported by most web browsers.)
    Refresh: 5; url=http://www.w3.org/pub/WWW/People.html
    Retry-After If an entity is temporarily unavailable, this instructs the client to try again after a specified period of time. Retry-After: 120
    Server A name for the server Server: Apache/1.3.27 (Unix) (Red-Hat/Linux)
    Set-Cookie an HTTP cookie Set-Cookie: UserID=JohnDoe; Max-Age=3600; Version=1
    Trailer The Trailer general field value indicates that the given set of header fields is present in the trailer of a message encoded with chunked transfer-coding. Trailer: Max-Forwards
    Transfer-Encoding The form of encoding used to safely transfer the entity to the user. Currently defined methodsare: chunked, compress, deflate, gzip, identity. Transfer-Encoding: chunked
    Vary Tells downstream proxies how to match future request headers to decide whether the cached response can be used rather than requesting a fresh one from the origin server. Vary: *
    Via Informs the client of proxies through which the response was sent. Via: 1.0 fred, 1.1 nowhere.com (Apache/1.1)
    Warning A general warning about possible problems with the entity body. Warning: 199 Miscellaneous warning
    WWW-Authenticate Indicates the authentication scheme that should be used to access the requested entity. WWW-Authenticate: Basic

    Common non-standard headers

    Non-standard headers can be used, with the convention of prefixing the header name with X-

    Field nameDescriptionExample
    X-Frame-Options[2] Clickjacking protection. DENY - no rendering within a frame, SAMEORIGIN - no rendering if origin mismatch X-Frame-Options: DENY
    X-XSS-Protection[citation needed] Cross-site scripting (XSS) filter X-XSS-Protection: 1; mode=block
    X-Requested-With[3] mainly used to identify Ajax requests. Most JavaScript frameworks send this header with value of XMLHttpRequest X-Requested-With: XMLHttpRequest
    X-Forwarded-For[4] a de facto standard for identifying the originating IP address of a client connecting to a web server through an HTTP proxy or load balancer X-Forwarded-For: client1, proxy1, proxy2
    X-Forwarded-Proto[citation needed] a de facto standard for identifying the originating protocol of an HTTP request, since a reverse proxy (load balancer) communicates with a web server using HTTP X-Forwarded-Proto: https
    论读书
    睁开眼,书在面前
    闭上眼,书在心里
  • 相关阅读:
    js插件ztree使用
    asp.net错误页和asp.net mvc错误页设置
    C#实现Excel的导入导出
    ios开发UI篇—使用纯代码自定义UItableviewcell实现一个简单的微博界面布局
    iOS开发UI篇—UITabBarController简单介绍
    iOS开发UI篇—字典转模型
    iOS开发UI篇—从代码的逐步优化看MVC
    iOS开发UI篇—九宫格坐标计算
    iOS开发UI篇—transframe属性(形变)
    iOS开发UI篇—懒加载
  • 原文地址:https://www.cnblogs.com/YC-L/p/14472311.html
Copyright © 2011-2022 走看看