Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/joomla/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Common lisp 在hunchentoot中,有没有办法在路径之前获取url的一部分_Common Lisp_Hunchentoot - Fatal编程技术网

Common lisp 在hunchentoot中,有没有办法在路径之前获取url的一部分

Common lisp 在hunchentoot中,有没有办法在路径之前获取url的一部分,common-lisp,hunchentoot,Common Lisp,Hunchentoot,如果客户请求proto://hostname:port/path我想得到proto://hostname:port 我本可以错过一些东西,但现在我唯一能想到的方法就是按照 (format nil "~A://~A" (stringify-downcase-scan (server-protocol*)) (host)) 是否有特定于此的函数/方法或更简单的方法 主要原因是服务器协议返回我必须解析的关键字符号(例如:http/1.1)。当然我可以做到,但它可能已经存在,我可能已经错过了它。您可以

如果客户请求
proto://hostname:port/path
我想得到
proto://hostname:port

我本可以错过一些东西,但现在我唯一能想到的方法就是按照

(format nil "~A://~A" (stringify-downcase-scan (server-protocol*)) (host))
是否有特定于此的函数/方法或更简单的方法

主要原因是
服务器协议
返回我必须解析的关键字符号(例如
:http/1.1
)。当然我可以做到,但它可能已经存在,我可能已经错过了它。

您可以安装或解析URI:

CL-USER> (describe (quri:uri "proto://hostname:1000/path"))
#<QURI.URI:URI proto://hostname:1000/path>
Type: QURI.URI:URI
Class: #<STRUCTURE-CLASS QURI.URI:URI>
SCHEME: "proto"
USERINFO: NIL
HOST: "hostname"
PORT: 1000
PATH: "/path"
QUERY: NIL
FRAGMENT: NIL

在您的情况下,您可能希望使用
(request URI*)

访问URI,谢谢,但我希望相反:在路径之前获取url字符串,而不是解析它。在hunchentoot请求的上下文中,我隐式地包含以下部分:我有host:port-from(主机)方法和protocol-from(服务器协议)方法。我只需要解析/过滤后者的响应,因为它返回一个包含版本号的关键字also@Paralife对不起,我不知道你想要什么。我试图编辑答案以提供更多细节,但如果这还不够,您能否添加一个示例来说明处理程序是如何实现的?谢谢(请求uri*)不会返回完整的url。它返回host:port之后的部分。为了更好地说明我的问题:您能给我一个示例处理程序,它只输出客户机在地址栏中的内容吗?(当然直到第一个散列)@Paralife好的,我现在明白了。从一个请求中获取整个路径似乎并不容易,也许有一种方法可以定义一些低级Hunchentoot通用函数的方法,比如handleincomingconnection,但我没有尝试。
(quri:render-uri 
 (quri:merge-uris (quri:uri "/")
                  (quri:uri "proto://hostname:1000/path")))

=> "proto://hostname:1000/"