3

私のコード:

from Core.PythonLib import requests
requests.packages.urllib3.disable_warnings()
def go_url(self, url, data=None, headers={}):
    if data:
        send = requests.post
    else:
        send = requests.get

    response = send(url, data=data, headers=headers, auth=(self.username, self.password))
    response.raise_for_status()
    print response.status_code
    print response.content

最初に2つのリクエストを送信すると、回答が得られ、2番目にエラーが発生します。

最初:

Set state
200
{"status":"ok", ..... .....}
Loading admin SAVE from file [Empty] - Success!

2番:

TEST_ERROR: 
  File "D:\autotest\Core\Admin.py", line 94, in go_url
    response = send(url, data=data, headers=headers, auth=(self.username, self.password))

  File "D:\autotest\Core\PythonLib\requests\api.py", line 69, in get
    return request('get', url, params=params, **kwargs)

  File "D:\autotest\Core\PythonLib\requests\api.py", line 50, in request
    response = session.request(method=method, url=url, **kwargs)

  File "D:\autotest\Core\PythonLib\requests\sessions.py", line 468, in request
    resp = self.send(prep, **send_kwargs)

  File "D:\autotest\Core\PythonLib\requests\sessions.py", line 597, in send
    history = [resp for resp in gen] if allow_redirects else []

  File "D:\autotest\Core\PythonLib\requests\sessions.py", line 187, in resolve_redirects
    resp = self.send(

  File "D:\autotest\Core\PythonLib\requests\sessions.py", line 608, in send
    r.content

  File "D:\autotest\Core\PythonLib\requests\models.py", line 734, in content
    self._content = bytes().join(self.iter_content(CONTENT_CHUNK_SIZE)) or bytes()

  File "D:\autotest\Core\PythonLib\requests\models.py", line 734, in content
    self._content = bytes().join(self.iter_content(CONTENT_CHUNK_SIZE)) or bytes()

  File "D:\autotest\Core\PythonLib\requests\models.py", line 657, in generate
    for chunk in self.raw.stream(chunk_size, decode_content=True):

  File "D:\autotest\Core\PythonLib\requests\models.py", line 657, in generate
    for chunk in self.raw.stream(chunk_size, decode_content=True):

  File "D:\autotest\Core\PythonLib\requests\packages\urllib3\response.py", line 322, in stream
    for line in self.read_chunked(amt, decode_content=decode_content):

  File "D:\autotest\Core\PythonLib\requests\packages\urllib3\response.py", line 471, in read_chunked
    yield self._decode(chunk, decode_content=decode_content,

  File "D:\autotest\Core\PythonLib\requests\packages\urllib3\response.py", line 190, in _decode
    data = self._decoder.decompress(data)

  File "D:\autotest\Core\PythonLib\requests\packages\urllib3\response.py", line 190, in _decode
    data = self._decoder.decompress(data)

  File "D:\autotest\Core\PythonLib\requests\packages\urllib3\response.py", line 56, in decompress
    return self._obj.decompress(data)

  File "D:\autotest\SikuliX\sikulix.jar\Lib\zlib.py", line 155, in decompress
    inflated = _get_inflate_data(self.inflater, max_length)

  File "D:\autotest\SikuliX\sikulix.jar\Lib\zlib.py", line 202, in _get_inflate_data
    l = inflater.inflate(buf)

  File "D:\autotest\SikuliX\sikulix.jar\Lib\zlib.py", line 202, in _get_inflate_data
    l = inflater.inflate(buf)
java.lang.NullPointerException: Inflater has been closed

フラグ「stream=True」を指定するリクエストが実行された場合、リクエストは実行されますが、 response.content を印刷することはできません。同じエラーが発生しました。誰かがそのような問題に直面するかもしれませんか?

4

1 に答える 1