在应用程序引擎上使用 urlfetch() 查询除 80 之外的端口上的 URL

发布于 2024-09-10 21:31:11 字数 278 浏览 1 评论 0原文

是否允许使用 urlfetch() 查询除 80 之外的端口上存在的 URL

我想从非标准端口上的服务器获取数据 -

http://example.com:8000/WebService?input=a

理想的示例是托管在非标准端口上的 Web 服务。

我可以用 appengine 以某种方式做到这一点吗?

Is querying for URLs present on ports other than 80 allowed with urlfetch()

I would like to get data from a server on a non-standard port -

http://example.com:8000/WebService?input=a

Ideal example would be web services hosted on non-standard ports.

Can i do this somehow with appengine?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

枯叶蝶 2024-09-17 21:31:11

应用引擎文档n 表示您可以使用 Python 的 urllib2 发出请求,该请求将自动使用 Google 的 urlfetch 服务。使用 urllib2 您可以在主机名中指示端口号。

import urllib2
conn = urllib2.urlopen('http://www.google.com:80')
print conn.read()

我还没有在 GAE 上测试过它,但我不明白为什么它不起作用。

编辑:

来自 GAE 文档

要获取的 URL 可以使用以下范围内的任何端口号:80-90、440-450、1024-65535。如果 URL 中未提及端口,则该端口由方案隐含:http://... 是端口 80,https://... 是端口 443。

这意味着可以在使用标准 urlfetch API 时的 url。

The app engine documentation says that you can use Python's urllib2 to make your requests which will automatically use Google's urlfetch service. Using urllib2 you can indicate the port number in the hostname.

import urllib2
conn = urllib2.urlopen('http://www.google.com:80')
print conn.read()

I haven't tested it on GAE, but I don't see why it shouldn't work.

Edit:

From the GAE documentation:

The URL to be fetched can use any port number in the following ranges: 80-90, 440-450, 1024-65535. If the port is not mentioned in the URL, the port is implied by the scheme: http://... is port 80, https://... is port 443.

This implies that the port can be specified in the url while using the standard urlfetch API.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文