Python httplib ResponseNotReady

前端 未结 6 695
南笙
南笙 2020-12-04 23:59

I\'m writing a REST client for elgg using python, and even when the request succeeds, I get this in response:

Traceback (most recent call last):
  File \"tes         


        
6条回答
  •  清歌不尽
    2020-12-05 00:34

    Previous answers are correct, but there's another case where you could get that exception:

    Making multiple requests without reading any intermediate responses completely.

    For instance:

    conn.request('PUT',...)
    conn.request('GET',...)
    # will not work: raises ResponseNotReady
    
    conn.request('PUT',...)
    r = conn.getresponse()
    r.read() # <-- that's the important call!
    conn.request('GET',...)
    r = conn.getresponse()
    r.read() # <-- same thing
    

    and so on.

提交回复
热议问题