双魚蓮花 發表於 2019-10-25 09:10:00

PHP header函数设置http头

<div class="cnblogs_code">
<pre><span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">定义编码</span>
<span style="color: rgba(0, 128, 128, 1)">header</span>( 'Content-Type:text/html;charset=utf-8 '<span style="color: rgba(0, 0, 0, 1)">);

</span><span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">Atom</span>
<span style="color: rgba(0, 128, 128, 1)">header</span>('Content-type: application/atom+xml'<span style="color: rgba(0, 0, 0, 1)">);

</span><span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">CSS</span>
<span style="color: rgba(0, 128, 128, 1)">header</span>('Content-type: text/css'<span style="color: rgba(0, 0, 0, 1)">);

</span><span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">Javascript</span>
<span style="color: rgba(0, 128, 128, 1)">header</span>('Content-type: text/javascript'<span style="color: rgba(0, 0, 0, 1)">);

</span><span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">JPEG Image</span>
<span style="color: rgba(0, 128, 128, 1)">header</span>('Content-type: image/jpeg'<span style="color: rgba(0, 0, 0, 1)">);

</span><span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">JSON</span>
<span style="color: rgba(0, 128, 128, 1)">header</span>('Content-type: application/json'<span style="color: rgba(0, 0, 0, 1)">);

</span><span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">PDF</span>
<span style="color: rgba(0, 128, 128, 1)">header</span>('Content-type: application/pdf'<span style="color: rgba(0, 0, 0, 1)">);

</span><span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">RSS</span>
<span style="color: rgba(0, 128, 128, 1)">header</span>('Content-Type: application/rss+xml; charset=ISO-8859-1'<span style="color: rgba(0, 0, 0, 1)">);

</span><span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">Text (Plain)</span>
<span style="color: rgba(0, 128, 128, 1)">header</span>('Content-type: text/plain'<span style="color: rgba(0, 0, 0, 1)">);

</span><span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">XML</span>
<span style="color: rgba(0, 128, 128, 1)">header</span>('Content-type: text/xml'<span style="color: rgba(0, 0, 0, 1)">);

</span><span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)"> ok</span>
<span style="color: rgba(0, 128, 128, 1)">header</span>('HTTP/1.1 200 OK'<span style="color: rgba(0, 0, 0, 1)">);

</span><span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">设置一个404头:</span>
<span style="color: rgba(0, 128, 128, 1)">header</span>('HTTP/1.1 404 Not Found'<span style="color: rgba(0, 0, 0, 1)">);

</span><span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">设置地址被永久的重定向</span>
<span style="color: rgba(0, 128, 128, 1)">header</span>('HTTP/1.1 301 Moved Permanently'<span style="color: rgba(0, 0, 0, 1)">);

</span><span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">转到一个新地址</span>
<span style="color: rgba(0, 128, 128, 1)">header</span>('Location: http://www.example.org/'<span style="color: rgba(0, 0, 0, 1)">);

</span><span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">文件延迟转向:</span>
<span style="color: rgba(0, 128, 128, 1)">header</span>('Refresh: 10; url=http://www.example.org/'<span style="color: rgba(0, 0, 0, 1)">);
</span><span style="color: rgba(0, 0, 255, 1)">print</span> 'You will be redirected in 10 seconds'<span style="color: rgba(0, 0, 0, 1)">;

</span><span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">当然,也可以使用html语法实现
// &lt;meta http-equiv="refresh" content="10;http://www.example.org/ /&gt;

// override X-Powered-By: PHP:</span>
<span style="color: rgba(0, 128, 128, 1)">header</span>('X-Powered-By: PHP/4.4.0'<span style="color: rgba(0, 0, 0, 1)">);
</span><span style="color: rgba(0, 128, 128, 1)">header</span>('X-Powered-By: Brain/0.6b'<span style="color: rgba(0, 0, 0, 1)">);

</span><span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">文档语言</span>
<span style="color: rgba(0, 128, 128, 1)">header</span>('Content-language: en'<span style="color: rgba(0, 0, 0, 1)">);

