【发布时间】:2011-04-18 13:26:54
【问题描述】:
我正在尝试从我的 Google App Engine 网络应用发出 http 请求,并发现我必须使用 URLConnection,因为它是唯一列入白名单的类。对应的Clojure库是clojure.contrib.http.agent,我的代码如下:
(defroutes example
(GET "/" [] (http/string (http/http-agent "http://www.example.com")))
(route/not-found "Page not found"))
这在我的开发环境中运行良好 - 浏览器显示 example.com 的文本。但是当我使用 Google 的开发应用服务器对其进行测试时:
phrygian:example wei$ dev_appserver.sh war
2010-09-28 14:53:36.120 java[43845:903] [Java CocoaComponent compatibility mode]: Enabled
...
INFO: The server is running at http://localhost:8080/
它只是在我加载页面时挂起。没有错误,或任何东西。知道会发生什么吗?
【问题讨论】:
-
http-agent是否创建线程?我的理解是 App Engine 不喜欢这些。 -
嗯,好问题。你知道它是否有非线程版本吗?
-
你可以试试
http-connectionrichhickey.github.com/clojure-contrib/http.connection-api.html,它似乎是HttpURLConnection的一个相当低级的包装器。或者只使用URLConnection。午饭后我会尝试看看更多的选择。 -
我添加了我的 cmets 作为正确答案,但它已经失控了。我还添加了更多可能性供您研究。虽然没有时间测试它们中的任何一个:(
标签: google-app-engine clojure httpwebrequest jvm compojure