HTTP ResponseNotReady

P

pedr0

Hi at all,

I don't understand why, in this piece of code, i catch the

raise ResponseNotReady(self.__state)
http.client.ResponseNotReady: Request-sent

EVERY time I run this piece of code:

#connection
http_connection = http.client.HTTPConnection('www.xxx.net',80,timeout=60)
#first request
http_connection.request("POST", "/",params,headers=headers_)
r1 = http_connection.getresponse()
#second request
http_connection.request("GET", "/","",headers=headers_)
r2 = http_connection.getresponse()


Someone can help me ?
 
P

pedr0

Hi solved this problem, I have to add:



#connection
http_connection = http.client.HTTPConnection('www.xxx.net',80,timeout=60)
#first request
http_connection.request("POST", "/",params,headers=headers_)
r1 = http_connection.getresponse()
r1.read() // THIS ONE
#second request
http_connection.request("GET", "/","",headers=headers_)
r2 = http_connection.getresponse()


Someone know if this is a bug ?

Thanks
 
M

MRAB

Hi solved this problem, I have to add:



#connection
http_connection = http.client.HTTPConnection('www.xxx.net',80,timeout=60)
#first request
http_connection.request("POST", "/",params,headers=headers_)
r1 = http_connection.getresponse()
r1.read() // THIS ONE
#second request
http_connection.request("GET", "/","",headers=headers_)
r2 = http_connection.getresponse()


Someone know if this is a bug ?
It's not a bug.

The documentation for "getresponse" says:

"""HTTPConnection.getresponse()
Should be called after a request is sent to get the response from the
server. Returns an HTTPResponse instance.

Note
Note that you must have read the whole response before you can send a
new request to the server.
"""

The note is highlighted.
 
P

pedr0

Mumble mumble... I described bad my question I think, yes I read that, but maybe is not a correct way of working.

The http request I did retrieve (every time) an empty response, when I print the read() result call the result is the same of the sample you are talking about.

http://docs.python.org/py3k/library/http.client.html?highlight=http.client#http.client (2th sample)

Then I have to call the read() function only for change the state of my request, for this reasons I asked for a bug open in the http.client module.
 
P

pedr0

Mumble mumble... I described bad my question I think, yes I read that, but maybe is not a correct way of working.

The http request I did retrieve (every time) an empty response, when I print the read() result call the result is the same of the sample you are talking about.

http://docs.python.org/py3k/library/http.client.html?highlight=http.client#http.client (2th sample)

Then I have to call the read() function only for change the state of my request, for this reasons I asked for a bug open in the http.client module.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,979
Messages
2,570,185
Members
46,728
Latest member
FernMcmull

Latest Threads

Top