英文:
how do I get the entire http request line?
问题
我正在尝试处理一个格式奇怪的请求
https://explorer.ether.cards/#/founder/1
目前在本地主机上进行测试
http://localhost:9009/#/founder/1
有没有办法提取/founder/1
?
我已经尝试了默认和自定义的muxes,但找不到提取值的方法。
英文:
I am trying to handle a request that has a strange formatting
https://explorer.ether.cards/#/founder/1
currently testing on localhost as
http://localhost:9009/#/founder/1
Is there any way to extract the /founder/1
?
I have tried the default and custom muxes but cannot find any way to extract the values.
答案1
得分: 2
使用Request.RequestURI字段来获取从网络读取的HTTP请求URI。根据你的需求解析该值。
#/founder/1
是一个片段。片段不是HTTP请求URI的一部分,客户端不会将片段发送给服务器。
要在服务器上访问/founder/1
,请将该值移动到路径或查询参数中。
英文:
Use the Request.RequestURI field to get the HTTP request URI as read from the network. Parse the value as needed by your requirements.
#/founder/1
Is a fragment. Fragments are not part of the HTTP request URI and are not sent to the server by clients.
To access /founder/1
on the server, move the value to the path or a query parameter.
答案2
得分: 1
在URL中,#
后面的任何内容都被视为URL片段。这里请求URL的设计不正确,因为#
被用作请求路径的一部分,使/founder/1
成为URL片段。URL片段只是一个浏览器端的概念,浏览器不会将URL片段发送到服务器端。
简而言之,在服务器端无法捕获/founder/1
。
英文:
Anything after #
in the URL is considered as the URL fragment.
The design of request URL is not correct here because #
is being used here as a part of request path making /founder/1
a URL fragment. URL fragment is only a browser-side concept and browsers do not send URL fragment to the server side.
So in short, you cannot capture /founder/1
on the server side.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论