英文:
http.DefaultTransport and http.DefaultClient are not available in AppEngine, but a lib uses them
问题
我正在使用一个名为gotwilio的库,该库使用http.Client对象向服务器发起HTTP请求:
client := &http.Client{}
然而,在appengine上运行时,会出现以下错误信息:
http.DefaultTransport和http.DefaultClient在App Engine中不可用
这是有道理的。然而,由于该库直接使用这些对象,我无法告诉库使用appengine提供的基于urlfetch的传输方式。
是否有办法使&http.Client{}始终返回一个与urlfetch兼容的客户端... 在Java中,在appengine上也可以实现这一点。(URLConnection可以正常工作)
英文:
I'm using a library (gotwilio) that makes http requests to a server using a http.Client object:
client := &http.Client{}
However this fails on appengine with the following error message:
http.DefaultTransport and http.DefaultClient are not available in App Engine
This makes sense. However since the lib is using these directly there is no way for me to tell the library to use the urlfetch based transport that appengine provides.
Is there a way to make &http.Client{} always return a client that works with urlfetch.... In java this is also possible on appengine. (URLConnection just works)
答案1
得分: 2
很遗憾,你不能直接翻译代码部分。但是你可以复制这个库,修改github.com/sfreiberg/gotwilio/gotwilio.go
中的func (twilio *Twilio) post
函数,并使用你本地修改后的库,直到它被正确实现。
英文:
Sadly no, OTOH you can just copy the library, change func (twilio *Twilio) post
in github.com/sfreiberg/gotwilio/gotwilio.go
and use your local copy until it's implemented properly.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论