http.DefaultTransport和http.DefaultClient在AppEngine中不可用,但是一个库使用它们。

huangapple go评论78阅读模式
英文:

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.

huangapple
  • 本文由 发表于 2014年9月11日 05:55:52
  • 转载请务必保留本文链接:https://go.coder-hub.com/25775720.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定