Issue591349
This issue tracker has been migrated to GitHub,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2002-08-06 00:42 by rbgrn, last changed 2022-04-10 16:05 by admin. This issue is now closed.
Files | ||||
---|---|---|---|---|
File name | Uploaded | Description | Edit | |
python_httpbug_testcase.tgz | rbgrn, 2002-08-07 06:16 | Test code which reproduces the error | ||
httplib.diff | rbgrn, 2002-08-08 04:14 | a patch which fixes this so the proper exception is raised |
Messages (12) | |||
---|---|---|---|
msg11832 - (view) | Author: Rob Green (rbgrn) | Date: 2002-08-06 00:42 | |
This is the output that occurs about 1 in 500 hits to any particular URL. I've only seen it so far hitting servers running Apache 1.3.20, but I don't have enough data to limit it to that. Python 2.1.2 (#1, Mar 16 2002, 18:24:08) [GCC 2.95.3 [FreeBSD] 20010315 (release)] on freebsd4 h = httplib.HTTPConnection(host) response = h.getresponse() data = response.read() File "/usr/local/lib/python2.1/httplib.py", line 246, in read value = value + self._safe_read(chunk_left) File "/usr/local/lib/python2.1/httplib.py", line 314, in _safe_read chunk = self.fp.read(amt) TypeError: an integer is required |
|||
msg11833 - (view) | Author: Jeremy Hylton (jhylton) ![]() |
Date: 2002-08-06 12:42 | |
Logged In: YES user_id=31392 Can you provide any more information about what URLs cause problems? You could call set_debuglevel(1) to enable output of all HTTP trafffic. Or just a list of some of the URLs that failed. |
|||
msg11834 - (view) | Author: Rob Green (rbgrn) | Date: 2002-08-07 05:14 | |
Logged In: YES user_id=590105 I'd give you the URLs but I don't think it matters that much, I've seen this problem now hitting 4 different machines, all running linux/apache. It's not something very easy for me to reproduce because I only see the exception thrown once or maybe twice during the day where there are 20,000 hits from my daemon that day. I suppose that the way to reproduce it would be to have a list of urls, and to just have an app sit there and cycle through them doing a GET every 5 seconds or so, and eventually it should show up. I suppose to be more accurate the app would have to be threaded as well, maybe having a thread for each url that just opens an HTTPConnection every 5 seconds. |
|||
msg11835 - (view) | Author: Rob Green (rbgrn) | Date: 2002-08-07 06:16 | |
Logged In: YES user_id=590105 Ok I put together some test code that reproduced the bug in under an hour on my machine. Here it is... |
|||
msg11836 - (view) | Author: Rob Green (rbgrn) | Date: 2002-08-08 03:51 | |
Logged In: YES user_id=590105 Ok I figured out what causes this. It's not a threading issue or anything like that, basically what happens is this: When httplib connects to a server and the hostname is good and the port is open and connects, but the server immediately disconnects without printing any text or anything, this exception is then thrown. I was able to reproduce it by running netcat -l -p <port> locally and starting an HTTPConnection to that port, then punting netcat which causes python to throw the exception. |
|||
msg11837 - (view) | Author: Rob Green (rbgrn) | Date: 2002-08-08 04:14 | |
Logged In: YES user_id=590105 Line 245 should be "if chunk_left is not _UNKNOWN:" And the next block up to line 259 should be indented. This causes an IncompleteRead exception to be thrown, which is IMO the correct one in this case. I attached a diff that patches the Python 2.1.2 httplib. |
|||
msg11838 - (view) | Author: Jeremy Hylton (jhylton) ![]() |
Date: 2002-09-03 22:20 | |
Logged In: YES user_id=31392 A bunch of questions. You seem to have narrowed this problem down a lot, but I'm not sure I understand the diagnosis. First off, have you tried the latest version of the code from CVS? It has changed in several ways, so it would be helpful if you could test with that version. I've been running a test driver for about an hour now without seeing any errors caused by httplib. The real problem I have is understanding what path through the code leaves chunked set to a true value and chunk_left set to something invalid. The begin() method of an HTTPResponse always sets chunked to 1 or 0. If it sets chunked to 1, it sets chunk_left to None. |
|||
msg11839 - (view) | Author: Rob Green (rbgrn) | Date: 2002-09-26 04:40 | |
Logged In: YES user_id=590105 I have not tried the latest version, however I defined the test case which reproduces the problem. It takes under a minute to try, so please try it on your version as I do not currently have time to checkout and build it myself. Thank-you. Here's the test case again `nc -l -p 8888` on some terminal then in python have your test prog connect to the IP of that terminal port 8888 and GET / HTTP/1.0 or whatever then on the terminal hit Ctrl-C instead of handing back a response the test prog should throw the exception if affected. Thanks |
|||
msg11840 - (view) | Author: Jeremy Hylton (jhylton) ![]() |
Date: 2003-01-31 14:19 | |
Logged In: YES user_id=31392 Just getting back to this bug: What is the nc program? I don't have it on my RedHat 7.3 installation. |
|||
msg11841 - (view) | Author: Rob Green (rbgrn) | Date: 2003-01-31 15:25 | |
Logged In: YES user_id=590105 netcat the rpm is called netcat but the executable is nc you should be able to get an rpm for it off of rpmfind.net It's a very common program for diagnosing plain-text protocol network code. |
|||
msg11842 - (view) | Author: Irmen de Jong (irmen) ![]() |
Date: 2004-11-07 22:39 | |
Logged In: YES user_id=129426 Can reproduce problem with Python 2.1.x, but cannot reproduce with Python versions >= 2.2.x For instance, python 2.4 gives a socket.error: (104, 'Connection reset by peer'). Which seems correct. So I think this bug can be closed |
|||
msg11843 - (view) | Author: Johannes Gijsbers (jlgijsbers) * ![]() |
Date: 2004-11-08 10:47 | |
Logged In: YES user_id=469548 Hmm, I'm getting a BadStatusLine exception on 2.3 and 2.4, but that seems to be the right exception as well, so I'm closing this. |
History | |||
---|---|---|---|
Date | User | Action | Args |
2022-04-10 16:05:33 | admin | set | github: 36987 |
2002-08-06 00:42:30 | rbgrn | create |