[issue26231] HTTPResponse.close() should consume all remaining data in body if any

2016-01-28 Thread Jacky

New submission from Jacky:

HTTPResponse.close() in httplib should consume all remaining data in body if 
any. Or the followed request would get the unread content from the previous 
request, which result in the wrong result.

The following code shown that the second request will get a wrong status code 
if calling HTTPResponse.close() on the first response.

The whole code consists of a HTTP server and a client. The server will always 
return 403 for testing.


def client():
conn = httplib.HTTPConnection(HOST, PORT)
conn.request('GET', PATH, None, headers={})
rsp = conn.getresponse()
print rsp.status
rsp.close()  # close response

conn.request('GET', PATH, None, headers={})
rsp2 = conn.getresponse()
print rsp2.status  # --> should be 403

The full version see the attached file (The server used Tornado)

--
components: Library (Lib)
files: zzz.py
messages: 259122
nosy: Jacky
priority: normal
severity: normal
status: open
title: HTTPResponse.close() should consume all remaining data in body if any
type: enhancement
versions: Python 2.7
Added file: http://bugs.python.org/file41742/zzz.py

___
Python tracker 
<http://bugs.python.org/issue26231>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue26231] HTTPResponse.close() should consume all remaining data in body if any

2016-01-28 Thread Jacky

Jacky added the comment:

In my opinion, HTTPResponse.close() should do really close work. Not only 
releasing the underlying file obj but also need to consume the remaining data 
to make sure the request complete.

If close() does not consume the remaining data, the user would have to do it 
after invoking close(), regardless of how large the data is. But how do do it, 
the HTTPResponse has been closed. So we have to use HTTPConnection.sock to do 
read work. However, this looks somewhat weird.

--

___
Python tracker 
<http://bugs.python.org/issue26231>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com