【问题标题】:pycurl post request hangs infinitely on perform()pycurl post 请求在 perform() 上无限挂起
【发布时间】:2018-05-19 23:14:06
【问题描述】:

我正在尝试使用 pycurl 发出发布请求,但请求在 c.perform() 上无限挂起。我的代码是:

    try:
        from io import BytesIO
    except ImportError:
        from io import StringIO as BytesIO

    buffer = BytesIO()
    self.c.setopt(self.c.URL, 'http://pycurl.io/')
    self.c.setopt(self.c.HEADER, 0)
    self.c.setopt(self.c.POST, 1)
    self.c.perform()
    self.c.close()
    body = buffer.getvalue()

    status = self.c.getinfo(self.c.HTTP_CODE)
    response_data = {
        'is_fed_successfully': True
    }'

为了清楚起见,没有错误。请求只是无限挂起,没有任何响应。

【问题讨论】:

  • pycurl.Curl()在哪里?
  • self.c = pycurl.Curl() 在类的方法中

标签: python-3.x flask pycurl


【解决方案1】:

我也有这个问题。对我有用的是使用 POSTFIELDS 传递一些空数据。您可以尝试添加此行。

self.c.setopt(self.c.POSTFIELDS,'')

我猜它挂了,因为它正在等待永远不会到来的数据。

【讨论】:

    猜你喜欢
    • 2018-03-24
    • 2018-09-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-07-23
    • 2014-02-08
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多