簡體   English   中英

TypeError:期望一個可讀的緩沖區對象

[英]TypeError: expected a readable buffer object

當我嘗試使用GET方法使用M2Crypto HTTPSConnection庫連接到API時,我遇到以下錯誤。

Traceback (most recent call last):
  File "osg-gridadmin-cert-request", line 665, in <module>
    status = check_quota_limit(request_count)
  File "osg-gridadmin-cert-request", line 543, in check_quota_limit
    conn.request('GET', arguments['quotaurl'], headers)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 941, in request
    self._send_request(method, url, body, headers)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 975, in _send_request
    self.endheaders(body)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 937, in endheaders
    self._send_output(message_body)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 801, in _send_output
    self.send(message_body)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 773, in send
    self.sock.sendall(data)
  File "build/bdist.macosx-10.7-intel/egg/M2Crypto/SSL/Connection.py", line 217, in write
    return self._write_nbio(data)
  File "build/bdist.macosx-10.7-intel/egg/M2Crypto/SSL/Connection.py", line 202, in _write_nbio
    return m2.ssl_write_nbio(self.ssl, data)
TypeError: expected a readable buffer object

我正在使用此代碼訪問API

conn = M2Crypto.httpslib.HTTPSConnection(arguments['host'],
            ssl_context=ssl_context)
        conn.request('GET', arguments['quotaurl'], headers)
        response = conn.getresponse()

你能幫幫我解決這個問題嗎?

請參閱錯誤消息

self._send_request(method, url, body, headers)

這表示您正在傳遞“標題”,您應該傳遞“正文”。

所以,試着打電話

conn.request('GET', arguments['quotaurl'], None, headers)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM