【发布时间】:2016-08-10 22:04:22
【问题描述】:
我无法将数据发布到休息服务器,因为服务器不知道如何处理多部分发布请求,并且在遇到边界时会引发错误。 有没有办法在 pycurl 中制作非多部分帖子? 为什么 post 请求需要是多部分的?
【问题讨论】:
标签: python http post curl pycurl
我无法将数据发布到休息服务器,因为服务器不知道如何处理多部分发布请求,并且在遇到边界时会引发错误。 有没有办法在 pycurl 中制作非多部分帖子? 为什么 post 请求需要是多部分的?
【问题讨论】:
标签: python http post curl pycurl
一个 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()
【讨论】: