有没有比直接通过 tcp 访问主机更简单的方法来获取 HTTP 404 响应的内容?
这是 404 响应的示例,内容如下:
HTTP/1.1 404 Object Not Found
Server: CouchDB/1.3.0 (Erlang OTP/R15B03)
Date: Wed, 24 Jul 2013 08:32:50 GMT
Content-Type: text/plain; charset=utf-8
Content-Length: 41
Cache-Control: must-revalidate
{"error":"not_found","reason":"missing"}
Rebol HTTP 方案的设计实际上并没有考虑到这一点,它的目的是像在浏览器中那样读取内容,而不是通过 HTTP 提供服务。
也就是说,您可以破解协议来破坏 Rebol 2 处理不同响应代码的方式:
in-http-scheme: func [does [block!]][
do bind :does bind? last body-of get in system/schemes/http/handler 'open
]
in-http-scheme [
remove-each [code response] response-actions [find [400 403 404] code]
append response-actions [400 success 403 success 404 success]
]
这里需要注意的是 HTTP 协议必须已启动(任何打开/读取的 http 端口)。 response-actions
未发起http时仍然可以访问:
select body-of get in system/schemes/http/handler 'open quote response-actions:
您可以获得最后一条响应行:
in-http-scheme [response-line]
或者,您将需要一个为 HTTP 服务设计的方案。我有一个休息协议 http://www.ross-gill.com/page/REST_Protocol(两个版本,一个版本使用卷曲 http://reb4.me/r/rest-curl,以及一个使用定制HTTP方案 http://reb4.me/r/rest可以,但效果没那么好)。虽然是针对 Rebol 2 的。我有 Rebol 3 版本的计划。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)