Issue1745073
Created on 2007-06-28.21:29:17 by rluse, last changed 2007-06-29.16:52:32 by rluse.
Messages | |||
---|---|---|---|
msg1689 (view) | Author: Bob Luse (rluse) | Date: 2007-06-28.21:29:17 | |
Hi, This one is a little strange and I'm not sure how serious it is, but I thought I would document it while I have recreated it. When I run the following script on Jython 2.2b2: import SocketServer import socket import string class EchoHandler(SocketServer.BaseRequestHandler): def handle(self): f = self.request.makefile() self.request.send("HTTP/1.0 200 OK\r\n") self.request.send("Content-type text/plain\r\n\r\n") self.request.send("Received connection from %s\r\n\r\n" % (self.client_address,)) while True: line = f.readline() self.request.send(line) if not string.strip(line): break f.close() import sys print sys.version print sys.platform serv = SocketServer.TCPServer(("", 9000), EchoHandler) print 'Running on port 9000' serv.serve_forever() ---------------------------------------------------- And then point my Firefox browser at http://localhost:9000 I get the following output: ------------------------------------------------- Received connection from ('sn45g', 1037) GET / HTTP/1.1 Host: localhost:9000 User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.4) Gecko/20070515 Firefox/2.0.0.4 Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5 Accept-Language: en-us,en;q=0.5 Accept-Encoding: gzip,deflate Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 Keep-Alive: 300 Connection: keep-alive Cache-Control: max-age=0 ----------------------------------------------------- but, when I run the same script on Jython 2.2RC1, I get this output in my browser: ---------------------------------------------------- Received connection from ('localhost', 4090) GET / HTTP/1.1 ------------------------------------------------------ It gives me 'localhost' instead of 'sn45g' which is my windows system name, and then trunkates much of the remaining response. |
|||
msg1690 (view) | Author: Alan Kennedy (amak) | Date: 2007-06-29.12:01:36 | |
I see that your code for this is using socket.makefile(). We know that simultaneously reading and writing on the same socket file wrapper can cause a deadlock, cf bug 1744567 that you reported. That might explain the curtailment of the output; the server thread might be hung on the write. Does the problem still happen if you use the socket.send and socket.recv methods directly? Meantime, I will look into the hostnames issue. |
|||
msg1691 (view) | Author: Bob Luse (rluse) | Date: 2007-06-29.14:46:35 | |
That was it. Good spot. |
|||
msg1692 (view) | Author: Alan Kennedy (amak) | Date: 2007-06-29.16:03:54 | |
Closing this as a duplicate of #1744567. I am not going to address the naming issue for now. The name returned for the remote end of the connection depends on the network configuration of the machine, i.e. does the traffic pass through loopback (thus causing 'localhost' to be returned), or reach the IP stack, in which case the Windows networking "Computer name" will be returned. If this is not acceptable, please open a separate issue. |
|||
msg1693 (view) | Author: Bob Luse (rluse) | Date: 2007-06-29.16:52:32 | |
Thats fine, I don't really have a problem with the naming. I just found it strange that it would be different when the difference was moving from 2.2b2 to 2.2RC1 and thought you may want to know about it. |
History | |||
---|---|---|---|
Date | User | Action | Args |
2007-06-28 21:29:17 | rluse | create |
Supported by Python Software Foundation,
Powered by Roundup