本文整理匯總了Python中pycurl.UPLOAD屬性的典型用法代碼示例。如果您正苦於以下問題:Python pycurl.UPLOAD屬性的具體用法?Python pycurl.UPLOAD怎麽用?Python pycurl.UPLOAD使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類pycurl
的用法示例。
在下文中一共展示了pycurl.UPLOAD屬性的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: get_uploader
# 需要導入模塊: import pycurl [as 別名]
# 或者: from pycurl import UPLOAD [as 別名]
def get_uploader(self):
"""Initialze a Curl object for a single PUT request.
Returns a tuple of initialized Curl and HTTPResponse objects.
"""
c = pycurl.Curl()
resp = HTTPResponse(self._encoding)
c.setopt(pycurl.UPLOAD, 1) # does an HTTP PUT
data = self._data.get("PUT", "")
filesize = len(data)
c.setopt(pycurl.READFUNCTION, DataWrapper(data).read)
c.setopt(pycurl.INFILESIZE, filesize)
c.setopt(c.WRITEFUNCTION, resp._body_callback)
c.setopt(c.HEADERFUNCTION, resp._header_callback)
# extra options to avoid hanging forever
c.setopt(c.URL, str(self._url))
c.setopt(c.HTTPHEADER, map(str, self._headers))
self._set_common(c)
return c, resp