</span><span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">告诉浏览器最后一次修改时间</span>
<span style="color: rgba(128, 0, 128, 1)">$time</span> = <span style="color: rgba(0, 128, 128, 1)">time</span>() - 60; <span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)"> or filemtime($fn), etc</span>
<span style="color: rgba(0, 128, 128, 1)">header</span>('Last-Modified: '.<span style="color: rgba(0, 128, 128, 1)">gmdate</span>('D, d M Y H:i:s', <span style="color: rgba(128, 0, 128, 1)">$time</span>).' GMT'<span style="color: rgba(0, 0, 0, 1)">);

</span><span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">告诉浏览器文档内容没有发生改变</span>
<span style="color: rgba(0, 128, 128, 1)">header</span>('HTTP/1.1 304 Not Modified'<span style="color: rgba(0, 0, 0, 1)">);

</span><span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">设置内容长度</span>
<span style="color: rgba(0, 128, 128, 1)">header</span>('Content-Length: 1234'<span style="color: rgba(0, 0, 0, 1)">);

</span><span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">设置为一个下载类型</span>
<span style="color: rgba(0, 128, 128, 1)">header</span>('Content-Type: application/octet-stream'<span style="color: rgba(0, 0, 0, 1)">);
</span><span style="color: rgba(0, 128, 128, 1)">header</span>('Content-Disposition: attachment; filename="example.zip"'<span style="color: rgba(0, 0, 0, 1)">);
</span><span style="color: rgba(0, 128, 128, 1)">header</span>('Content-Transfer-Encoding: binary'<span style="color: rgba(0, 0, 0, 1)">);
</span><span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)"> load the file to send:</span>
<span style="color: rgba(0, 128, 128, 1)">readfile</span>('example.zip'<span style="color: rgba(0, 0, 0, 1)">);

</span><span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)"> 对当前文档禁用缓存</span>
<span style="color: rgba(0, 128, 128, 1)">header</span>('Cache-Control: no-cache, no-store, max-age=0, must-revalidate'<span style="color: rgba(0, 0, 0, 1)">);
</span><span style="color: rgba(0, 128, 128, 1)">header</span>('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); <span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)"> Date in the past</span>
<span style="color: rgba(0, 128, 128, 1)">header</span>('Pragma: no-cache'<span style="color: rgba(0, 0, 0, 1)">);

</span><span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">设置内容类型:</span>
<span style="color: rgba(0, 128, 128, 1)">header</span>('Content-Type: text/html; charset=iso-8859-1'<span style="color: rgba(0, 0, 0, 1)">);
</span><span style="color: rgba(0, 128, 128, 1)">header</span>('Content-Type: text/html; charset=utf-8'<span style="color: rgba(0, 0, 0, 1)">);
</span><span style="color: rgba(0, 128, 128, 1)">header</span>('Content-Type: text/plain'); <span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">纯文本格式</span>
<span style="color: rgba(0, 128, 128, 1)">header</span>('Content-Type: image/jpeg'); <span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">JPG***</span>
<span style="color: rgba(0, 128, 128, 1)">header</span>('Content-Type: application/zip'); <span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)"> ZIP文件</span>
<span style="color: rgba(0, 128, 128, 1)">header</span>('Content-Type: application/pdf'); <span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)"> PDF文件</span>
<span style="color: rgba(0, 128, 128, 1)">header</span>('Content-Type: audio/mpeg'); <span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)"> 音频文件</span>
<span style="color: rgba(0, 128, 128, 1)">header</span>('Content-Type: application/x-shockw**e-flash'); <span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">Flash动画

//显示登陆对话框</span>
<span style="color: rgba(0, 128, 128, 1)">header</span>('HTTP/1.1 401 Unauthorized'<span style="color: rgba(0, 0, 0, 1)">);
</span><span style="color: rgba(0, 128, 128, 1)">header</span>('WWW-Authenticate: Basic realm="Top Secret"'<span style="color: rgba(0, 0, 0, 1)">);
</span><span style="color: rgba(0, 0, 255, 1)">print</span> 'Text that will be displayed if the user hits cancel or '<span style="color: rgba(0, 0, 0, 1)">;
</span><span style="color: rgba(0, 0, 255, 1)">print</span> 'enters wrong login data';</pre>
</div>
<p>&nbsp;</p>
<h4>HTTP header 详解</h4>
<h4>Requests部分</h4>
<div>
<table class="table table-bordered" border="1" cellpadding="0">
<tbody>
<tr><th><span style="font-size: 13px">Header</span></th><th><span style="font-size: 13px">解释</span></th><th><span style="font-size: 13px">示例</span></th></tr>
<tr>
<td><span style="font-size: 13px">Accept</span></td>
<td><span style="font-size: 13px">指定客户端能够接收的内容类型</span></td>
<td><span style="font-size: 13px">Accept: text/plain, text/html</span></td>
</tr>
<tr>
<td><span style="font-size: 13px">Accept-Charset</span></td>
<td><span style="font-size: 13px">浏览器可以接受的字符编码集。</span></td>
<td><span style="font-size: 13px">Accept-Charset: iso-8859-5</span></td>
</tr>
<tr>
<td><span style="font-size: 13px">Accept-Encoding</span></td>
<td><span style="font-size: 13px">指定浏览器可以支持的web服务器返回内容压缩编码类型。</span></td>
<td><span style="font-size: 13px">Accept-Encoding: compress, gzip</span></td>
</tr>
<tr>
<td><span style="font-size: 13px">Accept-Language</span></td>
<td><span style="font-size: 13px">浏览器可接受的语言</span></td>
<td><span style="font-size: 13px">Accept-Language: en,zh</span></td>
</tr>
<tr>
<td><span style="font-size: 13px">Accept-Ranges</span></td>
<td><span style="font-size: 13px">可以请求网页实体的一个或者多个子范围字段</span></td>
<td><span style="font-size: 13px">Accept-Ranges: bytes</span></td>
</tr>
<tr>
<td><span style="font-size: 13px">Authorization</span></td>
<td><span style="font-size: 13px">HTTP授权的授权证书</span></td>
<td><span style="font-size: 13px">Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==</span></td>
</tr>
<tr>
<td><span style="font-size: 13px">Cache-Control</span></td>
<td><span style="font-size: 13px">指定请求和响应遵循的缓存机制</span></td>
<td><span style="font-size: 13px">Cache-Control: no-cache</span></td>
</tr>
<tr>
<td><span style="font-size: 13px">Connection</span></td>
<td><span style="font-size: 13px">表示是否需要持久连接。(HTTP 1.1默认进行持久连接)</span></td>
<td><span style="font-size: 13px">Connection: close</span></td>
</tr>
<tr>
<td><span style="font-size: 13px">Cookie</span></td>
<td><span style="font-size: 13px">HTTP请求发送时,会把保存在该请求域名下的所有cookie值一起发送给web服务器。</span></td>
<td><span style="font-size: 13px">Cookie: $Version=1; Skin=new;</span></td>
</tr>
<tr>
<td><span style="font-size: 13px">Content-Length</span></td>
<td><span style="font-size: 13px">请求的内容长度</span></td>
<td><span style="font-size: 13px">Content-Length: 348</span></td>
</tr>
<tr>
<td><span style="font-size: 13px">Content-Type</span></td>
<td><span style="font-size: 13px">请求的与实体对应的MIME信息</span></td>
<td><span style="font-size: 13px">Content-Type: application/x-www-form-urlencoded</span></td>
</tr>
<tr>
<td><span style="font-size: 13px">Date</span></td>
<td><span style="font-size: 13px">请求发送的日期和时间</span></td>
<td><span style="font-size: 13px">Date: Tue, 15 Nov&nbsp;2010 08:12:31 GMT</span></td>
</tr>
<tr>
<td><span style="font-size: 13px">Expect</span></td>
<td><span style="font-size: 13px">请求的特定的服务器行为</span></td>
<td><span style="font-size: 13px">Expect: 100-continue</span></td>
</tr>
<tr>
<td><span style="font-size: 13px">From</span></td>
<td><span style="font-size: 13px">发出请求的用户的Email</span></td>
<td><span style="font-size: 13px">From: user@email.com</span></td>
</tr>
<tr>
<td><span style="font-size: 13px">Host</span></td>
<td><span style="font-size: 13px">指定请求的服务器的域名和端口号</span></td>
<td><span style="font-size: 13px">Host: www.zcmhi.com</span></td>
</tr>
<tr>
<td><span style="font-size: 13px">If-Match</span></td>
<td><span style="font-size: 13px">只有请求内容与实体相匹配才有效</span></td>
<td><span style="font-size: 13px">If-Match: “737060cd8c284d8af7ad3082f209582d”</span></td>
</tr>
<tr>
<td><span style="font-size: 13px">If-Modified-Since</span></td>
<td><span style="font-size: 13px">如果请求的部分在指定时间之后被修改则请求成功,未被修改则返回304代码</span></td>
<td><span style="font-size: 13px">If-Modified-Since: Sat, 29 Oct 2010 19:43:31 GMT</span></td>
</tr>
<tr>
<td><span style="font-size: 13px">If-None-Match</span></td>
<td><span style="font-size: 13px">如果内容未改变返回304代码,参数为服务器先前发送的Etag,与服务器回应的Etag比较判断是否改变</span></td>
<td><span style="font-size: 13px">If-None-Match: “737060cd8c284d8af7ad3082f209582d”</span></td>
</tr>
<tr>
<td><span style="font-size: 13px">If-Range</span></td>
<td><span style="font-size: 13px">如果实体未改变,服务器发送客户端丢失的部分,否则发送整个实体。参数也为Etag</span></td>
<td><span style="font-size: 13px">If-Range: “737060cd8c284d8af7ad3082f209582d”</span></td>
</tr>
<tr>
<td><span style="font-size: 13px">If-Unmodified-Since</span></td>
<td><span style="font-size: 13px">只在实体在指定时间之后未被修改才请求成功</span></td>
<td><span style="font-size: 13px">If-Unmodified-Since: Sat, 29 Oct 2010 19:43:31 GMT</span></td>
</tr>
<tr>
<td><span style="font-size: 13px">Max-Forwards</span></td>
<td><span style="font-size: 13px">限制信息通过代理和网关传送的时间</span></td>
<td><span style="font-size: 13px">Max-Forwards: 10</span></td>
</tr>
<tr>
<td><span style="font-size: 13px">Pragma</span></td>
<td><span style="font-size: 13px">用来包含实现特定的指令</span></td>
<td><span style="font-size: 13px">Pragma: no-cache</span></td>
</tr>
<tr>
<td><span style="font-size: 13px">Proxy-Authorization</span></td>
<td><span style="font-size: 13px">连接到代理的授权证书</span></td>
<td><span style="font-size: 13px">Proxy-Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==</span></td>
</tr>
<tr>
<td><span style="font-size: 13px">Range</span></td>
<td><span style="font-size: 13px">只请求实体的一部分,指定范围</span></td>
<td><span style="font-size: 13px">Range: bytes=500-999</span></td>
</tr>
<tr>
<td><span style="font-size: 13px">Referer</span></td>
<td><span style="font-size: 13px">先前网页的地址,当前请求网页紧随其后,即来路</span></td>
<td><span style="font-size: 13px">Referer: http://www.zcmhi.com/archives/71.html</span></td>
</tr>
<tr>
<td><span style="font-size: 13px">TE</span></td>
<td><span style="font-size: 13px">客户端愿意接受的传输编码,并通知服务器接受接受尾加头信息</span></td>
<td><span style="font-size: 13px">TE: trailers,deflate;q=0.5</span></td>
</tr>
<tr>
<td><span style="font-size: 13px">Upgrade</span></td>
<td><span style="font-size: 13px">向服务器指定某种传输协议以便服务器进行转换(如果支持)</span></td>
<td><span style="font-size: 13px">Upgrade: HTTP/2.0, SHTTP/1.3, IRC/6.9, RTA/x11</span></td>
</tr>
<tr>
<td><span style="font-size: 13px">User-Agent</span></td>
<td><span style="font-size: 13px">User-Agent的内容包含发出请求的用户信息</span></td>
<td><span style="font-size: 13px">User-Agent: Mozilla/5.0 (Linux; X11)</span></td>
</tr>
<tr>
<td><span style="font-size: 13px">Via</span></td>
<td><span style="font-size: 13px">通知中间网关或代理服务器地址,通信协议</span></td>
<td><span style="font-size: 13px">Via: 1.0 fred, 1.1 nowhere.com (Apache/1.1)</span></td>
</tr>
<tr>
<td><span style="font-size: 13px">Warning</span></td>
<td><span style="font-size: 13px">关于消息实体的警告信息</span></td>
<td><span style="font-size: 13px">Warn: 199 Miscellaneous warning</span></td>
</tr>
</tbody>
</table>
<h2><span style="font-size: 13px">Responses 部分&nbsp;&nbsp;</span></h2>
<table class="table table-bordered" border="1" cellpadding="0">
<tbody>
<tr><th><span style="font-size: 13px">Header</span></th><th><span style="font-size: 13px">解释</span></th><th><span style="font-size: 13px">示例</span></th></tr>
<tr>
<td><span style="font-size: 13px">Accept-Ranges</span></td>
<td><span style="font-size: 13px">表明服务器是否支持指定范围请求及哪种类型的分段请求</span></td>
<td><span style="font-size: 13px">Accept-Ranges: bytes</span></td>
</tr>
<tr>
<td><span style="font-size: 13px">Age</span></td>
<td><span style="font-size: 13px">从原始服务器到代理缓存形成的估算时间(以秒计,非负)</span></td>
<td><span style="font-size: 13px">Age: 12</span></td>
</tr>
<tr>
<td><span style="font-size: 13px">Allow</span></td>
<td><span style="font-size: 13px">对某网络资源的有效的请求行为,不允许则返回405</span></td>
<td><span style="font-size: 13px">Allow: GET, HEAD</span></td>
</tr>
<tr>
<td><span style="font-size: 13px">Cache-Control</span></td>
<td><span style="font-size: 13px">告诉所有的缓存机制是否可以缓存及哪种类型</span></td>
<td><span style="font-size: 13px">Cache-Control: no-cache</span></td>
</tr>
<tr>
<td><span style="font-size: 13px">Content-Encoding</span></td>
<td><span style="font-size: 13px">web服务器支持的返回内容压缩编码类型。</span></td>
<td><span style="font-size: 13px">Content-Encoding: gzip</span></td>
</tr>
<tr>
<td><span style="font-size: 13px">Content-Language</span></td>
<td><span style="font-size: 13px">响应体的语言</span></td>
<td><span style="font-size: 13px">Content-Language: en,zh</span></td>
</tr>
<tr>
<td><span style="font-size: 13px">Content-Length</span></td>
<td><span style="font-size: 13px">响应体的长度</span></td>
<td><span style="font-size: 13px">Content-Length: 348</span></td>
</tr>
<tr>
<td><span style="font-size: 13px">Content-Location</span></td>
<td><span style="font-size: 13px">请求资源可替代的备用的另一地址</span></td>
<td><span style="font-size: 13px">Content-Location: /index.htm</span></td>
</tr>
<tr>
<td><span style="font-size: 13px">Content-MD5</span></td>
<td><span style="font-size: 13px">返回资源的MD5校验值</span></td>
<td><span style="font-size: 13px">Content-MD5: Q2hlY2sgSW50ZWdyaXR5IQ==</span></td>
</tr>
<tr>
<td><span style="font-size: 13px">Content-Range</span></td>
<td><span style="font-size: 13px">在整个返回体中本部分的字节位置</span></td>
<td><span style="font-size: 13px">Content-Range: bytes 21010-47021/47022</span></td>
</tr>
<tr>
<td><span style="font-size: 13px">Content-Type</span></td>
<td><span style="font-size: 13px">返回内容的MIME类型</span></td>
<td><span style="font-size: 13px">Content-Type: text/html; charset=utf-8</span></td>
</tr>
<tr>
<td><span style="font-size: 13px">Date</span></td>
<td><span style="font-size: 13px">原始服务器消息发出的时间</span></td>
<td><span style="font-size: 13px">Date: Tue, 15 Nov 2010 08:12:31 GMT</span></td>
</tr>
<tr>
<td><span style="font-size: 13px">ETag</span></td>
<td><span style="font-size: 13px">请求变量的实体标签的当前值</span></td>
<td><span style="font-size: 13px">ETag: “737060cd8c284d8af7ad3082f209582d”</span></td>
</tr>
<tr>
<td><span style="font-size: 13px">Expires</span></td>
<td><span style="font-size: 13px">响应过期的日期和时间</span></td>
<td><span style="font-size: 13px">Expires: Thu, 01 Dec 2010 16:00:00 GMT</span></td>
</tr>
<tr>
<td><span style="font-size: 13px">Last-Modified</span></td>
<td><span style="font-size: 13px">请求资源的最后修改时间</span></td>
<td><span style="font-size: 13px">Last-Modified: Tue, 15 Nov 2010 12:45:26 GMT</span></td>
</tr>
<tr>
<td><span style="font-size: 13px">Location</span></td>
<td><span style="font-size: 13px">用来重定向接收方到非请求URL的位置来完成请求或标识新的资源</span></td>
<td><span style="font-size: 13px">Location: http://www.zcmhi.com/archives/94.html</span></td>
</tr>
<tr>
<td><span style="font-size: 13px">Pragma</span></td>
<td><span style="font-size: 13px">包括实现特定的指令,它可应用到响应链上的任何接收方</span></td>
<td><span style="font-size: 13px">Pragma: no-cache</span></td>
</tr>
<tr>
<td><span style="font-size: 13px">Proxy-Authenticate</span></td>
<td><span style="font-size: 13px">它指出认证方案和可应用到代理的该URL上的参数</span></td>
<td><span style="font-size: 13px">Proxy-Authenticate: Basic</span></td>
</tr>
<tr>
<td><span style="font-size: 13px">refresh</span></td>
<td><span style="font-size: 13px">应用于重定向或一个新的资源被创造,在5秒之后重定向(由网景提出,被大部分浏览器支持)</span></td>
<td>
<p><span style="font-size: 13px">&nbsp;</span></p>
<p><span style="font-size: 13px">Refresh: 5; url=</span></p>
<p><span style="font-size: 13px">http://www.zcmhi.com/archives/94.html</span></p>
</td>
</tr>
<tr>
<td><span style="font-size: 13px">Retry-After</span></td>
<td><span style="font-size: 13px">如果实体暂时不可取,通知客户端在指定时间之后再次尝试</span></td>
<td><span style="font-size: 13px">Retry-After: 120</span></td>
</tr>
<tr>
<td><span style="font-size: 13px">Server</span></td>
<td><span style="font-size: 13px">web服务器软件名称</span></td>
<td><span style="font-size: 13px">Server: Apache/1.3.27 (Unix) (Red-Hat/Linux)</span></td>
</tr>
<tr>
<td><span style="font-size: 13px">Set-Cookie</span></td>
<td><span style="font-size: 13px">设置Http Cookie</span></td>
<td><span style="font-size: 13px">Set-Cookie: UserID=JohnDoe; Max-Age=3600; Version=1</span></td>
</tr>
<tr>
<td><span style="font-size: 13px">Trailer</span></td>
<td><span style="font-size: 13px">指出头域在分块传输编码的尾部存在</span></td>
<td><span style="font-size: 13px">Trailer: Max-Forwards</span></td>
</tr>
<tr>
<td><span style="font-size: 13px">Transfer-Encoding</span></td>
<td><span style="font-size: 13px">文件传输编码</span></td>
<td><span style="font-size: 13px">Transfer-Encoding:chunked</span></td>
</tr>
<tr>
<td><span style="font-size: 13px">Vary</span></td>
<td><span style="font-size: 13px">告诉下游代理是使用缓存响应还是从原始服务器请求</span></td>
<td><span style="font-size: 13px">Vary: *</span></td>
</tr>
<tr>
<td><span style="font-size: 13px">Via</span></td>
<td><span style="font-size: 13px">告知代理客户端响应是通过哪里发送的</span></td>
<td><span style="font-size: 13px">Via: 1.0 fred, 1.1 nowhere.com (Apache/1.1)</span></td>
</tr>
<tr>
<td><span style="font-size: 13px">Warning</span></td>
<td><span style="font-size: 13px">警告实体可能存在的问题</span></td>
<td><span style="font-size: 13px">Warning: 199 Miscellaneous warning</span></td>
</tr>
<tr>
<td><span style="font-size: 13px">WWW-Authenticate</span></td>
<td><span style="font-size: 13px">表明客户端请求实体应该使用的授权方案</span></td>
<td><span style="font-size: 13px">WWW-Authenticate: Basic</span></td>
</tr>
</tbody>
</table>
</div><br><br>
来源:https://www.cnblogs.com/leaf-blog/p/11736232.html
頁: [1]
查看完整版本: PHP header函数设置http头