【问题标题】:Non multi part post using pycurl使用 pycurl 的非多部分帖子
【发布时间】:2016-08-10 22:04:22
【问题描述】:

我无法将数据发布到休息服务器,因为服务器不知道如何处理多部分发布请求,并且在遇到边界时会引发错误。 有没有办法在 pycurl 中制作非多部分帖子? 为什么 post 请求需要是多部分的?

【问题讨论】:

    标签: python http post curl pycurl


    【解决方案1】:

    一个 POST 当然不必是多部分的,请参阅我也在此处粘贴的 pycurl 文档中的 this example

    c = pycurl.Curl()
    c.setopt(c.URL, 'http://pycurl.io/tests/testpostvars.php')
    
    post_data = {'field': 'value'}
    # Form data must be provided already urlencoded.
    postfields = urlencode(post_data)
    # Sets request method to POST,
    # Content-Type header to application/x-www-form-urlencoded
    # and data to send in request body.
    c.setopt(c.POSTFIELDS, postfields)
    
    c.perform()
    c.close()
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-09-26
      • 1970-01-01
      • 1970-01-01
      • 2014-09-05
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多