Grails HTTP 代理
我想在 grails 中创建一个代理控制器,它只接受基于 url 映射传入的任何内容,记录所请求的内容,将请求发送到另一台服务器,记录响应,然后将响应发送回浏览器。
当请求具有奇怪的文件扩展名 (.gif) 或没有文件扩展名 (/xxx?sdcscd) 时,我遇到麻烦
我的 url 映射是:
"/proxy/$target**"
并且我已经尝试过(根据另一个问题的答案):
def targetURL = params.target
if (!FilenameUtils.getExtension(targetURL) && request.format) {
targetURL += ".${response.format}"
}
但这通常附加 .html 而从不附加 .gif 或 ?csdcsd
不知道该怎么做,因为我可能只是直接用 Java 编写该内容
I want to create a proxy controller in grails, something that just takes whatever is passed in based on a url mapping, records what was asked for, sends the request to another server, records the response, and send the response back to the browser.
I'm having trouble with when the request has an odd file extension (.gif) or no file extension (/xxx?sdcscd)
My url mapping is:
"/proxy/$target**"
and I've attempted (per an answer to another question):
def targetURL = params.target
if (!FilenameUtils.getExtension(targetURL) && request.format) {
targetURL += ".${response.format}"
}
but this usually appends .html and never the .gif or ?csdcsd
Not sure what to do as I might just write the thing in straight Java
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
实际上,真正的答案就在您之前链接到的帖子 一直以来,作者:Peter Ledbrook:
这将禁用文件扩展名的格式使用,但会将文件扩展名保留在 params.target 上。您可以完全忽略
response.format
!Actually, the real answer was sitting in the post you linked to previously all along, by Peter Ledbrook:
This will disable the usage of file extensions for format, but will leave the file extension on
params.target
. You can completely ignoreresponse.format
!