Google AppEngine 中的 httplib.HTTPConnection
我在我的应用程序中使用 httplib.HTTPConnection
。我真的需要在 httplib.HTTPConnection
构造函数中提供 host
参数吗?如果是这样,为什么? (我的意思是,我知道这是一个强制参数,但我想知道我是否可以指定 None
或空字符串)Google AppEngine 和开发服务器中是否有任何全局常量可以在我的应用程序中使用app 为了省略明确定义的主机。
I use httplib.HTTPConnection
within my app. Do I really need to provide host
parameter in httplib.HTTPConnection
constructor? If so, why? (I mean, I know that it's a mandatory parameter, but I wonder if I could specify None
or empty string) And is there any global constant in Google AppEngine and in development server which I can use within my app in order to omit explicitly defined host.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果将其排除在构造函数之外,其他方法将如何知道将消息发送到哪里?
您要连接的服务器的地址/名称是 HTTPConnection 的参数,该服务器上的 URI 是进入请求的内容。
来自 python 文档(这是 AppEngine 的基础)
[编辑]
请记住,负责此代码的人可能并不总是您。另外,当您(例如)在同一网站上调用多个 URI 时,为什么要在 URI 中包含如此多的信息而使事情变得复杂呢?
[/编辑]
If you leave it out of the constructor, how will the other methods know where to send their messages?
The address/name of the server you're connecting to is the parameter for the HTTPConnection, the URI on that server is what goes into request.
From the python documentation (which is the basis for AppEngine)
[edit]
Remember, it may not always be you who is responsible for this code. Also, why complicate things by including so much more information in the URI when you're (for example) making calls to numerous URI's on the same website?
[/edit]